This is an unoffical update to roomsave.txt originally published by Reza Nejad , and updated by Russell Ryan It also uses code from house_save.patch to handle object within objects. Sadly this code doesn't have anyone's name on it, so I don't know who to credit. Also, BIG UPS go to Torgny Bjers for his help and advice (and code!) to help with objects within objects. Rather than only save rooms which have a special flag, this will save ANY room which has objects in it. --Ziz /* --begin instruction-- */ make a "rsv" directory in lib/world ----->in db.h after #define HLP_PREFIX LIB_TEXT"help"SLASH /* for HELP */ #define TRG_PREFIX LIB_WORLD"trg"SLASH /* trigger files */ add #define RSV_PREFIX LIB_WORLD"rsv"SLASH /* room save files */ ------>Stick this at the end of house.c int save_get_filename(int i, char *filename) { if (i < 0) return 0; sprintf(filename, RSV_PREFIX"%d.save", world[i].number); return 1; } int save_load(room_rnum rnum) { FILE *fll; char fname[MAX_STRING_LENGTH]; struct obj_file_elem object; /* int i; */ struct obj_data *cont_row[MAX_BAG_ROWS]; struct obj_data *obj1, *obj; int locate, j; /* Empty all of the container lists (you never know ...) */ for (j = 0; j < MAX_BAG_ROWS; j++) cont_row[j] = NULL; if (!save_get_filename(rnum, fname)) return 0; if (!(fll = fopen(fname, "r+b"))) return 0; while (!feof(fll)) { fread(&object, sizeof(struct obj_file_elem), 1, fll); if (ferror(fll)) { perror("Reading save file: save_load."); fclose(fll); return 0; } if (!feof(fll)) { if ((obj = Obj_from_store(object, &locate))) { obj_to_room(obj, rnum); if ( locate > 0) { for (j = MAX_BAG_ROWS-1;j>0;j--) { if (cont_row[j]) { for (;cont_row[j];cont_row[j] = obj1) { obj1 = cont_row[j]->next_content; obj_to_room(cont_row[j], rnum); } cont_row[j] = NULL; } } if (cont_row[0]) { if (GET_OBJ_TYPE(obj) == ITEM_CONTAINER) { obj->contains = NULL; for (;cont_row[0];cont_row[0] = obj1) { obj1 = cont_row[0]->next_content; obj_to_obj(cont_row[0], obj); } obj_to_room(obj, rnum); } else { for (;cont_row[0];cont_row[0] = obj1) { obj1 = cont_row[0]->next_content; obj_to_room(cont_row[0], rnum); } cont_row[0] = NULL; } } } else { /* Locate <= 0 */ for (j = MAX_BAG_ROWS-1;j > -locate;j--) { if (cont_row[j]) { /* No Container throw in room! */ for (;cont_row[j];cont_row[j] = obj1) { obj1 = cont_row[j]->next_content; obj_to_room(cont_row[j], rnum); } cont_row[j] = NULL; } } if (j== -locate && cont_row[j]) { if (GET_OBJ_TYPE(obj) == ITEM_CONTAINER) { obj_from_room(obj); obj->contains = NULL; for (;cont_row[j];cont_row[j] = obj1) { obj1 = cont_row[j]->next_content; obj_to_obj(cont_row[j], obj); } obj_to_room(obj, rnum); } else { /* Object isn't container -> empty content list */ for (;cont_row[j];cont_row[j] = obj1) { obj1 = cont_row[j]->next_content; obj_to_room(cont_row[j], rnum); } cont_row[j] = NULL; } } if (locate < 0 && locate >= -MAX_BAG_ROWS) { obj_from_room(obj); if ((obj1 = cont_row[-locate-1])) { while (obj1->next_content) { obj1 = obj1->next_content; } obj1->next_content = obj; } else { cont_row[-locate-1] = obj; } } } } } } rewind(fll); fclose(fll); return 1; } void save_boot(void) { int i; for (i = 0; i <= top_of_world; i++) save_load(i); } int save_save(struct obj_data *obj, FILE *fll, int locate) { struct obj_data *tmp; int result; if (obj) { save_save(obj->next_content, fll, locate); save_save(obj->contains, fll, MIN(0, locate)-1); result = Obj_to_store(obj, fll, locate); if (!result) return (0); for (tmp = obj->in_obj; tmp; tmp = tmp->in_obj) GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj); } return (1); } void save_restore_weight(struct obj_data * obj) { if (obj) { save_restore_weight(obj->contains); save_restore_weight(obj->next_content); if (obj->in_obj) GET_OBJ_WEIGHT(obj->in_obj) += GET_OBJ_WEIGHT(obj); } } void save_saved(int i) { char buf[MAX_STRING_LENGTH]; FILE *fll; if (i == -1) return; sprintf(buf, RSV_PREFIX"%d.save", world[i].number); fll = fopen(buf, "wb"); if (!save_save(world[i].contents, fll, 0)); { fclose(fll); return; } fclose(fll); save_restore_weight(world[i].contents); } void save_state(void) { FILE *tmp; char fname[MAX_INPUT_LENGTH]; int i; for (i = 0; i <= top_of_world; i++) { if (!save_get_filename(i, fname)) continue; if (!world[i].contents && ((tmp = fopen(fname, "rb")) != NULL)) { remove(fname); continue; } if (world[i].contents) save_saved(i); } } ------>Add this to the end of house.h void save_boot(void); void save_saved(int vnum); -----> In db.c in void_boot_db add log("Loading Saved Rooms."); save_boot(); anywhere you like inside of the boot routines (I suggest affter the house loading) ------> In act.wizard.c add to extern functions void save_state(void); ------> In act.wizard.c in do_shutdown() (or anywhere you find nice) after one_argument(argument, arg); add save_state(); ------> In comm.c add to extern functions void save_state(void); ------> In comm.c in heartbeat after House_save_all(); add save_state(); /* --end instruction-- */