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

Function find_objowner

src/shk.c:1083–1115  ·  view source on GitHub ↗

find the shopkeeper who owns 'obj'; needed to handle shared shop walls */

Source from the content-addressed store, hash-verified

1081
1082/* find the shopkeeper who owns 'obj'; needed to handle shared shop walls */
1083struct monst *
1084find_objowner(
1085 struct obj *obj,
1086 coordxy x, coordxy y) /* caller passes obj's location since obj->ox,oy
1087 * might be stale; don't update coordinates here
1088 * because if we're called during sanity checking
1089 * they shouldn't be modified */
1090{
1091 struct monst *shkp, *deflt_shkp = 0;
1092
1093 if (obj->where == OBJ_ONBILL) {
1094 /* used up item; bill obj coordinates are useless and so are x,y */
1095 for (shkp = next_shkp(fmon, TRUE); shkp;
1096 shkp = next_shkp(shkp->nmon, TRUE))
1097 if (onshopbill(obj, shkp, TRUE))
1098 return shkp;
1099 } else {
1100 char *roomindx, *where = in_rooms(x, y, SHOPBASE);
1101
1102 /* conceptually object could be inside up to 4 rooms simultaneously;
1103 in practice it will usually be one room but can sometimes be two;
1104 check shk and bill for each room rather than just the first;
1105 fallback to the first shk if obj isn't on the relevant bill(s) */
1106 for (roomindx = where; *roomindx; ++roomindx)
1107 if ((shkp = shop_keeper(*roomindx)) != 0) {
1108 if (onshopbill(obj, shkp, TRUE))
1109 return shkp;
1110 if (!deflt_shkp)
1111 deflt_shkp = shkp;
1112 }
1113 }
1114 return deflt_shkp;
1115}
1116
1117boolean
1118tended_shop(struct mkroom *sroom)

Callers 10

mpickobjFunction · 0.85
rloc_to_coreFunction · 0.85
rlocoFunction · 0.85
dopushFunction · 0.85
place_objectFunction · 0.85
shop_obj_sanityFunction · 0.85
really_kick_objectFunction · 0.85
stolen_valueFunction · 0.85
litter_scatterFunction · 0.85
use_unpaid_trapobjFunction · 0.85

Calls 4

next_shkpFunction · 0.85
onshopbillFunction · 0.85
in_roomsFunction · 0.85
shop_keeperFunction · 0.85

Tested by

no test coverage detected