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

Function eat_ok

src/eat.c:3516–3534  ·  view source on GitHub ↗

getobj callback for object to eat - effectively just wraps is_edible() */

Source from the content-addressed store, hash-verified

3514
3515/* getobj callback for object to eat - effectively just wraps is_edible() */
3516staticfn int
3517eat_ok(struct obj *obj)
3518{
3519 /* 'getobj_else' will be non-zero if floor food is present and
3520 player declined to eat that; used to insert "else" into
3521 "you don't have anything [else] to eat" if not carrying any food */
3522 if (!obj)
3523 return getobj_else ? GETOBJ_EXCLUDE_NONINVENT : GETOBJ_EXCLUDE;
3524
3525 if (is_edible(obj))
3526 return GETOBJ_SUGGEST;
3527
3528 /* make sure to exclude, not downplay, gold (if not is_edible) in order to
3529 * produce the "You cannot eat gold" message in getobj */
3530 if (obj->oclass == COIN_CLASS)
3531 return GETOBJ_EXCLUDE;
3532
3533 return GETOBJ_EXCLUDE_SELECTABLE;
3534}
3535
3536/* getobj callback for object to be offered (corpses and things that look like
3537 * the Amulet only */

Callers

nothing calls this directly

Calls 1

is_edibleFunction · 0.85

Tested by

no test coverage detected