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

Function touchfood

src/eat.c:359–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

357
358/* might destroy otmp if hero drops it */
359staticfn struct obj *
360touchfood(struct obj *otmp)
361{
362 if (otmp->quan > 1L) {
363 if (!carried(otmp))
364 (void) splitobj(otmp, otmp->quan - 1L);
365 else
366 otmp = splitobj(otmp, 1L);
367 debugpline0("split food,");
368 }
369
370 if (!otmp->oeaten) {
371 costly_alteration(otmp, COST_BITE);
372 otmp->oeaten = obj_nutrition(otmp);
373 }
374
375 if (carried(otmp)) {
376 freeinv(otmp);
377 if (inv_cnt(FALSE) >= invlet_basic) {
378 sellobj_state(SELL_DONTSELL);
379 dropy(otmp);
380 sellobj_state(SELL_NORMAL);
381 if (otmp->where == OBJ_DELETED)
382 otmp = (struct obj *) NULL;
383 } else {
384 otmp = addinv_nomerge(otmp);
385 }
386 }
387 return otmp;
388}
389
390/* When food decays, in the middle of your meal, we don't want to dereference
391 * any dangling pointers, so set it to null (which should still trigger

Callers 3

do_reset_eatFunction · 0.85
eatcorpseFunction · 0.85
doeatFunction · 0.85

Calls 8

splitobjFunction · 0.85
costly_alterationFunction · 0.85
obj_nutritionFunction · 0.85
freeinvFunction · 0.85
inv_cntFunction · 0.85
sellobj_stateFunction · 0.85
dropyFunction · 0.85
addinv_nomergeFunction · 0.85

Tested by

no test coverage detected