]> granicus.if.org Git - nethack/commitdiff
fix #H4181 - strange death messages
authorPatR <rankin@nethack.org>
Thu, 7 Jan 2016 09:53:06 +0000 (01:53 -0800)
committerPatR <rankin@nethack.org>
Thu, 7 Jan 2016 09:53:06 +0000 (01:53 -0800)
"Petrified by <foo>, while getting stoned." -- multi_reason "while
getting stoned" explains why no last-second recovery could be made,
but doesn't explain how the petrification happened, so suppress it.

"Died of starvation, while fainted from lack of food." -- nethack
does not display this; presumeably the IRC death notices for NAO are
generated from xlogfile entries.  Change 'while fainted from lack of
food' to 'while fainted' at time of death if reason for death is
starvation.  The longer version is accurate but sounds fairly silly.

When starvation is set in motion, set it up before checking whether
the initial faint triggers falling on a wielded cockatrice corpse, so
that fainting isn't applied after recovery in case of life-saving.

doc/fixes36.1
src/eat.c
src/end.c

index 12386fc24004eb7a9761a8a1525549d40259ba8f..b2c3197ca97335b2c72973849c6710b47378f828 100644 (file)
@@ -88,6 +88,7 @@ make mimics mimicing walls or trees also block light
 stepping onto lava destroyed non-fireproof water walking boots but left other
        vulnerable boot types intact
 fix death reason when eating tainted glob of <monster> (not corpse)
+fix death reason when petrified (avoid redundant 'while getting stoned')
 use appropriate place name for drum of earthquake shakes
 fix unmapped branch stairs on sokoban level
 redraw map when hilite_pile is toggled to display the highlighting
index 7591b9cc39dda32cfa2a3413c566e746fab847b2..13a3944052b06720778182a2674464319c6de93f 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -2838,14 +2838,14 @@ boolean incr;
                 /* stop what you're doing, then faint */
                 stop_occupation();
                 You("faint from lack of food.");
-                if (!Levitation)
-                    selftouch("Falling, you");
                 incr_itimeout(&HDeaf, duration);
                 nomul(-duration);
                 multi_reason = "fainted from lack of food";
                 nomovemsg = "You regain consciousness.";
                 afternmv = unfaint;
                 newhs = FAINTED;
+                if (!Levitation)
+                    selftouch("Falling, you");
             }
         } else if (u.uhunger < -(int) (200 + 20 * ACURR(A_CON))) {
             u.uhs = STARVED;
index 5e52318562c8ce14bf157c32c758059ceba227d0..7e53467e71d0c32afc44d2ab299822aa63d30d35 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -503,6 +503,42 @@ int how;
     return;
 }
 
+/* some special cases for overriding while-helpless reason */
+static const struct {
+    int why, unmulti;
+    const char *exclude, *include;
+} death_fixups[] = {
+    /* "petrified by <foo>, while getting stoned" -- "while getting stoned"
+       prevented any last-second recovery, but it was not the cause of
+       "petrified by <foo>" */
+    { STONING, 1, "getting stoned", (char *) 0 },
+    /* "died of starvation, while fainted from lack of food" is accurate
+       but sounds a fairly silly (and doesn't actually appear unless you
+       splice together death and while-helpless from xlogfile) */
+    { STARVING, 0, "fainted from lack of food", "fainted" },
+};
+
+/* clear away while-helpless when the cause of death caused that
+   helplessness (ie, "petrified by <foo> while getting stoned") */
+STATIC_DCL void
+fixup_death(how)
+int how;
+{
+    int i;
+
+    for (i = 0; i < SIZE(death_fixups); ++i)
+        if (death_fixups[i].why == how
+            && !strcmp(death_fixups[i].exclude, multi_reason)) {
+            if (death_fixups[i].include) /* substitute an alternate reason */
+                multi_reason = death_fixups[i].include;
+            else /* remove the helplessness reason */
+                multi_reason = (char *) 0;
+            if (death_fixups[i].unmulti) /* possibly hide helplessness */
+                multi = 0L;
+            break;
+        }
+}
+
 #if defined(WIN32) && !defined(SYSCF)
 #define NOTIFY_NETHACK_BUGS
 #endif
@@ -1002,6 +1038,8 @@ int how;
     if (how == ESCAPED || how == PANICKED)
         killer.format = NO_KILLER_PREFIX;
 
+    fixup_death(how); /* actually, fixup multi_reason */
+
     if (how != PANICKED) {
         /* these affect score and/or bones, but avoid them during panic */
         taken = paybill((how == ESCAPED) ? -1 : (how != QUIT));