find the shopkeeper who owns 'obj'; needed to handle shared shop walls */
| 1081 | |
| 1082 | /* find the shopkeeper who owns 'obj'; needed to handle shared shop walls */ |
| 1083 | struct monst * |
| 1084 | find_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 | |
| 1117 | boolean |
| 1118 | tended_shop(struct mkroom *sroom) |
no test coverage detected