diff --git a/include/extern.h b/include/extern.h index d3ef197b9..7814f7572 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2481,7 +2481,7 @@ extern void shopper_financial_report(void); extern int inhishop(struct monst *); extern struct monst *shop_keeper(char); extern boolean tended_shop(struct mkroom *); -struct bill_x *onbill(struct obj *, struct monst *, boolean); +extern boolean onshopbill(struct obj *, struct monst *, boolean); extern boolean is_unpaid(struct obj *); extern void delete_contents(struct obj *); extern void obfree(struct obj *, struct obj *); diff --git a/src/hack.c b/src/hack.c index 2a6acc237..f5c690123 100644 --- a/src/hack.c +++ b/src/hack.c @@ -452,8 +452,9 @@ moverock(void) if (costly && !costly_spot(rx, ry)) { addtobill(otmp, FALSE, FALSE, FALSE); } else if (!costly && costly_spot(rx, ry) && otmp->unpaid - && (shkp = shop_keeper(*in_rooms(rx, ry, SHOPBASE))) - && onbill(otmp, shkp, TRUE)) { + && ((shkp = shop_keeper(*in_rooms(rx, ry, SHOPBASE))) + != 0) + && onshopbill(otmp, shkp, TRUE)) { subfrombill(otmp, shkp); } } else { diff --git a/src/shk.c b/src/shk.c index 866e2aebc..b9c58c54d 100644 --- a/src/shk.c +++ b/src/shk.c @@ -29,6 +29,7 @@ static const char the_contents_of[] = "the contents of "; static void append_honorific(char *); static long addupbill(struct monst *); static void pacify_shk(struct monst *, boolean); +static struct bill_x *onbill(struct obj *, struct monst *, boolean); static struct monst *next_shkp(struct monst *, boolean); static long shop_debt(struct eshk *); static char *shk_owns(char *, struct obj *); @@ -82,7 +83,9 @@ static const char *cad(boolean); obj->quan <= bp->bquan */ -static const char *const angrytexts[] = { "quite upset", "ticked off", "furious" }; +static const char *const angrytexts[] = { + "quite upset", "ticked off", "furious" +}; /* * Transfer money from inventory to monster when paying @@ -879,14 +882,23 @@ onbill(struct obj *obj, struct monst *shkp, boolean silent) if (!obj->unpaid) pline("onbill: paid obj on bill?"); return bp; - } else + } else { bp++; + } } if (obj->unpaid && !silent) pline("onbill: unpaid obj not on bill?"); return (struct bill_x *) 0; } +/* used outside of shk.c when caller wants to know whether item is on bill + but doesn't need to know any details about the bill itself */ +boolean +onshopbill(struct obj *obj, struct monst *shkp, boolean silent) +{ + return onbill(obj, shkp, silent) ? TRUE : FALSE; +} + /* check whether an object or any of its contents belongs to a shop */ boolean is_unpaid(struct obj* obj)