MCPcopy Index your code
hub / github.com/NetHack/NetHack / check_shop_obj

Function check_shop_obj

src/dothrow.c:1180–1214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1178}
1179
1180staticfn void
1181check_shop_obj(struct obj *obj, coordxy x, coordxy y, boolean broken)
1182{
1183 boolean costly_xy;
1184 struct monst *shkp = shop_keeper(*u.ushops);
1185
1186 if (!shkp)
1187 return;
1188
1189 costly_xy = costly_spot(x, y);
1190 if (broken || !costly_xy || *in_rooms(x, y, SHOPBASE) != *u.ushops) {
1191 /* thrown out of a shop or into a different shop */
1192 if (is_unpaid(obj))
1193 (void) stolen_value(obj, u.ux, u.uy, (boolean) shkp->mpeaceful,
1194 FALSE);
1195 if (broken)
1196 obj->no_charge = 1;
1197 } else if (costly_xy) {
1198 char *oshops = in_rooms(x, y, SHOPBASE);
1199
1200 /* ushops0: in case we threw while levitating and recoiled
1201 out of shop (most likely to the shk's spot in front of door) */
1202 if (*oshops == *u.ushops || *oshops == *u.ushops0) {
1203 if (is_unpaid(obj)) {
1204 long gtg = Has_contents(obj) ? contained_gold(obj, TRUE) : 0L;
1205
1206 subfrombill(obj, shkp);
1207 if (gtg > 0L)
1208 donate_gold(gtg, shkp, TRUE);
1209 } else if (x != shkp->mx || y != shkp->my) {
1210 sellobj(obj, x, y);
1211 }
1212 }
1213 }
1214}
1215
1216/* Will 'obj' cause damage if it falls on hero's head when thrown upward?
1217 Not used to handle things which break when they hit.

Callers 4

throwitFunction · 0.85
thitmonstFunction · 0.85
gem_acceptFunction · 0.85
breakobjFunction · 0.85

Calls 9

shop_keeperFunction · 0.85
costly_spotFunction · 0.85
in_roomsFunction · 0.85
is_unpaidFunction · 0.85
stolen_valueFunction · 0.85
contained_goldFunction · 0.85
subfrombillFunction · 0.85
donate_goldFunction · 0.85
sellobjFunction · 0.85

Tested by

no test coverage detected