MCPcopy Create free account
hub / github.com/NetHack/NetHack / bite

Function bite

src/eat.c:3132–3159  ·  view source on GitHub ↗

Take a single bite from a piece of food, checking for choking and * modifying usedtime. Returns 1 if they choked and survived, 0 otherwise. */

Source from the content-addressed store, hash-verified

3130 * modifying usedtime. Returns 1 if they choked and survived, 0 otherwise.
3131 */
3132staticfn int
3133bite(void)
3134{
3135 /* hack to pacify static analyzer incorporated into gcc 12.2 */
3136 sa_victual(&svc.context.victual);
3137
3138 if (svc.context.victual.canchoke && u.uhunger >= 2000) {
3139 choke(svc.context.victual.piece);
3140 return 1;
3141 }
3142 if (svc.context.victual.doreset) {
3143 do_reset_eat();
3144 return 0;
3145 }
3146 gf.force_save_hs = TRUE;
3147 if (svc.context.victual.nmod < 0) {
3148 lesshungry(adj_victual_nutrition(/*-svc.context.victual.nmod*/));
3149 consume_oeaten(svc.context.victual.piece,
3150 svc.context.victual.nmod); /* -= -nmod */
3151 } else if (svc.context.victual.nmod > 0
3152 && (svc.context.victual.usedtime % svc.context.victual.nmod)) {
3153 lesshungry(1);
3154 consume_oeaten(svc.context.victual.piece, -1); /* -= 1 */
3155 }
3156 gf.force_save_hs = FALSE;
3157 recalc_wt();
3158 return 0;
3159}
3160
3161/* as time goes by - called by moveloop(every move) & domove(melee attack) */
3162void

Callers 2

eatfoodFunction · 0.85
start_eatingFunction · 0.85

Calls 7

sa_victualFunction · 0.85
chokeFunction · 0.85
do_reset_eatFunction · 0.85
lesshungryFunction · 0.85
adj_victual_nutritionFunction · 0.85
consume_oeatenFunction · 0.85
recalc_wtFunction · 0.85

Tested by

no test coverage detected