From b9acbbba9fc22b50b54dec1bf9ae71e295d9df79 Mon Sep 17 00:00:00 2001 From: kinther Date: Thu, 25 Sep 2025 09:13:24 -0700 Subject: [PATCH] Fix syserror messages on start related to msave --- src/act.wizard.c | 1 + src/db.c | 17 ++++++++++------- src/dg_mobcmd.c | 1 + 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/act.wizard.c b/src/act.wizard.c index dd4a0f6..198ba88 100644 --- a/src/act.wizard.c +++ b/src/act.wizard.c @@ -1726,6 +1726,7 @@ ACMD(do_load) for (i=0; i < n; i++) { mob = read_mobile(r_num, REAL); char_to_room(mob, IN_ROOM(ch)); + equip_mob_from_loadout(mob); act("$n makes a quaint, magical gesture with one hand.", TRUE, ch, 0, 0, TO_ROOM); act("$n has created $N!", FALSE, ch, 0, mob, TO_ROOM); diff --git a/src/db.c b/src/db.c index 71925b8..30847d0 100644 --- a/src/db.c +++ b/src/db.c @@ -2472,6 +2472,10 @@ void equip_mob_from_loadout(struct char_data *mob) { if (!mob || !IS_NPC(mob)) return; + /* If called too early (e.g., from some future path), just do nothing. */ + if (IN_ROOM(mob) == NOWHERE) + return; + mob_rnum rnum = GET_MOB_RNUM(mob); if (rnum < 0) return; @@ -2589,9 +2593,6 @@ struct char_data *read_mobile(mob_vnum nr, int type) /* and mob_rnum */ mob->script_id = 0; // this is set later by char_script_id - /* Equip/load items from prototype loadout before scripts fire */ - equip_mob_from_loadout(mob); - copy_proto_script(&mob_proto[i], mob, MOB_TRIGGER); assign_triggers(mob, MOB_TRIGGER); @@ -2754,13 +2755,15 @@ void reset_zone(zone_rnum zone) case 'M': /* read a mobile */ if (mob_index[ZCMD.arg1].number < ZCMD.arg2) { - mob = read_mobile(ZCMD.arg1, REAL); - char_to_room(mob, ZCMD.arg3); + mob = read_mobile(ZCMD.arg1, REAL); + char_to_room(mob, ZCMD.arg3); + /* NEW: equip from prototype loadout now that the mob is in a room */ + equip_mob_from_loadout(mob); load_mtrigger(mob); tmob = mob; - last_cmd = 1; + last_cmd = 1; } else - last_cmd = 0; + last_cmd = 0; tobj = NULL; break; diff --git a/src/dg_mobcmd.c b/src/dg_mobcmd.c index 1a89820..78f2fcd 100644 --- a/src/dg_mobcmd.c +++ b/src/dg_mobcmd.c @@ -377,6 +377,7 @@ ACMD(do_mload) return; } char_to_room(mob, rnum); + equip_mob_from_loadout(mob); if (SCRIPT(ch)) { /* It _should_ have, but it might be detached. */ char buf[MAX_INPUT_LENGTH]; sprintf(buf, "%c%ld", UID_CHAR, char_script_id(mob));