return the shopkeeper for rooms[rmno-2]; returns Null if there isn't one */
| 1049 | |
| 1050 | /* return the shopkeeper for rooms[rmno-2]; returns Null if there isn't one */ |
| 1051 | struct monst * |
| 1052 | shop_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 */ |
| 1083 | struct monst * |
no test coverage detected