/* Save new/edited mob to memory. */ void medit_save_internally(struct descriptor_data *d) { int i; mob_rnum new_rnum; struct descriptor_data *dsc; struct char_data *mob; i = (real_mobile(OLC_NUM(d)) == NOBODY); if ((new_rnum = add_mobile(OLC_MOB(d), OLC_NUM(d))) == NOBODY) { log("medit_save_internally: add_mobile failed."); return; } /* Update triggers and free old proto list */ if (mob_proto[new_rnum].proto_script && mob_proto[new_rnum].proto_script != OLC_SCRIPT(d)) free_proto_script(&mob_proto[new_rnum], MOB_TRIGGER); mob_proto[new_rnum].proto_script = OLC_SCRIPT(d); /* this takes care of the mobs currently in-game */ for (mob = character_list; mob; mob = mob->next) { if (GET_MOB_RNUM(mob) != new_rnum) continue; /* remove any old scripts */ if (SCRIPT(mob)) extract_script(mob, MOB_TRIGGER); free_proto_script(mob, MOB_TRIGGER); copy_proto_script(&mob_proto[new_rnum], mob, MOB_TRIGGER); assign_triggers(mob, MOB_TRIGGER); } /* end trigger update */ if (!i) /* Only renumber on new mobiles. */ return; /* Update keepers in shops being edited and other mobs being edited. */ for (dsc = descriptor_list; dsc; dsc = dsc->next) { if (STATE(dsc) == CON_SEDIT) S_KEEPER(OLC_SHOP(dsc)) += (S_KEEPER(OLC_SHOP(dsc)) != NOTHING && S_KEEPER(OLC_SHOP(dsc)) >= new_rnum); else if (STATE(dsc) == CON_MEDIT) GET_MOB_RNUM(OLC_MOB(dsc)) += (GET_MOB_RNUM(OLC_MOB(dsc)) != NOTHING && GET_MOB_RNUM(OLC_MOB(dsc)) >= new_rnum); } /* Update other people in zedit too. From: C.Raehl 4/27/99 */ for (dsc = descriptor_list; dsc; dsc = dsc->next) if (STATE(dsc) == CON_ZEDIT) for (i = 0; OLC_ZONE(dsc)->cmd[i].command != 'S'; i++) if (OLC_ZONE(dsc)->cmd[i].command == 'M') if (OLC_ZONE(dsc)->cmd[i].arg1 >= new_rnum) OLC_ZONE(dsc)->cmd[i].arg1++; }
/* * Save new/edited mob to memory. */ void medit_save_internally(struct descriptor_data *d) { int i; mob_rnum new_rnum; struct descriptor_data *dsc; i = (real_mobile(OLC_NUM(d)) == NOBODY); if ((new_rnum = add_mobile(OLC_MOB(d), OLC_NUM(d))) < 0) { log("medit_save_internally: add_object failed."); return; } if (!i) /* Only renumber on new mobiles. */ return; /* * Update keepers in shops being edited and other mobs being edited. */ for (dsc = descriptor_list; dsc; dsc = dsc->next) { if (STATE(dsc) == CON_SEDIT) S_KEEPER(OLC_SHOP(dsc)) += (S_KEEPER(OLC_SHOP(dsc)) >= new_rnum); else if (STATE(dsc) == CON_MEDIT) GET_MOB_RNUM(OLC_MOB(dsc)) += (GET_MOB_RNUM(OLC_MOB(dsc)) >= new_rnum); } /* * Update other people in zedit too. From: C.Raehl 4/27/99 */ for (dsc = descriptor_list; dsc; dsc = dsc->next) if (STATE(dsc) == CON_ZEDIT) for (i = 0; OLC_ZONE(dsc)->cmd[i].command != 'S'; i++) if (OLC_ZONE(dsc)->cmd[i].command == 'M') if (OLC_ZONE(dsc)->cmd[i].arg1 >= new_rnum) OLC_ZONE(dsc)->cmd[i].arg1++; }