shrinking globs vs shop bill

A shop-owned glob picked up by the hero was added to shop's bill
and if that shrank to nothing it moved from the unpaid portion to
used-up portion as intended.  But once there it retained obj->owt
of 0 and if 'sanity_check' was enabled, that triggered a warning
every move until finally paid for.  Both the 'Ix' list of used-up
items and itemized shop billing revealed a weight of 0 aum if
'wizweight' was enabled.

Keep track of the weight a glob had when it becomes unpaid, then
reset from 0 to that amount if it becomes used-up.  This overloads
the obj->oextra->omid field which is an unsigned int previously
only used for corpses.  Now for globs it is pre-bill obj->owt which
is also unsigned int.  I didn't add new oextra access functions for
it; it is only used in two places and existing omid ones suffice.
This commit is contained in:
PatR
2021-11-25 00:47:45 -08:00
parent 01b2bcff75
commit c0228d1a74
3 changed files with 15 additions and 2 deletions

View File

@@ -946,6 +946,10 @@ obfree(register struct obj* obj, register struct obj* merge)
if (!merge) {
bp->useup = 1;
obj->unpaid = 0; /* only for doinvbill */
/* for used up glob, put back origial weight in case it gets
formatted ('I x' or itemized billing) with 'wizweight' On */
if (obj->globby && !obj->owt && has_omid(obj))
obj->owt = OMID(obj);
add_to_billobjs(obj);
return;
}
@@ -2483,9 +2487,14 @@ add_one_tobill(struct obj *obj, boolean dummy, struct monst *shkp)
} else
bp->useup = 0;
bp->price = get_cost(obj, shkp);
if (obj->globby)
if (obj->globby) {
/* for globs, the amt charged for quan 1 depends on owt */
bp->price *= get_pricing_units(obj);
/* remember the weight this glob had when it was added to bill;
glob oextra_owt field overlays corpse omid field */
newomid(obj);
OMID(obj) = obj->owt;
}
eshkp->billct++;
obj->unpaid = 1;
}