void update_persistent_room_from_game(const char *info) { ROOM_DATA *room = NULL; hookParseInfo(info, &room); listRemove(p_to_save, room); // have we been replaced by a non-persistent room? ROOM_DATA *new_room = worldGetRoom(gameworld, roomGetClass(room)); if(roomIsPersistent(room) && new_room != NULL && !roomIsPersistent(new_room)) worldClearPersistentRoom(gameworld, roomGetClass(room)); }
// // save all of our pending persistent rooms to disc void flush_persistent_rooms_event(void *owner, void *data, const char *arg) { ROOM_DATA *room = NULL; while( (room = listPop(p_to_save)) != NULL) { worldStorePersistentRoom(gameworld, roomGetClass(room), room); roomClearPersistentDirty(room); } }
// // unload a persistent room from memory. Will not work if PCs are present. PyObject *PyRoom_unloadPersistence(PyObject *pyroom) { ROOM_DATA *room = PyRoom_AsRoom(pyroom); if(room == NULL) { PyErr_Format(PyExc_TypeError, "tried to save nonexistent room."); return NULL; } // it's not pesistent if(!roomIsPersistent(room)) return Py_BuildValue("i", 0); // does it contain a PC? LIST_ITERATOR *ch_i = newListIterator(roomGetCharacters(room)); CHAR_DATA *ch = NULL; bool pc_found = FALSE; ITERATE_LIST(ch, ch_i) { if(!charIsNPC(ch)) { pc_found = TRUE; break; } } deleteListIterator(ch_i); if(pc_found) return Py_BuildValue("i", 0); worldStorePersistentRoom(gameworld, roomGetClass(room), room); extract_room(room); return Py_BuildValue(""); }
void roomSetPersistent(ROOM_DATA *room, bool val) { PERSISTENT_DATA *data = roomGetAuxiliaryData(room, "persistent_data"); // if it was persistent before and not now, clear our database entry if(data->persistent == TRUE && val == FALSE) worldClearPersistentRoom(gameworld, roomGetClass(room)); data->persistent = val; }
void expand_exit_dynamic_descs(const char *info) { EXIT_DATA *me = NULL; CHAR_DATA *ch = NULL; hookParseInfo(info, &me, &ch); PyObject *pyme = newPyExit(me); char *locale = strdup(get_key_locale(roomGetClass(exitGetRoom(me)))); expand_dynamic_descs(charGetLookBuffer(ch), pyme, ch, locale); Py_DECREF(pyme); free(locale); }
void expand_room_dynamic_descs(const char *info) { ROOM_DATA *me = NULL; CHAR_DATA *ch = NULL; hookParseInfo(info, &me, &ch); PyObject *pyme = roomGetPyForm(me); char *locale = strdup(get_key_locale(roomGetClass(me))); expand_dynamic_descs(charGetLookBuffer(ch), pyme, ch, locale); Py_DECREF(pyme); free(locale); }
const char *get_smart_locale(CHAR_DATA *ch) { const char *locale = get_script_locale(); if(locale == NULL && charGetRoom(ch) != NULL) locale = get_key_locale(roomGetClass(charGetRoom(ch))); return locale; }