wishing fix
name_to_mon() has a bunch of alternate monster names, such as "gray-elf" to match "grey-elf" and "ki rin" to match "ki-rin". Those worked as intended when they occurred at the end of a wish, but only worked in the middle if their length was the same or one character less than the canonical name in mons[].mname. djinni figurine -> h - a figurine of a djinni genie figurine -> i - a figurine of a djinni figurine of mumak -> j - a figurine of a mumak mumak figurine -> k - a figurine of a mumak figurine of mumakil -> l - a figurine of a mumak mumakil figurine -> nothing fitting that description exists (The one-less case worked because its following space ended up being implicitly removed when skipping ahead by the length of mons[].mname; subsequent explicit removal didn't find a space so was a no-op.)
This commit is contained in:
19
src/objnam.c
19
src/objnam.c
@@ -3585,19 +3585,24 @@ struct obj *no_wish;
|
||||
&& strncmpi(bp, "ninja-to", 8) /* not the "ninja" rank */
|
||||
&& strncmpi(bp, "master key", 10) /* not the "master" rank */
|
||||
&& strncmpi(bp, "magenta", 7)) { /* not the "mage" rank */
|
||||
const char *rest = 0;
|
||||
|
||||
if (mntmp < LOW_PM && strlen(bp) > 2
|
||||
&& (mntmp = name_to_mon(bp)) >= LOW_PM) {
|
||||
int mntmptoo, mntmplen; /* double check for rank title */
|
||||
&& (mntmp = name_to_monplus(bp, &rest)) >= LOW_PM) {
|
||||
char *obp = bp;
|
||||
|
||||
mntmptoo = title_to_mon(bp, (int *) 0, &mntmplen);
|
||||
bp += (mntmp != mntmptoo) ? (int) strlen(mons[mntmp].mname)
|
||||
: mntmplen;
|
||||
/* 'rest' is a pointer past the matching portion; if that was
|
||||
an alternate name or a rank title rather than the canonical
|
||||
monster name we wouldn't otherwise know how much to skip */
|
||||
bp = (char *) rest; /* cast away const */
|
||||
|
||||
if (*bp == ' ') {
|
||||
bp++;
|
||||
} else if (!strncmpi(bp, "s ", 2)) {
|
||||
} else if (!strncmpi(bp, "s ", 2)
|
||||
|| (bp > origbp && !strncmpi(bp - 1, "s' ", 3))) {
|
||||
bp += 2;
|
||||
} else if (!strncmpi(bp, "es ", 3)) {
|
||||
} else if (!strncmpi(bp, "es ", 3)
|
||||
|| !strncmpi(bp, "'s ", 3)) {
|
||||
bp += 3;
|
||||
} else if (!*bp && !actualn && !dn && !un && !oclass) {
|
||||
/* no referent; they don't really mean a monster type */
|
||||
|
||||
Reference in New Issue
Block a user