Beispiel #1
0
//*****************************************************************************
// initialization
//*****************************************************************************
void init_persistent(void) {
  p_to_save = newList();

  auxiliariesInstall("persistent_data", 
		     newAuxiliaryFuncs(AUXILIARY_TYPE_ROOM,
				       newPersistentData, deletePersistentData,
				       persistentDataCopyTo, persistentDataCopy,
				       persistentDataStore,persistentDataRead));

  // start our flushing of persistent rooms that need to be saved
  start_update(NULL, 1, flush_persistent_rooms_event, NULL,NULL,NULL);

  //
  // disabled until a better implementation is written.
  //
  // start_update(NULL, 1, close_unused_rooms_event,     NULL,NULL,NULL);

  // listen for objects and characters entering 
  // or leaving rooms. Update those rooms' statuses
  hookAdd("char_to_room",   update_persistent_char_to_room);
  hookAdd("char_from_room", update_persistent_char_from_room);
  hookAdd("obj_to_room",    update_persistent_obj_to_room);
  hookAdd("obj_from_room",  update_persistent_obj_from_room);
  hookAdd("obj_from_obj",   update_persistent_obj_from_obj);
  hookAdd("obj_to_obj",     update_persistent_obj_to_obj);
  hookAdd("room_from_game", update_persistent_room_from_game);
  hookAdd("room_change",    update_persistent_room_change);
  
  // add accessibility to Python
  /*
  PyRoom_addMethod("add_activity",  PyRoom_addActivity,   METH_NOARGS, NULL);
  PyRoom_addMethod("rem_activity",  PyRoom_remActivity,   METH_NOARGS, NULL);
  */
  PyRoom_addMethod("dirty",         PyRoom_dirtyPersistence,  METH_NOARGS,NULL);
  PyRoom_addMethod("unload",        PyRoom_unloadPersistence, METH_NOARGS,NULL);
  PyRoom_addGetSetter("persistent", 
		      PyRoom_getpersistent,     
		      PyRoom_setpersistent, NULL);
}
Beispiel #2
0
// initialize rooms for use. This must be called AFTER 
PyMODINIT_FUNC
init_PyRoom(void) {
    PyObject* module = NULL;

    // add all of the basic getsetters
    PyRoom_addGetSetter("vnum",  PyRoom_getvnum,   NULL, "The room's vnum");
    PyRoom_addGetSetter("chars", PyRoom_getchars,  NULL, "chars in the room");
    PyRoom_addGetSetter("objs",  PyRoom_getobjs,   NULL, "objects in the room");
    PyRoom_addGetSetter("contents",PyRoom_getobjs, NULL, "objects in the room");

    // add all of the basic methods
    PyRoom_addMethod("attach", PyRoom_attach, METH_VARARGS,
		     "attach a new script to the room.");
    PyRoom_addMethod("detach", PyRoom_detach, METH_VARARGS,
		     "detach a script from the room, by vnum.");
    PyRoom_addMethod("close", PyRoom_close, METH_VARARGS,
		     "close a door in the specified direction.");
    PyRoom_addMethod("open", PyRoom_open, METH_VARARGS,
		     "open a door in the specified direction. Also unlocks.");
    PyRoom_addMethod("lock", PyRoom_lock, METH_VARARGS,
		     "lock a door in the specified direction. Also closes.");
    PyRoom_addMethod("unlock", PyRoom_unlock, METH_VARARGS,
		     "unlocks a door in the specified direction.");
    PyRoom_addMethod("send", PyRoom_send, METH_VARARGS,
		     "send a message to everyone in the room.");

    // add in all the getsetters and methods
    makePyType(&PyRoom_Type, pyroom_getsetters, pyroom_methods);
    deleteListWith(pyroom_getsetters, free); pyroom_getsetters = NULL;
    deleteListWith(pyroom_methods,    free); pyroom_methods    = NULL;

    // make sure the room class is ready to be made
    if (PyType_Ready(&PyRoom_Type) < 0)
        return;

    // initialize the module
    module = Py_InitModule3("room", room_module_methods,
			    "The room module, for all MUD room-related stuff.");

    // make sure the module parsed OK
    if (module == NULL)
      return;

    // add the Room class to the room module
    PyModule_AddObject(module, "Room", (PyObject *)&PyRoom_Type);
    Py_INCREF(&PyRoom_Type);
}