tweak PR #925 - don't expose shop bill details

Avoid use of 'struct bill_x' outside of shk.c.
This commit is contained in:
PatR
2022-11-19 00:38:20 -08:00
parent fa0b2b7e94
commit 546930e05e
3 changed files with 18 additions and 5 deletions
+1 -1
View File
@@ -2481,7 +2481,7 @@ extern void shopper_financial_report(void);
extern int inhishop(struct monst *); extern int inhishop(struct monst *);
extern struct monst *shop_keeper(char); extern struct monst *shop_keeper(char);
extern boolean tended_shop(struct mkroom *); 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 boolean is_unpaid(struct obj *);
extern void delete_contents(struct obj *); extern void delete_contents(struct obj *);
extern void obfree(struct obj *, struct obj *); extern void obfree(struct obj *, struct obj *);
+3 -2
View File
@@ -452,8 +452,9 @@ moverock(void)
if (costly && !costly_spot(rx, ry)) { if (costly && !costly_spot(rx, ry)) {
addtobill(otmp, FALSE, FALSE, FALSE); addtobill(otmp, FALSE, FALSE, FALSE);
} else if (!costly && costly_spot(rx, ry) && otmp->unpaid } else if (!costly && costly_spot(rx, ry) && otmp->unpaid
&& (shkp = shop_keeper(*in_rooms(rx, ry, SHOPBASE))) && ((shkp = shop_keeper(*in_rooms(rx, ry, SHOPBASE)))
&& onbill(otmp, shkp, TRUE)) { != 0)
&& onshopbill(otmp, shkp, TRUE)) {
subfrombill(otmp, shkp); subfrombill(otmp, shkp);
} }
} else { } else {
+14 -2
View File
@@ -29,6 +29,7 @@ static const char the_contents_of[] = "the contents of ";
static void append_honorific(char *); static void append_honorific(char *);
static long addupbill(struct monst *); static long addupbill(struct monst *);
static void pacify_shk(struct monst *, boolean); 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 struct monst *next_shkp(struct monst *, boolean);
static long shop_debt(struct eshk *); static long shop_debt(struct eshk *);
static char *shk_owns(char *, struct obj *); static char *shk_owns(char *, struct obj *);
@@ -82,7 +83,9 @@ static const char *cad(boolean);
obj->quan <= bp->bquan 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 * Transfer money from inventory to monster when paying
@@ -879,14 +882,23 @@ onbill(struct obj *obj, struct monst *shkp, boolean silent)
if (!obj->unpaid) if (!obj->unpaid)
pline("onbill: paid obj on bill?"); pline("onbill: paid obj on bill?");
return bp; return bp;
} else } else {
bp++; bp++;
}
} }
if (obj->unpaid && !silent) if (obj->unpaid && !silent)
pline("onbill: unpaid obj not on bill?"); pline("onbill: unpaid obj not on bill?");
return (struct bill_x *) 0; 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 */ /* check whether an object or any of its contents belongs to a shop */
boolean boolean
is_unpaid(struct obj* obj) is_unpaid(struct obj* obj)