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

Function drink_ok

src/potion.c:504–521  ·  view source on GitHub ↗

getobj callback for object to drink from, which also does double duty as the callback for dipping into (both just allow potions). */

Source from the content-addressed store, hash-verified

502/* getobj callback for object to drink from, which also does double duty as
503 the callback for dipping into (both just allow potions). */
504staticfn int
505drink_ok(struct obj *obj)
506{
507 /* getobj()'s callback to test whether hands/self is a valid "item" to
508 pick is used here to communicate the fact that player has already
509 passed up an opportunity to perform the action (drink or dip) on a
510 non-inventory dungeon feature, so if there are no potions in invent
511 the message will be "you have nothing /else/ to {drink | dip into}";
512 if player used 'm' prefix to bypass dungeon features, drink_ok_extra
513 will be 0 and the potential "else" will be omitted */
514 if (!obj)
515 return drink_ok_extra ? GETOBJ_EXCLUDE_NONINVENT : GETOBJ_EXCLUDE;
516
517 if (obj->oclass == POTION_CLASS)
518 return GETOBJ_SUGGEST;
519
520 return GETOBJ_EXCLUDE;
521}
522
523/* "Quaffing is like drinking, except you spill more." - Terry Pratchett */
524/* the #quaff command */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected