From 0e04988fec97bd48bb13750f401c264cb88c1d6d Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 10 Jan 2025 15:46:04 +0200 Subject: [PATCH] Fix another no_charge in untended shop This time the no_charge object was being carried by a pet. To trigger, drop an object into shop, decline to sell it, pick up an object belonging to shopkeeper, decline to buy it, wait for your pet to pick up the no_charge object you dropped, teleport out of the shop, wait for shopkeeper to walk out of the shop. --- src/shk.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/shk.c b/src/shk.c index 2828d5efe..dda59b9b8 100644 --- a/src/shk.c +++ b/src/shk.c @@ -74,6 +74,7 @@ staticfn void clear_unpaid_obj(struct monst *, struct obj *); staticfn void clear_unpaid(struct monst *, struct obj *); staticfn void clear_no_charge_obj(struct monst *, struct obj *); staticfn void clear_no_charge(struct monst *, struct obj *); +staticfn void clear_no_charge_pets(struct monst *); staticfn long check_credit(long, struct monst *); staticfn void pay(long, struct monst *); staticfn long get_cost(struct obj *, struct monst *); @@ -383,6 +384,17 @@ clear_no_charge(struct monst *shkp, struct obj *list) } } +/* clear no_charge from objects in pets' inventories belonging to shkp */ +staticfn void +clear_no_charge_pets(struct monst *shkp) +{ + struct monst *mtmp; + + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) + if (mtmp->mtame && mtmp->minvent) + clear_no_charge(shkp, mtmp->minvent); +} + /* either you paid or left the shop or the shopkeeper died */ void setpaid(struct monst *shkp) @@ -1383,6 +1395,7 @@ hot_pursuit(struct monst *shkp) floor of this level (including inside containers on floor), even those that are in other shopkeepers' shops */ clear_no_charge((struct monst *) NULL, fobj); + clear_no_charge_pets(shkp); } /* Used when the shkp is teleported or falls (ox == 0) out of his shop, or