wishing for "<shape> amulet"
I saw a mimic disguised as an octagonal amulet and wished for an amulet of that shape to see what it was trying to tempt me with. I got a random amulet instead of one with the requested description. That was happening for any valid shape (it's expected behavior for invalid descriptions, where only "amulet" matches).
This commit is contained in:
18
src/objnam.c
18
src/objnam.c
@@ -4538,8 +4538,8 @@ readobjnam_postparse1(struct _readobjnam_data *d)
|
||||
return 4; /*goto any;*/
|
||||
}
|
||||
|
||||
/* Search for class names: XXXXX potion, scroll of XXXXX. Avoid */
|
||||
/* false hits on, e.g., rings for "ring mail". */
|
||||
/* Search for class names: XXXXX potion, scroll of XXXXX.
|
||||
Avoid false hits on, e.g., rings for "ring mail". */
|
||||
if (strncmpi(d->bp, "enchant ", 8)
|
||||
&& strncmpi(d->bp, "destroy ", 8)
|
||||
&& strncmpi(d->bp, "detect food", 11)
|
||||
@@ -4579,12 +4579,26 @@ readobjnam_postparse1(struct _readobjnam_data *d)
|
||||
if (d->p > d->bp && d->p[-1] == ' ')
|
||||
d->p[-1] = '\0';
|
||||
} else {
|
||||
int k, l;
|
||||
char amubuf[BUFSZ];
|
||||
|
||||
/* amulet without "of"; convoluted wording but better a
|
||||
special case that's handled than one that's missing */
|
||||
if (!strncmpi(d->bp, "versus poison ", 14)) {
|
||||
d->typ = AMULET_VERSUS_POISON;
|
||||
return 2; /*goto typfnd;*/
|
||||
}
|
||||
/* check for "<shape> amulet"; strip off trailing
|
||||
" amulet" for that w/o changing contents of d->bp */
|
||||
l = (int) strlen(d->bp) - j;
|
||||
if (l > 0 && d->bp[l - 1] == ' ')
|
||||
l -= 1;
|
||||
copynchars(amubuf, d->bp, min(l, (int) sizeof amubuf - 1));
|
||||
k = rnd_otyp_by_namedesc(amubuf, AMULET_CLASS, 0);
|
||||
if (k != STRANGE_OBJECT) {
|
||||
d->typ = k;
|
||||
return 2; /*goto typfnd;*/
|
||||
}
|
||||
}
|
||||
d->actualn = d->dn = d->bp;
|
||||
return 1; /*goto srch;*/
|
||||
|
||||
Reference in New Issue
Block a user