-/* NetHack 3.7 eat.c $NHDT-Date: 1654886097 2022/06/10 18:34:57 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.281 $ */
+/* NetHack 3.7 eat.c $NHDT-Date: 1674294705 2023/01/21 09:51:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.301 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
static const char *food_xname(struct obj *, boolean);
static void choke(struct obj *);
static void recalc_wt(void);
-static struct obj *touchfood(struct obj *);
+static struct obj *touchfood(struct obj *) NONNULL;
static void do_reset_eat(void);
static void maybe_extend_timed_resist(int);
static void done_eating(boolean);
*/
if (gc.context.victual.eating && !gc.context.victual.doreset) {
debugpline0("reset_eat...");
- gc.context.victual.doreset = TRUE;
+ gc.context.victual.doreset = 1;
}
return;
}
if (gc.context.victual.piece) {
gc.context.victual.o_id = 0;
gc.context.victual.piece = touchfood(gc.context.victual.piece);
- if (gc.context.victual.piece)
- gc.context.victual.o_id = gc.context.victual.piece->o_id;
+ gc.context.victual.o_id = gc.context.victual.piece->o_id;
recalc_wt();
}
gc.context.victual.fullwarn
= gc.context.victual.eating
= gc.context.victual.doreset
- = FALSE;
+ = 0;
/* Do not set canchoke to FALSE; if we continue eating the same object
* we need to know if canchoke was set when they started eating it the
* previous time. And if we don't continue eating the same object
{
struct obj *food = gc.context.victual.piece;
- if (!food || !(carried(food) || obj_here(food, u.ux, u.uy))) {
+ if (food && !carried(food) && !obj_here(food, u.ux, u.uy))
+ food = 0;
+ if (!food) {
/* maybe it was stolen? */
do_reset_eat();
return 0;
if (message)
pline1(gn.nomovemsg);
gn.nomovemsg = 0;
- } else if (message)
+ } else if (message) {
You("finish %s %s.",
- (gy.youmonst.data == &mons[PM_FIRE_ELEMENTAL])
- ? "consuming" : "eating",
+ (gy.youmonst.data == &mons[PM_FIRE_ELEMENTAL]) ? "consuming"
+ : "eating",
food_xname(piece, TRUE));
+ }
if (piece->otyp == CORPSE || piece->globby)
cpostfx(piece->corpsenm);
/* handle side-effects of mind flayer's tentacle attack */
int
-eat_brains(struct monst *magr, struct monst *mdef,
- boolean visflag,
- int *dmg_p) /* for dishing out extra damage in lieu of Int loss */
+eat_brains(
+ struct monst *magr,
+ struct monst *mdef,
+ boolean visflag,
+ int *dmg_p) /* for dishing out extra damage in lieu of Int loss */
{
struct permonst *pd = mdef->data;
boolean give_nutrit = FALSE;
You("turn to stone.");
done(STONING);
if (gc.context.victual.piece)
- gc.context.victual.eating = FALSE;
+ gc.context.victual.eating = 0;
return; /* lifesaved */
}
}
debugpline1("(original reqtime = %d)", objects[otmp->otyp].oc_delay);
debugpline1("nmod = %d", gc.context.victual.nmod);
debugpline1("oeaten = %d", otmp->oeaten);
- gc.context.victual.fullwarn = gc.context.victual.doreset = FALSE;
- gc.context.victual.eating = TRUE;
+ gc.context.victual.fullwarn = gc.context.victual.doreset = 0;
+ gc.context.victual.eating = 1;
if (otmp->otyp == CORPSE || otmp->globby) {
cprefx(gc.context.victual.piece->corpsenm);
if (!gc.context.victual.piece || !gc.context.victual.eating) {
- /* rider revived, or died and lifesaved */
+ /* rider revived, or hero died and was lifesaved */
return;
}
}
}
#endif
gc.context.victual.nmod = basenutrit;
- gc.context.victual.eating = TRUE; /* needed for lesshungry() */
+ gc.context.victual.eating = 1; /* needed for lesshungry() */
if (!u.uconduct.food++) {
ll_conduct++;
* they shouldn't be able to choke now.
*/
if (u.uhs != SATIATED)
- gc.context.victual.canchoke = FALSE;
+ gc.context.victual.canchoke = 0;
gc.context.victual.o_id = 0;
gc.context.victual.piece = touchfood(otmp);
- if (gc.context.victual.piece)
- gc.context.victual.o_id = gc.context.victual.piece->o_id;
+ gc.context.victual.o_id = gc.context.victual.piece->o_id;
/* if there's only one bite left, there sometimes won't be any
"you finish eating" message when done; use different wording
for resuming with one bite remaining instead of trying to
already_partly_eaten = otmp->oeaten ? TRUE : FALSE;
gc.context.victual.piece = otmp = touchfood(otmp);
- if (gc.context.victual.piece)
- gc.context.victual.o_id = gc.context.victual.piece->o_id;
+ gc.context.victual.o_id = gc.context.victual.piece->o_id;
gc.context.victual.usedtime = 0;
/* Now we need to calculate delay and nutritional info.
choke(gc.context.victual.piece);
reset_eat();
} else
- choke(go.occupation == opentin ? gc.context.tin.tin
- : (struct obj *) 0);
+ choke((go.occupation == opentin) ? gc.context.tin.tin : 0);
/* no reset_eat() */
}
} else {
if (!gc.context.victual.eating) {
gm.multi = -2;
} else {
- gc.context.victual.fullwarn = TRUE;
+ gc.context.victual.fullwarn = 1;
if (gc.context.victual.canchoke
&& (gc.context.victual.reqtime
- gc.context.victual.usedtime) > 1) {
be fatal (still handled below) by reducing HP if it
tried to take base strength below minimum of 3 */
ATEMP(A_STR) = -1; /* temporary loss overrides Fixed_abil */
- /* defer gc.context.botl status update until after hunger message */
+ /* defer context.botl status update until after hunger message */
} else if (newhs < WEAK && u.uhs >= WEAK) {
/* this used to be losestr(-1) which could be abused by
becoming weak while wearing ring of sustain ability,
substituting "while polymorphed" for sustain ability and
"rehumanize" for ring removal might have done that too */
ATEMP(A_STR) = 0; /* repair of loss also overrides Fixed_abil */
- /* defer gc.context.botl status update until after hunger message */
+ /* defer context.botl status update until after hunger message */
}
switch (newhs) {