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

Function check_invent_gold

src/invent.c:4888–4913  ·  view source on GitHub ↗

invent gold sanity check; used by doorganize() to control how getobj() deals with gold and also by wizard mode sanity_check() */

Source from the content-addressed store, hash-verified

4886/* invent gold sanity check; used by doorganize() to control how getobj()
4887 deals with gold and also by wizard mode sanity_check() */
4888boolean
4889check_invent_gold(const char *why) /* 'why' == caller in case of warning */
4890{
4891 struct obj *otmp;
4892 int goldstacks = 0, wrongslot = 0;
4893
4894 /* there should be at most one stack of gold in invent, in slot '$' */
4895 for (otmp = gi.invent; otmp; otmp = otmp->nobj)
4896 if (otmp->oclass == COIN_CLASS) {
4897 ++goldstacks;
4898 if (otmp->invlet != GOLD_SYM)
4899 ++wrongslot;
4900 }
4901
4902 if (goldstacks > 1 || wrongslot > 0) {
4903 impossible("%s: %s%s%s", why,
4904 (wrongslot > 1) ? "gold in wrong slots"
4905 : (wrongslot > 0) ? "gold in wrong slot"
4906 : "",
4907 (wrongslot > 0 && goldstacks > 1) ? " and " : "",
4908 (goldstacks > 1) ? "multiple gold stacks" : "");
4909 return TRUE; /* gold can be #adjusted */
4910 }
4911
4912 return FALSE; /* gold can't be #adjusted */
4913}
4914
4915/* normal getobj callback for item to #adjust; excludes gold */
4916staticfn int

Callers 3

itemactionsFunction · 0.85
doorganizeFunction · 0.85
you_sanity_checkFunction · 0.85

Calls 1

impossibleFunction · 0.70

Tested by

no test coverage detected