u.uswallow

Make sure u.uswallow is cleared when u.ustuck gets set to Null so
that they won't be out of sync with each other.  Having u.uswallow
be non-zero does imply that u.ustuck is non-Null.

Running #panic while swallowed didn't produce any anomalies for me,
either before or after this change.
This commit is contained in:
PatR
2022-08-15 10:53:50 -07:00
parent b07fe59b3c
commit be0def37c1
4 changed files with 14 additions and 12 deletions

View File

@@ -2952,7 +2952,7 @@ monkilled(
}
void
set_ustuck(struct monst* mtmp)
set_ustuck(struct monst *mtmp)
{
if (iflags.sanity_check || iflags.debug_fuzzer) {
if (mtmp && !next2u(mtmp->mx, mtmp->my))
@@ -2962,23 +2962,26 @@ set_ustuck(struct monst* mtmp)
g.context.botl = 1;
u.ustuck = mtmp;
if (!u.ustuck) {
u.uswallow = 0;
u.uswldtim = 0;
}
}
void
unstuck(struct monst* mtmp)
unstuck(struct monst *mtmp)
{
if (u.ustuck == mtmp) {
struct permonst *ptr = mtmp->data;
unsigned swallowed = u.uswallow;
/* do this first so that docrt()'s botl update is accurate;
safe to do as long as u.uswallow is also cleared before docrt() */
clears u.uswallow as well as setting u.ustuck to Null */
set_ustuck((struct monst *) 0);
if (u.uswallow) {
if (swallowed) {
u.ux = mtmp->mx;
u.uy = mtmp->my;
u.uswallow = 0;
u.uswldtim = 0;
if (Punished && uchain->where != OBJ_FLOOR)
placebc();
g.vision_full_recalc = 1;