more glob wishing

Wishing for "<size> glob of black pudding" worked, and wishing for
"black pudding glob" worked, but wishing for "<size> black pudding
glob" didn't work.  Fix that.

Also, remove a bit of spaghetti introduced by the previous patch.
And once we know we're wishing for a glob, we can skip a big chunk
of wish parsing and special case handling.
This commit is contained in:
PatR
2018-06-19 18:39:08 -07:00
parent 9415797c65
commit 3c979cb0a5

View File

@@ -2721,9 +2721,9 @@ char oclass;
if (!name)
return STRANGE_OBJECT;
memset((genericptr_t) validobjs, 0, sizeof(validobjs));
memset((genericptr_t) validobjs, 0, sizeof validobjs);
for (i = oclass ? bases[(int)oclass] : STRANGE_OBJECT + 1;
for (i = oclass ? bases[(int) oclass] : STRANGE_OBJECT + 1;
i < NUM_OBJECTS && (!oclass || objects[i].oc_class == oclass);
++i) {
/* don't match extra descriptions (w/o real name) */
@@ -2921,8 +2921,11 @@ struct obj *no_wish;
contents = EMPTY;
} else if (!strncmpi(bp, "small ", l = 6)) { /* glob sizes */
/* "small" might be part of monster name (mimic, if wishing
for its corpse) rather than prefix for glob size */
if (strncmpi(bp + l, "glob", 4))
for its corpse) rather than prefix for glob size; when
used for globs, it might be either "small glob of <foo>" or
"small <foo> glob" and user might add 's' even though plural
doesn't accomplish anything because globs don't stack */
if (strncmpi(bp + l, "glob", 4) && !strstri(bp + l, " glob"))
break;
gsize = 1;
} else if (!strncmpi(bp, "medium ", l = 7)) {
@@ -2934,7 +2937,7 @@ struct obj *no_wish;
/* "large" might be part of monster name (dog, cat, koboold,
mimic) or object name (box, round shield) rather than
prefix for glob size */
if (strncmpi(bp + l, "glob", 4))
if (strncmpi(bp + l, "glob", 4) && !strstri(bp + l, " glob"))
break;
/* "very large " had "very " peeled off on previous iteration */
gsize = (very != 1) ? 3 : 4;
@@ -3067,30 +3070,27 @@ struct obj *no_wish;
* also don't let player wish for multiple globs.
*/
i = (int) strlen(bp);
p = (char *) 0;
/* check for "glob", "<foo> glob", and "glob of <foo>" */
if (!strcmpi(bp, "glob") || !BSTRCMPI(bp, bp + i - 5, " glob")
|| !strcmpi(bp, "globs") || !BSTRCMPI(bp, bp + i - 6, " globs")) {
/* string ends in "glob"; accept "black pudding glob" variation */
if ((mntmp = name_to_mon(bp)) == NON_PM)
/* "[size] glob" without "of <foo>"; pick random <foo> */
|| !strcmpi(bp, "globs") || !BSTRCMPI(bp, bp + i - 6, " globs")
|| (p = strstri(bp, "glob of ")) != 0
|| (p = strstri(bp, "globs of ")) != 0) {
mntmp = name_to_mon(!p ? bp : (strstri(p, " of ") + 4));
/* if we didn't recognize monster type, pick a valid one at random */
if (mntmp == NON_PM)
mntmp = rn1(PM_BLACK_PUDDING - PM_GRAY_OOZE, PM_GRAY_OOZE);
replaceglob:
/* construct canonical spelling in case name_to_mon() recognized a
variant (grey ooze) or player used inverted syntax (<foo> glob);
if player has given a valid monster type but not valid glob type,
object name lookup won't find it and wish attempt will fail */
Sprintf(globbuf, "glob of %s", mons[mntmp].mname);
bp = globbuf;
mntmp = NON_PM; /* not useful for "glob of <foo>" object lookup */
cnt = 0; /* globs don't stack */
} else if ((p = strstri(bp, "glob of ")) != 0
|| (p = strstri(bp, "globs of ")) != 0) {
int globoffset = (*(p + 4) == 's') ? 9 : 8;
if ((mntmp = name_to_mon(p + globoffset)) == PM_GRAY_OOZE) {
/* name_to_mon() recognizes "grey ooze" as variant spelling
but doesn't change input string to fix it; force canonical
spelling so that object name lookup always finds it */
goto replaceglob;
} else if (mntmp > PM_GRAY_OOZE && mntmp <= PM_BLACK_PUDDING) {
mntmp = NON_PM; /* lie to ourselves */
cnt = 0; /* force only one */
}
oclass = FOOD_CLASS;
actualn = bp, dn = 0;
goto srch;
} else {
/*
* Find corpse type using "of" (figurine of an orc, tin of orc meat)