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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
21
src/shk.c
21
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*/
|
||||
|
||||
Reference in New Issue
Block a user