worn/wielded pointer sanity checks

Check the various uarm, uwep, and so forth pointers to make sure that
they point to items in hero's inventory and that those items have the
corresponding W_ARM, W_WEP, &c bit set in their owornmask field.
Also check whether any other items in inventory have the same bit set.
[Some of this is already handled by sanity_check_worn() in mkobj.c.]

Also validate two-weapon combat mode.  I don't recall ever seeing any
problems reported about it though.

Does not validate ball and chain.  Those should have their own sanity
checks that validate a bunch of other stuff besides just worn slots.
They already get some checking by the normal object tests.

This works ok with 'sanity_check' set and items worn and wielded
normally.  The only insane situation tested was by reverting the
confused-looting-with-quivered-gold fix from earlier today.  I haven't
used a debugger to force other such problems so this isn't very
thoroughly tested.
This commit is contained in:
PatR
2024-02-09 23:32:16 -08:00
parent c490265e35
commit e2a3c98aac
3 changed files with 111 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 cmd.c $NHDT-Date: 1704225560 2024/01/02 19:59:20 $ $NHDT-Branch: keni-luabits2 $:$NHDT-Revision: 1.699 $ */
/* NetHack 3.7 cmd.c $NHDT-Date: 1707547723 2024/02/10 06:48:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.704 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -4255,6 +4255,7 @@ you_sanity_check(void)
impossible("sanity_check: you over monster");
}
check_wornmask_slots();
(void) check_invent_gold("invent");
}