]> granicus.if.org Git - nethack/commitdiff
fix #H6015 - 'crash' on NAO
authorPatR <rankin@nethack.org>
Sat, 9 Sep 2017 23:21:22 +0000 (16:21 -0700)
committerPatR <rankin@nethack.org>
Sat, 9 Sep 2017 23:21:22 +0000 (16:21 -0700)
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.

doc/fixes36.1
src/uhitm.c

index 4032a9dc2b20995eb43ef809d9ff1347c45d0979..5c5e732b58d7d8fd9f709a3969fb1fc5754b6589 100644 (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
index b11cb0fd8059be7fbe4d139417a89eb104e6ed52..81a71a4069d03b3f8c4fa016a2f9b4707004708a 100644 (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