]> granicus.if.org Git - nethack/commitdiff
wishing for "<foo> of <bar> abilities" (trunk only)
authornethack.rankin <nethack.rankin>
Sun, 2 Oct 2011 03:55:03 +0000 (03:55 +0000)
committernethack.rankin <nethack.rankin>
Sun, 2 Oct 2011 03:55:03 +0000 (03:55 +0000)
     Wishing for "{gain,restore,sustain} abilities" works since
makesingular() changes it to "* ability", but a post-3.4.3 change to
makesingular() caused "potion(s) of {gain,restore} abilities" and
"ring of sustain abilities" to fail to match the name, then yield a
random potion or ring.  If there turn out to be many other similar
situations, makesingular()'s behavior for "foo(s) of bars" may need
to revert.  For now, handle "* of * abilities" as a special case.

src/objnam.c

index 17ad4a719af2a006ea1dad3671cd8b12ca55f7cc..7eec819e9781af3370ea60086ce4530ce7d76a11 100644 (file)
@@ -2145,6 +2145,16 @@ boolean retry_inverted;  /* optional extra "of" handling */
                releaseobuf(p);
                return fuzzymatch(buf, o_str, " -", TRUE);
            }
+       } else if (strstri(o_str, "ability")) {
+               /* when presented with "foo of bar", make singular() used to
+                  singularize both foo & bar, but now only does so for foo */
+           /* catch "{potion(s),ring} of {gain,restore,sustain} abilities" */
+           if ((p = strstri(u_str, "abilities")) != 0 &&
+                   !*(p + sizeof "abilities" - 1)) {
+               (void)strncpy(buf, u_str, (unsigned)(p - u_str));
+               Strcpy(buf + (p - u_str), "ability");
+               return fuzzymatch(buf, o_str, " -", TRUE);
+           }
        } else if (!strcmp(o_str, "aluminum")) {
                /* this special case doesn't really fit anywhere else... */
                /* (note that " wand" will have been stripped off by now) */