From 86f961ba3f53eb5112b5a6cef29b71e4c2254741 Mon Sep 17 00:00:00 2001 From: cohrs Date: Mon, 15 Apr 2002 06:43:55 +0000 Subject: [PATCH] crash fix: shopkeeper re-entering shop - when a shopkeeper leaves the shop to chase the player, and the player enters the shop, bill_p is set to an unusual value. bill_p needs to be set back to a valid value if the shopkeeper re-enters the shop. - Also, the u.ushops state needs to be updated when a shop becomes tended again if the player is in the shop. - introduce a new after_shk_move function to handle this --- doc/fixes34.1 | 1 + include/extern.h | 1 + src/monmove.c | 3 +++ src/shk.c | 21 +++++++++++++++++++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/fixes34.1 b/doc/fixes34.1 index 06a34c651..8b441b42c 100644 --- a/doc/fixes34.1 +++ b/doc/fixes34.1 @@ -72,6 +72,7 @@ travel command should restrict its shortest paths to areas of the map the non-altar prayer should limit god action, not maximize it potions of acid explode, not dilute, so make water_damage behave this way lookat monster notes if you see monster is trapped +don't crash when angry shopkeeper re-enters the shop and you pick up something Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index cb8ce0803..ba1fc3720 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1761,6 +1761,7 @@ E struct monst *FDECL(shkcatch, (struct obj *,XCHAR_P,XCHAR_P)); E void FDECL(add_damage, (XCHAR_P,XCHAR_P,long)); E int FDECL(repair_damage, (struct monst *,struct damage *,BOOLEAN_P)); E int FDECL(shk_move, (struct monst *)); +E void FDECL(after_shk_move, (struct monst *)); E boolean FDECL(is_fshk, (struct monst *)); E void FDECL(shopdig, (int)); E void FDECL(pay_for_damage, (const char *)); diff --git a/src/monmove.c b/src/monmove.c index 3424b7304..ca61e287e 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -1194,6 +1194,9 @@ postmov: (is_pool(mtmp->mx, mtmp->my) && !Is_waterlevel(&u.uz)); newsym(mtmp->mx, mtmp->my); } + if (mtmp->isshk) { + after_shk_move(mtmp); + } } return(mmoved); } diff --git a/src/shk.c b/src/shk.c index e7c5f17e1..e9076de07 100644 --- a/src/shk.c +++ b/src/shk.c @@ -891,6 +891,7 @@ register boolean killkops; #endif pacify_guards(); } + after_shk_move(shkp); } STATIC_OVL boolean @@ -3257,8 +3258,24 @@ register struct monst *shkp; } } - return(move_special(shkp,inhishop(shkp), - appr,uondoor,avoid,omx,omy,gx,gy)); + z = move_special(shkp,inhishop(shkp),appr,uondoor,avoid,omx,omy,gx,gy); + if (z > 0) after_shk_move(shkp); + + return z; +} + +/* called after shopkeeper moves, in case the move causes re-entry into shop */ +void +after_shk_move(shkp) +struct monst *shkp; +{ + struct eshk *eshkp = ESHK(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); + } } #endif /*OVL3*/