fix #H6015 - 'crash' on NAO

Reported for nethack.alt.org where impossible events in to-be-3.6.1
trigger a panic instead of just a warning, being polymorphed into a
vampire and draining something to 0 HP (rather than killing it with
the bite attack) didn't properly kill off the victim unless it was
also being drained from level 0 to level -1, resulting in impossible
"dmonsfree: 1 removed doesn't match 0 pending".  If the hero got
another move before dead monsters were purged, applying a stethscope
to the victim could trigger an actual crash rather than an impossible
escalated to a panic.  Other actions such as attacking again probably
could too.

A followup included a diagnosis and one-line patch.  I expanded the
adjacent comment when manually putting the patch into place.
This commit is contained in:
PatR
2017-09-09 16:21:22 -07:00
parent a4becd6970
commit 263bd05fa0
2 changed files with 6 additions and 3 deletions

View File

@@ -473,6 +473,8 @@ wizhelp: ^O is #overview in wizard mode too; #wizwhere shows dungeon layout
wishing for tins sometimes yielded a tin wand
replace the fix for preventing putting on a helm of opposite alignment from
causing wielded Excalibur from blasting hero twice
hero poly'd into vampire could drain monster down to 0 HP without killing it,
triggering impossible "dmonsfree: 1 removed doesn't match 0 pending"
Platform- and/or Interface-Specific Fixes

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 uhitm.c $NHDT-Date: 1496860757 2017/06/07 18:39:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.166 $ */
/* NetHack 3.6 uhitm.c $NHDT-Date: 1504999056 2017/09/09 23:17:36 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.167 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1609,8 +1609,9 @@ register struct attack *mattk;
pline("%s suddenly seems weaker!", Monnam(mdef));
mdef->mhpmax -= xtmp;
mdef->mhp -= xtmp;
/* !m_lev: level 0 monster is killed rather than drop to -1 */
if (mdef->mhp <= 0 && !mdef->m_lev) {
/* !m_lev: level 0 monster is killed regardless of hit points
rather than drop to level -1 */
if (mdef->mhp <= 0 || !mdef->m_lev) {
pline("%s dies!", Monnam(mdef));
xkilled(mdef, XKILL_NOMSG);
} else