From 0fe42a67d0d47e24aabff6c93aa5e0ec38517e22 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 10 Jan 2025 20:52:25 -0800 Subject: [PATCH] eshkp->bill_p vs eshkp->bill Use ESHK(shkp)->bill_p consistently. The bill[] array field is used to initialize the bill_p pointer field rather than be used directly when manipulating shop bills. While in there, get rid of some '#if DUMB' from pre-standard C days. --- src/shk.c | 43 ++++++++++--------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/src/shk.c b/src/shk.c index dda59b9b8..8a521cb26 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1173,19 +1173,12 @@ obfree(struct obj *obj, struct obj *merge) merge->unpaid ? 1 : 0); return; } else { + struct eshk *eshkp = ESHK(shkp); + /* this was a merger */ bpm->bquan += bp->bquan; - ESHK(shkp)->billct--; -#ifdef DUMB - { - /* DRS/NS 2.2.6 messes up -- Peter Kendell */ - int indx = ESHK(shkp)->billct; - - *bp = ESHK(shkp)->bill_p[indx]; - } -#else - *bp = ESHK(shkp)->bill_p[ESHK(shkp)->billct]; -#endif + eshkp->billct--; + *bp = eshkp->bill_p[eshkp->billct]; } } else { /* not on bill; if the item is being merged away rather than @@ -2139,7 +2132,7 @@ update_bill( *bp = eshkp->bill_p[newebillct]; for (j = 0; j < ibillct; ++j) if (ibill[j].bidx == newebillct) - ibill[j].bidx = (int) (bp - eshkp->bill); + ibill[j].bidx = (int) (bp - eshkp->bill_p); eshkp->billct = newebillct; /* eshkp->billct - 1 */ } return; @@ -3153,7 +3146,7 @@ gem_learned(int oindx) for (shkp = next_shkp(fmon, TRUE); shkp; shkp = next_shkp(shkp->nmon, TRUE)) { ct = ESHK(shkp)->billct; - bp = ESHK(shkp)->bill; + bp = ESHK(shkp)->bill_p; while (--ct >= 0) { obj = find_oid(bp->bo_id); if (!obj) /* shouldn't happen */ @@ -3593,6 +3586,7 @@ staticfn void sub_one_frombill(struct obj *obj, struct monst *shkp) { struct bill_x *bp; + struct eshk *eshkp; if ((bp = onbill(obj, shkp, FALSE)) != 0) { struct obj *otmp; @@ -3610,17 +3604,9 @@ sub_one_frombill(struct obj *obj, struct monst *shkp) add_to_billobjs(otmp); return; } - ESHK(shkp)->billct--; -#ifdef DUMB - { - /* DRS/NS 2.2.6 messes up -- Peter Kendell */ - int indx = ESHK(shkp)->billct; - - *bp = ESHK(shkp)->bill_p[indx]; - } -#else - *bp = ESHK(shkp)->bill_p[ESHK(shkp)->billct]; -#endif + eshkp = ESHK(shkp); + eshkp->billct--; + *bp = eshkp->bill_p[eshkp->billct]; return; } else if (obj->unpaid) { impossible("sub_one_frombill: unpaid object not on bill"); @@ -5954,16 +5940,7 @@ globby_bill_fixup(struct obj *obj_absorber, struct obj *obj_absorbed) /* the glob being absorbed has a billing record */ amount = bp->price; eshkp->billct--; -#ifdef DUMB - { - /* DRS/NS 2.2.6 messes up -- Peter Kendell */ - int indx = eshkp->billct; - - *bp = eshkp->bill_p[indx]; - } -#else *bp = eshkp->bill_p[eshkp->billct]; -#endif clear_unpaid_obj(shkp, obj_absorbed); if (bp_absorber) {