The attempt to simplify shop handling of containers keeps getting more complicated. Fixes #1352
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 shk.c $NHDT-Date: 1720717993 2024/07/11 17:13:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.298 $ */
|
/* NetHack 3.7 shk.c $NHDT-Date: 1736516428 2025/01/10 05:40:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.306 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -2091,7 +2091,7 @@ pay_billed_items(
|
|||||||
/* update shk's bill and augmented bill after an item has been purchased */
|
/* update shk's bill and augmented bill after an item has been purchased */
|
||||||
staticfn void
|
staticfn void
|
||||||
update_bill(
|
update_bill(
|
||||||
int indx,
|
int indx, /* index into ibill[]; -1 for unpaid contained item */
|
||||||
int ibillct,
|
int ibillct,
|
||||||
Bill *ibill,
|
Bill *ibill,
|
||||||
struct eshk *eshkp,
|
struct eshk *eshkp,
|
||||||
@@ -2117,18 +2117,16 @@ update_bill(
|
|||||||
from shop bill; if it was used up, remove it from the billobjs
|
from shop bill; if it was used up, remove it from the billobjs
|
||||||
list and delete it; update shop's bill by moving last bill_p[]
|
list and delete it; update shop's bill by moving last bill_p[]
|
||||||
entry into vacated slot; also update ibill[] indices for that */
|
entry into vacated slot; also update ibill[] indices for that */
|
||||||
paiditem->unpaid = 0; /* set before maybe deallocating */
|
paiditem->unpaid = 0; /* clear before maybe deallocating */
|
||||||
if (paiditem->where == OBJ_ONBILL) {
|
if (paiditem->where == OBJ_ONBILL) {
|
||||||
obj_extract_self(paiditem);
|
obj_extract_self(paiditem);
|
||||||
dealloc_obj(paiditem);
|
dealloc_obj(paiditem);
|
||||||
}
|
}
|
||||||
newebillct = eshkp->billct - 1;
|
newebillct = eshkp->billct - 1;
|
||||||
*bp = eshkp->bill_p[newebillct];
|
*bp = eshkp->bill_p[newebillct];
|
||||||
if (indx >= 0) {
|
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 = ibill[indx].bidx;
|
|
||||||
}
|
|
||||||
eshkp->billct = newebillct; /* eshkp->billct - 1 */
|
eshkp->billct = newebillct; /* eshkp->billct - 1 */
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -2145,7 +2143,7 @@ dopayobj(
|
|||||||
struct monst *shkp,
|
struct monst *shkp,
|
||||||
struct bill_x *bp,
|
struct bill_x *bp,
|
||||||
struct obj *obj,
|
struct obj *obj,
|
||||||
int which /* 0 => used-up item, 1 => other (unpaid or lost) */,
|
int which, /* 0 => used-up item, 1 => other (unpaid or lost) */
|
||||||
boolean itemize,
|
boolean itemize,
|
||||||
boolean unseen)
|
boolean unseen)
|
||||||
{
|
{
|
||||||
@@ -2311,7 +2309,8 @@ buy_container(
|
|||||||
}
|
}
|
||||||
/* [updating cost here is not necessary but useful when debugging] */
|
/* [updating cost here is not necessary but useful when debugging] */
|
||||||
ibill[indx].cost -= (bp->price * bp->bquan); /* update container */
|
ibill[indx].cost -= (bp->price * bp->bquan); /* update container */
|
||||||
update_bill(-1, ibillct, ibill, eshkp, bp, otmp);
|
update_bill((boid == container->o_id) ? indx : -1,
|
||||||
|
ibillct, ibill, eshkp, bp, otmp);
|
||||||
++buycount;
|
++buycount;
|
||||||
}
|
}
|
||||||
if (buycount && sightunseen) {
|
if (buycount && sightunseen) {
|
||||||
|
|||||||
Reference in New Issue
Block a user