fix github issue #769 - revive panic

Issue #769, reported by k2 and diagnosed by entrez:  eating a troll
corpse that revives on the last turn of the meal was using up the
corpse while the revival was in progress (unless the hero couldn't
observe the resulting monster), leading to a panic when trying to
use it up at the end of revival.  Brought on by a recent change to
interrupt an occupied hero who can observe a hostile monster being
created nearby.

The fix isn't perfect.  If revival fails because there's no place
to put the revived troll, the meal will be interrupted with one bite
left instead of finishing.  If that happens, the interruption will
include a "you stop eating" message, just with no explanation why.
The partly eaten--almost completely eaten--corpse will remain.

Closes #769
This commit is contained in:
PatR
2022-06-10 11:35:07 -07:00
parent 95dece1a2b
commit e2d694ed32
3 changed files with 36 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 zap.c $NHDT-Date: 1654881021 2022/06/10 17:10:21 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.425 $ */
/* NetHack 3.7 zap.c $NHDT-Date: 1654886101 2022/06/10 18:35:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.426 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -804,6 +804,10 @@ revive(struct obj *corpse, boolean by_hero)
impossible("Attempting to revive %s?", xname(corpse));
return (struct monst *) 0;
}
/* if this corpse is being eaten, stop doing that; this should be done
after makemon() succeeds and skipped if it fails, but waiting until
we know the result for that would be too late */
cant_finish_meal(corpse);
x = y = 0;
if (corpse->where != OBJ_CONTAINED) {