sanity check of objs_deleted

Teach obj_sanity_check() and clear_bypasses() about the new obj list.
It should always be empty when sanity checks are performed.  That
might not be the case when obj bypasses are cleared, although failing
to clear bypasses for deleted objects wouldn't make any difference,
so this is mainly cosmetic.
This commit is contained in:
PatR
2024-05-07 12:19:43 -07:00
parent c8b8f8767e
commit 8d9b26e26d
2 changed files with 12 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 mkobj.c $NHDT-Date: 1704316444 2024/01/03 21:14:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.282 $ */
/* NetHack 3.7 mkobj.c $NHDT-Date: 1715109575 2024/05/07 19:19:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.296 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2692,6 +2692,13 @@ dealloc_obj(struct obj *obj)
obj->lamplit = 0;
}
/* clear some bits that obj_sanity() would complain about if it were
to be called when the objs_deleted list is populated */
obj->unpaid = obj->no_charge = 0;
obj->in_use = obj->bypass = obj->nomerge = 0;
if (obj->otyp == BOULDER)
obj->next_boulder = 0;
if (obj == gt.thrownobj)
gt.thrownobj = 0;
if (obj == gk.kickedobj)
@@ -2728,7 +2735,7 @@ dealloc_obj_real(struct obj *obj)
void
dobjsfree(void)
{
struct obj *otmp = go.objs_deleted;
struct obj *otmp;
while (go.objs_deleted) {
otmp = go.objs_deleted->nobj;
@@ -2894,6 +2901,7 @@ obj_sanity_check(void)
objlist_sanity(gm.migrating_objs, OBJ_MIGRATING, "migrating sanity");
objlist_sanity(gl.level.buriedobjlist, OBJ_BURIED, "buried sanity");
objlist_sanity(gb.billobjs, OBJ_ONBILL, "bill sanity");
objlist_sanity(go.objs_deleted, OBJ_DELETED, "deleted object sanity");
mon_obj_sanity(fmon, "minvent sanity");
mon_obj_sanity(gm.migrating_mons, "migrating minvent sanity");

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 worn.c $NHDT-Date: 1707547726 2024/02/10 06:48:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.100 $ */
/* NetHack 3.7 worn.c $NHDT-Date: 1715109581 2024/05/07 19:19:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.109 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -994,6 +994,7 @@ clear_bypasses(void)
clear_bypass(gm.migrating_objs);
clear_bypass(gl.level.buriedobjlist);
clear_bypass(gb.billobjs);
clear_bypass(go.objs_deleted);
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if (DEADMONSTER(mtmp))
continue;