/* * This procedure frees up the strings and/or the structures * attatched to a descriptor, sets all flags back to how they * should be. */ void cleanup_olc(struct descriptor_data *d, byte cleanup_type) { /* * Clean up WHAT? */ if (d->olc == NULL) return; /* * Check for a room. free_room doesn't perform * sanity checks, we must be careful here. */ if (OLC_ROOM(d)) { switch (cleanup_type) { case CLEANUP_ALL: free_room(OLC_ROOM(d)); break; case CLEANUP_STRUCTS: free(OLC_ROOM(d)); break; default: /* The caller has screwed up. */ log("SYSERR: cleanup_olc: Unknown type!"); break; } } /* * Check for an existing object in the OLC. The strings * aren't part of the prototype any longer. They get added * with strdup(). */ if (OLC_OBJ(d)) { free_object_strings(OLC_OBJ(d)); free(OLC_OBJ(d)); } /* * Check for a mob. free_mobile() makes sure strings are not in * the prototype. */ if (OLC_MOB(d)) free_mobile(OLC_MOB(d)); /* * Check for a zone. cleanup_type is irrelevant here, free() everything. */ if (OLC_ZONE(d)) { free(OLC_ZONE(d)->name); free(OLC_ZONE(d)->cmd); free(OLC_ZONE(d)); } /* * Check for a shop. free_shop doesn't perform sanity checks, we must * be careful here. */ if (OLC_SHOP(d)) { switch (cleanup_type) { case CLEANUP_ALL: free_shop(OLC_SHOP(d)); break; case CLEANUP_STRUCTS: free(OLC_SHOP(d)); break; default: /* The caller has screwed up but we already griped above. */ break; } } /* Triggers */ #if 0 /* * this is the command list - it's been copied to disk already, * so just free it -- Welcor */ if (OLC_STORAGE(d)) { free(OLC_STORAGE(d)); OLC_STORAGE(d) = NULL; } /* * Free this one regardless. If we've left olc, we've either made * a fresh copy of it in the trig index, or we lost connection. * Either way, we need to get rid of this. */ if (OLC_TRIG(d)) { free_trigger(OLC_TRIG(d)); OLC_STORAGE(d) = NULL; } #endif /* * Restore descriptor playing status. */ if (d->character) { REMOVE_BIT_AR(PLR_FLAGS(d->character), PLR_WRITING); STATE(d) = CON_PLAYING; act("$n stops using OLC.", TRUE, d->character, NULL, NULL, TO_ROOM); mudlog(CMP, LVL_IMMORT, TRUE, "OLC: %s stops editing zone %d allowed zone %d", GET_NAME(d->character), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(d->character)); } free(d->olc); d->olc = NULL; }
/* This procedure frees up the strings and/or the structures attatched to a * descriptor, sets all flags back to how they should be. */ void cleanup_olc(struct descriptor_data *d, byte cleanup_type) { /* Clean up WHAT? */ if (d->olc == NULL) return; /* Check for a room. free_room doesn't perform sanity checks, we must be * careful here. */ if (OLC_ROOM(d)) { switch (cleanup_type) { case CLEANUP_ALL: /* free(OLC_SCRIPT(d)) equivalent */ free_proto_script(OLC_ROOM(d), WLD_TRIGGER); free_room(OLC_ROOM(d)); break; case CLEANUP_STRUCTS: free(OLC_ROOM(d)); break; case CLEANUP_CONFIG: free_config(OLC_CONFIG(d)); break; default: /* The caller has screwed up. */ log("SYSERR: cleanup_olc: Unknown type!"); break; } } /* Check for an existing object in the OLC. The strings aren't part of the * prototype any longer. They get added with strdup(). */ if (OLC_OBJ(d)) { free_object_strings(OLC_OBJ(d)); free(OLC_OBJ(d)); } /* Check for a mob. free_mobile() makes sure strings are not in the * prototype. */ if (OLC_MOB(d)) free_mobile(OLC_MOB(d)); /* Check for a zone. cleanup_type is irrelevant here, free() everything. */ if (OLC_ZONE(d)) { if (OLC_ZONE(d)->builders) free(OLC_ZONE(d)->builders); if (OLC_ZONE(d)->name) free(OLC_ZONE(d)->name); if (OLC_ZONE(d)->cmd) free(OLC_ZONE(d)->cmd); free(OLC_ZONE(d)); } /* Check for a shop. free_shop doesn't perform sanity checks, we must be * careful here. OLC_SHOP(d) is a _copy_ - no pointers to the original. Just * go ahead and free it all. */ if (OLC_SHOP(d)) free_shop(OLC_SHOP(d)); /* Check for a quest. */ if (OLC_QUEST(d)) { switch (cleanup_type) { case CLEANUP_ALL: free_quest(OLC_QUEST(d)); break; case CLEANUP_STRUCTS: free(OLC_QUEST(d)); break; default: break; } } /*. Check for aedit stuff -- M. Scott */ if (OLC_ACTION(d)) { switch(cleanup_type) { case CLEANUP_ALL: free_action(OLC_ACTION(d)); break; case CLEANUP_STRUCTS: free(OLC_ACTION(d)); break; default: /* Caller has screwed up */ break; } } /* Used for cleanup of Hedit */ if (OLC_HELP(d)) { switch(cleanup_type) { case CLEANUP_ALL: free_help(OLC_HELP(d)); break; case CLEANUP_STRUCTS: free(OLC_HELP(d)); break; default: break; } } if (OLC_IBT(d)) { free_olc_ibt(OLC_IBT(d)); OLC_IBT(d) = NULL; } if (OLC_MSG_LIST(d)) { free_message_list(OLC_MSG_LIST(d)); OLC_MSG_LIST(d) = NULL; OLC_MSG(d) = NULL; } /* Free storage if allocated (tedit, aedit, and trigedit). This is the command * list - it's been copied to disk already, so just free it -Welcor. */ if (OLC_STORAGE(d)) { free(OLC_STORAGE(d)); OLC_STORAGE(d) = NULL; } /* Free this one regardless. If we've left olc, we've either made a fresh * copy of it in the trig index, or we lost connection. Either way, we need * to get rid of this. */ if (OLC_TRIG(d)) { free_trigger(OLC_TRIG(d)); OLC_TRIG(d) = NULL; } /* Free this one regardless. If we've left olc, we've either copied the * * preferences to the player, or we lost connection. Either way, we need * * to get rid of this. */ if(OLC_PREFS(d)) { /*. There is nothing else really to free, except this... .*/ free(OLC_PREFS(d)); OLC_PREFS(d) = NULL; } /* OLC_SCRIPT is always set as trig_proto of OLC_OBJ/MOB/ROOM. Therefore it * should not be free'd here. */ /* Restore descriptor playing status. */ if (d->character) { REMOVE_BIT_AR(PLR_FLAGS(d->character), PLR_WRITING); act("$n stops using OLC.", TRUE, d->character, NULL, NULL, TO_ROOM); if (cleanup_type == CLEANUP_CONFIG) mudlog(BRF, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing the game configuration", GET_NAME(d->character)); else if (STATE(d) == CON_TEDIT) mudlog(BRF, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing text files.", GET_NAME(d->character)); else if (STATE(d) == CON_HEDIT) mudlog(CMP, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing help files.", GET_NAME(d->character)); else mudlog(CMP, ADMLVL_IMMORT, TRUE, "OLC: %s stops editing zone %d allowed zone %d", GET_NAME(d->character), zone_table[OLC_ZNUM(d)].number, GET_OLC_ZONE(d->character)); STATE(d) = CON_PLAYING; } free(d->olc); d->olc = NULL; }
int copy_object(struct obj_data *to, struct obj_data *from) { free_object_strings(to); return copy_object_main(to, from, TRUE); }