From 70949a787e48313ebabc5dde0125bf523703b248 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 29 Apr 2023 05:30:14 -0700 Subject: [PATCH] mplayer creation bestowing 0 gold pieces Reported directly to devteam: a fake player monster was petrified and when creating its statue yielded "Calculating weight of 0 gold pieces?". Fake player monsters on the Astral Plane level were being created with rn2(1000) gold pieces so had a 1 in 1000 chance of that being 0. Gold gets created with a non-zero amount but the routine that gives it to a monster sets the amount to the requested value. That didn't update the weight so didn't notice the 0. Putting it into a container (the statue) did recalculate the weight and did notice. There was a choice between forcing a non-zero amount or allowing 0 and bypassing its creation and placement in monster's inventory. I went with the latter. --- doc/fixes3-7-0.txt | 3 +++ src/makemon.c | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index d4c581bc0..f6b7b1eb0 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1156,6 +1156,9 @@ wearing the Eyes of the Overworld overrides OPTIONS:blind; breaking the blindness stay cured after removing them was not change helm of brilliance from iron to crystal so that it no longer needs to be a special case for metallic armor vs spell casting +fake player monsters in endgame had a 1 in 1000 chance to be given a stack + of 0 gold pieces, eventually triggering an impossible warning (cited + one was "Calculating weight of 0 gold pieces?") Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/makemon.c b/src/makemon.c index 950f5e363..3e0490e2a 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -558,16 +558,18 @@ m_initweap(register struct monst *mtmp) (void) mongets(mtmp, rnd_offensive_item(mtmp)); } -/* - * Makes up money for monster's inventory. - */ +/* create a new stack of gold in monster's inventory */ void mkmonmoney(struct monst *mtmp, long amount) { - struct obj *gold = mksobj(GOLD_PIECE, FALSE, FALSE); + /* mk_mplayer() passes rn2(1000) so the amount might be 0 */ + if (amount > 0L) { + struct obj *gold = mksobj(GOLD_PIECE, FALSE, FALSE); - gold->quan = amount; - add_to_minv(mtmp, gold); + gold->quan = amount; + gold->owt = weight(gold); + add_to_minv(mtmp, gold); + } } static void