From c0228d1a74a09174a105388b74a9a7b2cef52ba0 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 25 Nov 2021 00:47:45 -0800 Subject: [PATCH] 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. --- doc/fixes37.0 | 3 +++ include/obj.h | 3 ++- src/shk.c | 11 ++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 7165222b4..5adf3188e 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -900,6 +900,9 @@ misaligned potion colors due to lack of reset_glyphmap() following obj shuffle; closed doors were described as "horizontal closed door" or "vertical closed door" instead of just "closed door" glob shrinkage while hero was away from glob's level wasn't handled properly +unpaid shop-owned glob that shrank to nothing had weight 0 which triggered + onbill warnings when 'sanity_check' was On; for 'Ix' and itemized + billing, the empty weight was shown to player if 'wizweight' was On curses: 'msg_window' option wasn't functional for curses unless the binary also included tty support diff --git a/include/obj.h b/include/obj.h index 32e30bf99..0fdd0d1ad 100644 --- a/include/obj.h +++ b/include/obj.h @@ -23,7 +23,8 @@ struct oextra { char *oname; /* ptr to name of object */ struct monst *omonst; /* ptr to attached monst struct */ char *omailcmd; /* response_cmd for mail delivery */ - unsigned omid; /* for corpse; m_id of corpse's ghost */ + unsigned omid; /* for corpse: m_id of corpse's ghost; overloaded + * for glob: owt at time added to shop's bill */ }; struct obj { diff --git a/src/shk.c b/src/shk.c index 102faafcf..1ac2a7926 100644 --- a/src/shk.c +++ b/src/shk.c @@ -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; }