| 1178 | } |
| 1179 | |
| 1180 | staticfn void |
| 1181 | check_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. |
no test coverage detected