From: PatR Date: Thu, 2 Jun 2022 20:02:45 +0000 (-0700) Subject: fix #K3608 - glob quantity X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cc2332946ef95e5f14fc85059c6f5cea205d1d31;p=nethack fix #K3608 - glob quantity Wishing for "N globs [of pudding type]" produces 1 glob starting at and then multiples weight by N (so possibly increasing ). When not it wizard mode, N can be replaced by a random amount to prevent the total weight from being huge. When N was less than 6, it was possible for that random amount to be larger than what the player asked for. Change the way the random amount is calculated so that it won't ever be larger than what player specified. Also for wizard mode prompt whether to make the substitution so that the player can choose to abide by the limit or to obtain a huge glob for whatever testing is being conducted. --- diff --git a/src/objnam.c b/src/objnam.c index c8248c5ba..b92c3ef89 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 objnam.c $NHDT-Date: 1653171584 2022/05/21 22:19:44 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.364 $ */ +/* NetHack 3.7 objnam.c $NHDT-Date: 1654200083 2022/06/02 20:01:23 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.366 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -685,15 +685,11 @@ xname_flags( doname() so we've added an external flag to request it */ Strcat(buf, "partly eaten "); } - if (obj->globby) { - Sprintf(eos(buf), "%s%s", - (obj->owt <= 100) - ? "small " - : (obj->owt > 500) - ? "very large " - : (obj->owt > 300) - ? "large " - : "medium ", + if (obj->globby) { /* 3.7 added "medium" to replace no-prefix */ + Sprintf(eos(buf), "%s %s", (obj->owt <= 100) ? "small" + : (obj->owt <= 300) ? "medium" + : (obj->owt <= 500) ? "large" + : "very large", actualn); break; } @@ -4602,9 +4598,17 @@ readobjnam(char *bp, struct obj *no_wish) if (d.gsize > 1) d.otmp->owt += ((unsigned) (5 + (d.gsize - 2) * 10) * d.otmp->owt); /* 20 + {5|15|25} times 20 */ + /* limit overall weight which limits shrink-away time which in turn + affects how long some of it will remain available to be eaten */ if (d.cnt > 1) { - if ((d.cnt > 6 - d.gsize) && !wizard) - d.cnt = rn1(5, 2); /* 2..6 */ + int rn1cnt = rn1(5, 2); /* 2..6 */ + + if (rn1cnt > 6 - d.gsize) + rn1cnt = 6 - d.gsize; + if (d.cnt > rn1cnt + && (!wizard || g.program_state.wizkit_wishing + || yn("Override glob weight limit?") != 'y')) + d.cnt = rn1cnt; d.otmp->owt *= (unsigned) d.cnt; } /* note: the owt assignment below will not change glob's weight */