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.
This commit is contained in:
Pasi Kallinen
2025-01-10 15:46:04 +02:00
parent 1928a3e12b
commit 0e04988fec

View File

@@ -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