more shop damage repair

Stop attempting to catch up for lost time for shop damage repair
when getlev() loads a previousl visited level.  Normal shopkeeper
behavior will take care of that.

Also, fixes the display related aspects of shop damage repair
interacting with ball and chain.  They don't happen when its done
while the map is being shown.
This commit is contained in:
PatR
2022-04-09 15:55:21 -07:00
parent dadbea1d8c
commit 593c3532fc
7 changed files with 45 additions and 48 deletions

View File

@@ -156,7 +156,7 @@ money2u(struct monst* mon, long amount)
}
static struct monst *
next_shkp(register struct monst* shkp, register boolean withbill)
next_shkp(register struct monst *shkp, boolean withbill)
{
for (; shkp; shkp = shkp->nmon) {
if (DEADMONSTER(shkp))
@@ -1983,9 +1983,11 @@ find_oid(unsigned int id)
/* Returns the price of an arbitrary item in the shop,
0 if the item doesn't belong to a shopkeeper or hero is not in the shop. */
long
get_cost_of_shop_item(register struct obj* obj, int* nochrg)
/* alternate return value: 1: no charge, 0: shop owned, */
{ /* -1: not in a shop (so should't be formatted as "no charge") */
get_cost_of_shop_item(
struct obj *obj,
int *nochrg) /* alternate return value: 1: no charge, 0: shop owned,
* -1: not in a shop (so don't format as "no charge") */
{
struct monst *shkp;
struct obj *top;
xchar x, y;
@@ -3632,7 +3634,7 @@ discard_damage_owned_by(struct monst *shkp)
/* Shopkeeper tries to repair damage belonging to them */
static void
shk_fixes_damage(struct monst* shkp)
shk_fixes_damage(struct monst *shkp)
{
struct damage *dam = find_damage(shkp);
boolean shk_closeby;
@@ -3649,7 +3651,7 @@ shk_fixes_damage(struct monst* shkp)
else if (!Deaf && shk_closeby)
You_hear("someone muttering an incantation.");
(void) repair_damage(shkp, dam, FALSE);
(void) repair_damage(shkp, dam);
discard_damage_struct(dam);
}
@@ -3769,19 +3771,19 @@ litter_newsyms(xchar *litter, xchar x, xchar y)
int
repair_damage(
struct monst *shkp,
struct damage *tmp_dam,
boolean catchup) /* restoring a level */
struct damage *tmp_dam)
{
xchar x, y;
xchar *litter;
struct obj *otmp;
struct trap *ttmp;
int k, disposition = 1;
boolean stop_picking = FALSE;
boolean catchup, stop_picking = FALSE;
if (!repairable_damage(tmp_dam, shkp))
return 0;
catchup = g.moves > tmp_dam->when + REPAIR_DELAY;
x = tmp_dam->place.x;
y = tmp_dam->place.y;
@@ -3873,11 +3875,25 @@ repair_damage(
return disposition;
}
/* normally repair is done when a shopkeeper moves, but we also try to
catch up for lost time when reloading a previously visited level */
void
fix_shop_damage(void)
{
struct monst *shkp;
for (shkp = next_shkp(fmon, FALSE); shkp;
shkp = next_shkp(shkp->nmon, FALSE)) {
if (shkp->mcanmove && inhishop(shkp))
shk_fixes_damage(shkp);
}
}
/*
* shk_move: return 1: moved 0: didn't -1: let m_move do it -2: died
*/
int
shk_move(struct monst* shkp)
shk_move(struct monst *shkp)
{
xchar gx, gy, omx, omy;
int udist;