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

Function shop_keeper

src/shk.c:1051–1080  ·  view source on GitHub ↗

return the shopkeeper for rooms[rmno-2]; returns Null if there isn't one */

Source from the content-addressed store, hash-verified

1049
1050/* return the shopkeeper for rooms[rmno-2]; returns Null if there isn't one */
1051struct monst *
1052shop_keeper(char rmno)
1053{
1054 struct monst *shkp;
1055
1056 shkp = (rmno >= ROOMOFFSET) ? svr.rooms[rmno - ROOMOFFSET].resident : 0;
1057 if (shkp) {
1058 if (has_eshk(shkp)) {
1059 if (ANGRY(shkp)) {
1060 if (!ESHK(shkp)->surcharge)
1061 rile_shk(shkp);
1062 }
1063 } else {
1064 /* would have segfaulted on ESHK dereference previously */
1065 impossible("%s? (rmno=%d, rtype=%d, mnum=%d, \"%s\")",
1066 shkp->isshk ? "shopkeeper career change"
1067 : "shop resident not shopkeeper",
1068 (int) rmno,
1069 (int) svr.rooms[rmno - ROOMOFFSET].rtype,
1070 shkp->mnum,
1071 /* [real shopkeeper name is kept in ESHK,
1072 not MGIVENNAME] */
1073 has_mgivenname(shkp) ? MGIVENNAME(shkp) : "anonymous");
1074 /* not sure if this is appropriate, because it does nothing to
1075 correct the underlying svr.rooms[].resident issue but... */
1076 return (struct monst *) 0;
1077 }
1078 }
1079 return shkp;
1080}
1081
1082/* find the shopkeeper who owns 'obj'; needed to handle shared shop walls */
1083struct monst *

Callers 15

ready_weaponFunction · 0.85
stealarmFunction · 0.85
stealFunction · 0.85
stealamuletFunction · 0.85
maybe_absorb_itemFunction · 0.85
potionhitFunction · 0.85
itemactionsFunction · 0.85
dopushFunction · 0.85
moverock_coreFunction · 0.85
bury_objsFunction · 0.85
check_shop_objFunction · 0.85
breakobjFunction · 0.85

Calls 2

rile_shkFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected