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.
This commit is contained in:
PatR
2025-01-10 20:52:25 -08:00
parent 539f039a83
commit 0fe42a67d0

View File

@@ -1173,19 +1173,12 @@ obfree(struct obj *obj, struct obj *merge)
merge->unpaid ? 1 : 0); merge->unpaid ? 1 : 0);
return; return;
} else { } else {
struct eshk *eshkp = ESHK(shkp);
/* this was a merger */ /* this was a merger */
bpm->bquan += bp->bquan; bpm->bquan += bp->bquan;
ESHK(shkp)->billct--; eshkp->billct--;
#ifdef DUMB *bp = eshkp->bill_p[eshkp->billct];
{
/* 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
} }
} else { } else {
/* not on bill; if the item is being merged away rather than /* not on bill; if the item is being merged away rather than
@@ -2139,7 +2132,7 @@ update_bill(
*bp = eshkp->bill_p[newebillct]; *bp = eshkp->bill_p[newebillct];
for (j = 0; j < ibillct; ++j) for (j = 0; j < ibillct; ++j)
if (ibill[j].bidx == newebillct) 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 */ eshkp->billct = newebillct; /* eshkp->billct - 1 */
} }
return; return;
@@ -3153,7 +3146,7 @@ gem_learned(int oindx)
for (shkp = next_shkp(fmon, TRUE); shkp; for (shkp = next_shkp(fmon, TRUE); shkp;
shkp = next_shkp(shkp->nmon, TRUE)) { shkp = next_shkp(shkp->nmon, TRUE)) {
ct = ESHK(shkp)->billct; ct = ESHK(shkp)->billct;
bp = ESHK(shkp)->bill; bp = ESHK(shkp)->bill_p;
while (--ct >= 0) { while (--ct >= 0) {
obj = find_oid(bp->bo_id); obj = find_oid(bp->bo_id);
if (!obj) /* shouldn't happen */ if (!obj) /* shouldn't happen */
@@ -3593,6 +3586,7 @@ staticfn void
sub_one_frombill(struct obj *obj, struct monst *shkp) sub_one_frombill(struct obj *obj, struct monst *shkp)
{ {
struct bill_x *bp; struct bill_x *bp;
struct eshk *eshkp;
if ((bp = onbill(obj, shkp, FALSE)) != 0) { if ((bp = onbill(obj, shkp, FALSE)) != 0) {
struct obj *otmp; struct obj *otmp;
@@ -3610,17 +3604,9 @@ sub_one_frombill(struct obj *obj, struct monst *shkp)
add_to_billobjs(otmp); add_to_billobjs(otmp);
return; return;
} }
ESHK(shkp)->billct--; eshkp = ESHK(shkp);
#ifdef DUMB eshkp->billct--;
{ *bp = eshkp->bill_p[eshkp->billct];
/* 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
return; return;
} else if (obj->unpaid) { } else if (obj->unpaid) {
impossible("sub_one_frombill: unpaid object not on bill"); 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 */ /* the glob being absorbed has a billing record */
amount = bp->price; amount = bp->price;
eshkp->billct--; 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]; *bp = eshkp->bill_p[eshkp->billct];
#endif
clear_unpaid_obj(shkp, obj_absorbed); clear_unpaid_obj(shkp, obj_absorbed);
if (bp_absorber) { if (bp_absorber) {