fix #H8922 - no "you finish eating" message

after being interrupted and then resuming.  Resuming a multi-turn
food when it only had one bite left was the culprit.
This commit is contained in:
PatR
2019-06-22 13:03:50 -07:00
parent eaa8c278c8
commit 456996509b
2 changed files with 52 additions and 35 deletions
+5 -1
View File
@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.62 $ $NHDT-Date: 1561081353 2019/06/21 01:42:33 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.64 $ $NHDT-Date: 1561233801 2019/06/22 20:03:21 $
This fixes36.3 file is here to capture information about updates in the 3.6.x This fixes36.3 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.2 in May 2019. Please note, however, lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -80,6 +80,10 @@ add Space, Return, and Escape to '? k' (help for menu control keys)
hero can no longer negotiate a bribe with a demon lord when deaf hero can no longer negotiate a bribe with a demon lord when deaf
wishing for "foo amulet" now yields an "amulet of foo" rather than random one wishing for "foo amulet" now yields an "amulet of foo" rather than random one
code in parse_conf_file() to trim trailing blanks/cr was skipping over them code in parse_conf_file() to trim trailing blanks/cr was skipping over them
partly eaten food with one bite left had message anomalies when eaten; the
usual "you resume your meal" case lacked the "you're finished" message
when done; eating something else in between to clobber meal context
resulted in no messages at all when restarting and finishing last bite
Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository
+47 -34
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 eat.c $NHDT-Date: 1559670604 2019/06/04 17:50:04 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.202 $ */ /* NetHack 3.6 eat.c $NHDT-Date: 1561233801 2019/06/22 20:03:21 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.203 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -25,7 +25,7 @@ STATIC_DCL void FDECL(cpostfx, (int));
STATIC_DCL void FDECL(consume_tin, (const char *)); STATIC_DCL void FDECL(consume_tin, (const char *));
STATIC_DCL void FDECL(start_tin, (struct obj *)); STATIC_DCL void FDECL(start_tin, (struct obj *));
STATIC_DCL int FDECL(eatcorpse, (struct obj *)); STATIC_DCL int FDECL(eatcorpse, (struct obj *));
STATIC_DCL void FDECL(start_eating, (struct obj *)); STATIC_DCL void FDECL(start_eating, (struct obj *, BOOLEAN_P));
STATIC_DCL void FDECL(fprefx, (struct obj *)); STATIC_DCL void FDECL(fprefx, (struct obj *));
STATIC_DCL void FDECL(fpostfx, (struct obj *)); STATIC_DCL void FDECL(fpostfx, (struct obj *));
STATIC_DCL int NDECL(bite); STATIC_DCL int NDECL(bite);
@@ -1419,15 +1419,12 @@ const char *mesg;
gainstr(tin, 0, FALSE); gainstr(tin, 0, FALSE);
tin = costly_tin(COST_OPEN); tin = costly_tin(COST_OPEN);
lesshungry(tin->blessed ? 600 /* blessed */
lesshungry(tin->blessed : !tin->cursed ? (400 + rnd(200)) /* uncursed */
? 600 /* blessed */ : (200 + rnd(400))); /* cursed */
: !tin->cursed
? (400 + rnd(200)) /* uncursed */
: (200 + rnd(400))); /* cursed */
} }
use_up_tin: use_up_tin:
if (carried(tin)) if (carried(tin))
useup(tin); useup(tin);
else else
@@ -1505,7 +1502,7 @@ struct obj *otmp;
} }
pline("Using %s you try to open the tin.", yobjnam(uwep, (char *) 0)); pline("Using %s you try to open the tin.", yobjnam(uwep, (char *) 0));
} else { } else {
no_opener: no_opener:
pline("It is not so easy to open this tin."); pline("It is not so easy to open this tin.");
if (Glib) { if (Glib) {
pline_The("tin slips from your %s.", pline_The("tin slips from your %s.",
@@ -1729,8 +1726,9 @@ struct obj *otmp;
/* called as you start to eat */ /* called as you start to eat */
STATIC_OVL void STATIC_OVL void
start_eating(otmp) start_eating(otmp, already_partly_eaten)
struct obj *otmp; struct obj *otmp;
boolean already_partly_eaten;
{ {
const char *old_nomovemsg, *save_nomovemsg; const char *old_nomovemsg, *save_nomovemsg;
@@ -1774,7 +1772,8 @@ struct obj *otmp;
if (++context.victual.usedtime >= context.victual.reqtime) { if (++context.victual.usedtime >= context.victual.reqtime) {
/* print "finish eating" message if they just resumed -dlc */ /* print "finish eating" message if they just resumed -dlc */
done_eating(context.victual.reqtime > 1 ? TRUE : FALSE); done_eating((context.victual.reqtime > 1
|| already_partly_eaten) ? TRUE : FALSE);
return; return;
} }
@@ -1783,28 +1782,35 @@ struct obj *otmp;
} }
/* /*
* called on "first bite" of (non-corpse) food. * Called on "first bite" of (non-corpse) food, after touchfood() has
* used for non-rotten non-tin non-corpse food * marked it 'partly eaten'. Used for non-rotten non-tin non-corpse food.
* Messages should use present tense since multi-turn food won't be
* finishing at the time they're issued.
*/ */
STATIC_OVL void STATIC_OVL void
fprefx(otmp) fprefx(otmp)
struct obj *otmp; struct obj *otmp;
{ {
switch (otmp->otyp) { switch (otmp->otyp) {
case FOOD_RATION: case FOOD_RATION: /* nutrition 800 */
/* 200+800 remains below 1000+1, the satiation threshold */
if (u.uhunger <= 200) if (u.uhunger <= 200)
pline(Hallucination ? "Oh wow, like, superior, man!" pline("%s!", Hallucination ? "Oh wow, like, superior, man"
: "That food really hit the spot!"); : "This food really hits the spot");
else if (u.uhunger <= 700)
pline("That satiated your %s!", body_part(STOMACH)); /* 700-1+800 remains below 1500, the choking threshold which
triggers "you're having a hard time getting it down" feedback */
else if (u.uhunger < 700)
pline("This satiates your %s!", body_part(STOMACH));
/* [satiation message may be inaccurate if eating gets interrupted] */
break; break;
case TRIPE_RATION: case TRIPE_RATION:
if (carnivorous(youmonst.data) && !humanoid(youmonst.data)) if (carnivorous(youmonst.data) && !humanoid(youmonst.data)) {
pline("That tripe ration was surprisingly good!"); pline("This tripe ration is surprisingly good!");
else if (maybe_polyd(is_orc(youmonst.data), Race_if(PM_ORC))) } else if (maybe_polyd(is_orc(youmonst.data), Race_if(PM_ORC))) {
pline(Hallucination ? "Tastes great! Less filling!" pline(Hallucination ? "Tastes great! Less filling!"
: "Mmm, tripe... not bad!"); : "Mmm, tripe... not bad!");
else { } else {
pline("Yak - dog food!"); pline("Yak - dog food!");
more_experienced(1, 0); more_experienced(1, 0);
newexplevel(); newexplevel();
@@ -1837,7 +1843,7 @@ struct obj *otmp;
default: default:
if (otmp->otyp == SLIME_MOLD && !otmp->cursed if (otmp->otyp == SLIME_MOLD && !otmp->cursed
&& otmp->spe == context.current_fruit) { && otmp->spe == context.current_fruit) {
pline("My, that was a %s %s!", pline("My, this is a %s %s!",
Hallucination ? "primo" : "yummy", Hallucination ? "primo" : "yummy",
singular(otmp, xname)); singular(otmp, xname));
} else if (otmp->otyp == APPLE && otmp->cursed && !Sleep_resistance) { } else if (otmp->otyp == APPLE && otmp->cursed && !Sleep_resistance) {
@@ -1856,9 +1862,7 @@ struct obj *otmp;
if (!Hallucination) { if (!Hallucination) {
pline("Core dumped."); pline("Core dumped.");
} else { } else {
/* This is based on an old Usenet joke, a fake a.out manual /* based on an old Usenet joke, a fake a.out manual page */
* page
*/
int x = rnd(100); int x = rnd(100);
pline("%s -- core dumped.", pline("%s -- core dumped.",
@@ -1876,7 +1880,7 @@ struct obj *otmp;
will be abused more times before illness completes */ will be abused more times before illness completes */
make_vomiting((Vomiting & TIMEOUT) + (long) d(10, 4), TRUE); make_vomiting((Vomiting & TIMEOUT) + (long) d(10, 4), TRUE);
} else { } else {
give_feedback: give_feedback:
pline("This %s is %s", singular(otmp, xname), pline("This %s is %s", singular(otmp, xname),
otmp->cursed otmp->cursed
? (Hallucination ? "grody!" : "terrible!") ? (Hallucination ? "grody!" : "terrible!")
@@ -2443,7 +2447,8 @@ doeat()
{ {
struct obj *otmp; struct obj *otmp;
int basenutrit; /* nutrition of full item */ int basenutrit; /* nutrition of full item */
boolean dont_start = FALSE, nodelicious = FALSE; boolean dont_start = FALSE, nodelicious = FALSE,
already_partly_eaten;
if (Strangled) { if (Strangled) {
pline("If you can't breathe air, how can you consume solids?"); pline("If you can't breathe air, how can you consume solids?");
@@ -2605,8 +2610,10 @@ doeat()
context.victual.piece = touchfood(otmp); context.victual.piece = touchfood(otmp);
if (context.victual.piece) if (context.victual.piece)
context.victual.o_id = context.victual.piece->o_id; context.victual.o_id = context.victual.piece->o_id;
You("resume your meal."); You("resume %syour meal.",
start_eating(context.victual.piece); (context.victual.usedtime + 1 >= context.victual.reqtime)
? "the last bite of " : "");
start_eating(context.victual.piece, FALSE);
return 1; return 1;
} }
@@ -2621,6 +2628,7 @@ doeat()
/* KMH, conduct */ /* KMH, conduct */
u.uconduct.food++; u.uconduct.food++;
already_partly_eaten = otmp->oeaten ? TRUE : FALSE;
context.victual.o_id = 0; context.victual.o_id = 0;
context.victual.piece = otmp = touchfood(otmp); context.victual.piece = otmp = touchfood(otmp);
if (context.victual.piece) if (context.victual.piece)
@@ -2674,8 +2682,13 @@ doeat()
dont_start = TRUE; dont_start = TRUE;
} }
consume_oeaten(otmp, 1); /* oeaten >>= 1 */ consume_oeaten(otmp, 1); /* oeaten >>= 1 */
} else } else if (!already_partly_eaten) {
fprefx(otmp); fprefx(otmp);
} else {
You("%s %s.",
(context.victual.reqtime == 1) ? "eat" : "begin eating",
doname(otmp));
}
} }
/* re-calc the nutrition */ /* re-calc the nutrition */
@@ -2707,7 +2720,7 @@ doeat()
context.victual.canchoke = (u.uhs == SATIATED); context.victual.canchoke = (u.uhs == SATIATED);
if (!dont_start) if (!dont_start)
start_eating(otmp); start_eating(otmp, already_partly_eaten);
return 1; return 1;
} }
@@ -3164,7 +3177,7 @@ int corpsecheck; /* 0, no check, 1, corpses, 2, tinnable corpses */
} }
} }
skipfloor: skipfloor:
/* We cannot use ALL_CLASSES since that causes getobj() to skip its /* We cannot use ALL_CLASSES since that causes getobj() to skip its
* "ugly checks" and we need to check for inedible items. * "ugly checks" and we need to check for inedible items.
*/ */