fix #H8833 - wishing for "<foo> amulet"

and receiving a random amulet instead of an "amulet of <foo>".
Although the failure to produce the 'right' amulet wasn't a regression
compared to earlier versions as the report indicated, supporting that
wish is straightforward.
This commit is contained in:
PatR
2019-06-20 18:42:35 -07:00
parent 2da552e22f
commit 2fe57af3f3
2 changed files with 24 additions and 7 deletions
+2 -1
View File
@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.61 $ $NHDT-Date: 1561061319 2019/06/20 20:08:39 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.62 $ $NHDT-Date: 1561081353 2019/06/21 01:42:33 $
This fixes36.3 file is here to capture information about updates in the 3.6.x This fixes36.3 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.2 in May 2019. Please note, however, lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -78,6 +78,7 @@ for wizard mode 'monpolycontrol', allow usually disallowed type 'chameleon',
into what?" prompt when <monster> is really that type of creature into what?" prompt when <monster> is really that type of creature
add Space, Return, and Escape to '? k' (help for menu control keys) add Space, Return, and Escape to '? k' (help for menu control keys)
hero can no longer negotiate a bribe with a demon lord when deaf hero can no longer negotiate a bribe with a demon lord when deaf
wishing for "foo amulet" now yields an "amulet of foo" rather than random one
Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository
+22 -6
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 objnam.c $NHDT-Date: 1560185545 2019/06/10 16:52:25 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.243 $ */ /* NetHack 3.6 objnam.c $NHDT-Date: 1561081353 2019/06/21 01:42:33 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.244 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -2818,7 +2818,7 @@ int xtra_prob; /* to force 0% random generation items to also be considered */
* probabilities are not very useful because they don't take * probabilities are not very useful because they don't take
* the class generation probability into account. [If 10% * the class generation probability into account. [If 10%
* of spellbooks were blank and 1% of scrolls were blank, * of spellbooks were blank and 1% of scrolls were blank,
* "blank" would have 10/11 chance to yield a blook even though * "blank" would have 10/11 chance to yield a book even though
* scrolls are supposed to be much more common than books.] * scrolls are supposed to be much more common than books.]
*/ */
for (i = oclass ? bases[(int) oclass] : STRANGE_OBJECT + 1; for (i = oclass ? bases[(int) oclass] : STRANGE_OBJECT + 1;
@@ -3353,6 +3353,7 @@ struct obj *no_wish;
for (i = 0; i < (int) (sizeof wrpsym); i++) { for (i = 0; i < (int) (sizeof wrpsym); i++) {
register int j = strlen(wrp[i]); register int j = strlen(wrp[i]);
/* check for "<class> [ of ] something" */
if (!strncmpi(bp, wrp[i], j)) { if (!strncmpi(bp, wrp[i], j)) {
oclass = wrpsym[i]; oclass = wrpsym[i];
if (oclass != AMULET_CLASS) { if (oclass != AMULET_CLASS) {
@@ -3364,12 +3365,27 @@ struct obj *no_wish;
actualn = bp; actualn = bp;
goto srch; goto srch;
} }
/* check for "something <class>" */
if (!BSTRCMPI(bp, p - j, wrp[i])) { if (!BSTRCMPI(bp, p - j, wrp[i])) {
oclass = wrpsym[i]; oclass = wrpsym[i];
p -= j; /* for "foo amulet", leave the class name so that
*p = 0; wishymatch() can do "of inversion" to try matching
if (p > bp && p[-1] == ' ') "amulet of foo"; other classes don't include their
p[-1] = 0; class name in their full object names (where
"potion of healing" is just "healing", for instance) */
if (oclass != AMULET_CLASS) {
p -= j;
*p = '\0';
if (p > bp && p[-1] == ' ')
p[-1] = '\0';
} else {
/* amulet without "of"; convoluted wording but better a
special case that's handled than one that's missing */
if (!strncmpi(bp, "versus poison ", 14)) {
typ = AMULET_VERSUS_POISON;
goto typfnd;
}
}
actualn = dn = bp; actualn = dn = bp;
goto srch; goto srch;
} }