]> granicus.if.org Git - nethack/commitdiff
fix #Q295 - post-choking food side-effects
authornethack.rankin <nethack.rankin>
Thu, 8 Feb 2007 23:33:14 +0000 (23:33 +0000)
committernethack.rankin <nethack.rankin>
Thu, 8 Feb 2007 23:33:14 +0000 (23:33 +0000)
     From a bug report, but
just received:  if you choked while eating a cockatrice egg and survived,
the turn-to-stone sequence wouldn't be initiated.  For such eggs, turning
to stone starts when the food is finished rather than when it's started,
and fpostfx() wasn't called for food that triggered choking so the egg
went away without actually being finished.  Fortune cookies, lumps of
royal jelly, and a few other things suffered from the same situation.

doc/fixes34.4
src/eat.c

index c3fd2bc2bdfdd6e7fc9161ce2565185eed866b0a..88e7ce4a2c50f0eb0f043892783fcdc0cfe88eb0 100644 (file)
@@ -309,6 +309,8 @@ vomiting countdown actually triggered the final vomit code twice
 rats aren't capable of vomiting
 fireproof, non-rustable weapon would be revealed as fireproof by hitting a
        rust-causing target; ditto for fixed crysknife
+surviving choking while eating various foods (cockatrice egg, fortune cookie,
+       wolfsbane, others) didn't carry through to those foods' side-effects
 
 
 Platform- and/or Interface-Specific Fixes
index 3cef6fc7aaf0e595b44c6995a55b46ac141b19fd..8da84fc2ac1d02a493d2c91feb7bd4cf83005139 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -1635,6 +1635,8 @@ STATIC_OVL void
 start_eating(otmp)             /* called as you start to eat */
        register struct obj *otmp;
 {
+       const char *old_nomovemsg, *save_nomovemsg;
+
 #ifdef DEBUG
        debugpline("start_eating: %lx (victual = %lx)", otmp, context.victual.piece);
        debugpline("reqtime = %d", context.victual.reqtime);
@@ -1653,7 +1655,20 @@ start_eating(otmp)               /* called as you start to eat */
            }
        }
 
-       if (bite()) return;
+       old_nomovemsg = nomovemsg;
+       if (bite()) {
+           /* survived choking, finish off food that's nearly done;
+              need this to handle cockatrice eggs, fortune cookies, etc */
+           if (++context.victual.usedtime >= context.victual.reqtime) {
+               /* don't want done_eating() to issue nomovemsg if it
+                  is due to vomit() called by bite() */
+               save_nomovemsg = nomovemsg;
+               if (!old_nomovemsg) nomovemsg = 0;
+               done_eating(FALSE);
+               if (!old_nomovemsg) nomovemsg = save_nomovemsg;
+           }
+           return;
+       }
 
        if (++context.victual.usedtime >= context.victual.reqtime) {
            /* print "finish eating" message if they just resumed -dlc */