!n ? "deserted" : "untended");
}
+/* called from check_special_room(hack.c) */
void
-u_entered_shop(char* enterstring)
+u_entered_shop(char *enterstring)
{
- register int rt;
- register struct monst *shkp;
- register struct eshk *eshkp;
static char empty_shops[5];
+ struct monst *shkp;
+ struct eshk *eshkp;
+ int rt;
if (!*enterstring)
return;
shkp = shop_keeper(*enterstring);
if (!shkp) {
if (!strchr(empty_shops, *enterstring)
- && in_rooms(u.ux, u.uy, SHOPBASE)
- != in_rooms(u.ux0, u.uy0, SHOPBASE))
+ && (in_rooms(u.ux, u.uy, SHOPBASE)
+ != in_rooms(u.ux0, u.uy0, SHOPBASE)))
deserted_shop(enterstring);
Strcpy(empty_shops, u.ushops);
u.ushops[0] = '\0';
}
}
+/* 1: shopkeeper is currently in her shop or its boundary; 0: not */
int
-inhishop(register struct monst* mtmp)
+inhishop(struct monst *shkp)
{
- struct eshk *eshkp = ESHK(mtmp);
+ char *shkrooms;
+ struct eshk *eshkp = ESHK(shkp);
- return (strchr(in_rooms(mtmp->mx, mtmp->my, SHOPBASE), eshkp->shoproom)
- && on_level(&eshkp->shoplevel, &u.uz));
+ if (!on_level(&eshkp->shoplevel, &u.uz))
+ return FALSE;
+ shkrooms = in_rooms(shkp->mx, shkp->my, SHOPBASE);
+ return (strchr(shkrooms, eshkp->shoproom) != 0);
}
+/* return the shopkeeper for rooms[rmno-2]; returns Null if there isn't one */
struct monst *
shop_keeper(char rmno)
{
return z;
}
-/* called after shopkeeper moves, in case themove causes re-entry into shop */
+/* called after shopkeeper moves, in case move causes re-entry into shop */
void
after_shk_move(struct monst *shkp)
{
if (eshkp->bill_p == (struct bill_x *) -1000 && inhishop(shkp)) {
/* reset bill_p, need to re-calc player's occupancy too */
eshkp->bill_p = &eshkp->bill[0];
- check_special_room(FALSE);
+ /* only re-check occupancy if game hasn't just ended */
+ if (!gp.program_state.gameover)
+ check_special_room(FALSE);
}
}
/* You are digging in the shop. */
void
-shopdig(register int fall)
+shopdig(int fall)
{
struct monst *shkp = shop_keeper(*u.ushops);
int lang;