]> granicus.if.org Git - nethack/commitdiff
fix pull request #488 - regressions for 'a'pply
authorPatR <rankin@nethack.org>
Mon, 19 Apr 2021 00:02:11 +0000 (17:02 -0700)
committerPatR <rankin@nethack.org>
Mon, 19 Apr 2021 00:02:11 +0000 (17:02 -0700)
Restore some old behavior for the apply command that was changed
by the "getobj refactor" patch.  You couldn't attempt to apply
potions to determine whether they were oil, couldn't apply gray
stones once touchstone was discovered, and attempting to apply
arbitrary items gave "that is a silly thing to apply" rather
than "sorry, I don't know how to use that."

doc/fixes37.0
include/hack.h
src/apply.c

index 1ab56a4699e79f93dbb485db4398bf882c92d542..207845c46af4520d03107f77e882c86f5376e34e 100644 (file)
@@ -614,6 +614,7 @@ give genetic engineers teleport capability (as they had in slash'em); 'port
        away after polymorphing someone so that they don't just repeat that
 if an invisible hero managed to convert an unaligned altar to an aligned one
        with color enabled, altar wasn't immediately redrawn with new color
+repair some regressions to (a)pply introduced by "getobj refactor" patch
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index ae563165fd4934cc6f321b6315682a6ea0ab6c13..5e0fb203a07902b4cc3bc0f444bc00de86210d82 100644 (file)
@@ -500,13 +500,13 @@ enum getobj_callback_returns {
      * else to foo". */
     GETOBJ_EXCLUDE_INACCESS = -1,
     /* invalid for purposes of not showing a prompt if nothing is valid but
-     * psuedo-valid for selecting - identical to GETOBJ_EXCLUDE but
+     * psuedo-valid for selecting - identical to GETOBJ_EXCLUDE_INACCESS but
      * without the "else" in "You don't have anything else to foo". */
     GETOBJ_EXCLUDE_SELECTABLE = 0,
     /* valid - invlet not presented in the summary or the ? menu as a
-     * recommendation, but is selectable if the player enters it anyway. Used
-     * for objects that are actually valid but unimportantly so, such as shirts
-     * for reading. */
+     * recommendation, but is selectable if the player enters it anyway.
+     * Used for objects that are actually valid but unimportantly so, such
+     * as shirts for reading. */
     GETOBJ_DOWNPLAY = 1,
     /* valid - will be shown in summary and ? menu */
     GETOBJ_SUGGEST  = 2,
index 868871e049841483dcbc3bb6c9ab3e7a4c12c976..cc986a11b34897c9277160f0bb4a7a6299bdf88e 100644 (file)
@@ -3658,7 +3658,7 @@ apply_ok(struct obj *obj)
         return GETOBJ_EXCLUDE;
 
     /* all tools, all wands (breaking), all spellbooks (flipping through -
-     * including blank/novel/Book of the Dead) */
+       including blank/novel/Book of the Dead) */
     if (obj->oclass == TOOL_CLASS || obj->oclass == WAND_CLASS
         || obj->oclass == SPBOOK_CLASS)
         return GETOBJ_SUGGEST;
@@ -3669,11 +3669,16 @@ apply_ok(struct obj *obj)
             || obj->otyp == BULLWHIP))
         return GETOBJ_SUGGEST;
 
-    /* only applicable potion is oil, and it will only be offered as a choice
-     * when already discovered */
-    if (obj->otyp == POT_OIL && obj->dknown
-        && objects[obj->otyp].oc_name_known)
-        return GETOBJ_SUGGEST;
+    if (obj->oclass == POTION_CLASS) {
+        /* permit applying unknown potions, but don't suggest them */
+        if (!obj->dknown || !objects[obj->otyp].oc_name_known)
+            return GETOBJ_DOWNPLAY;
+
+        /* only applicable potion is oil, and it will only be suggested as a
+           choice when already discovered */
+        if (obj->otyp == POT_OIL)
+            return GETOBJ_SUGGEST;
+    }
 
     /* certain foods */
     if (obj->otyp == CREAM_PIE || obj->otyp == EUCALYPTUS_LEAF
@@ -3682,19 +3687,22 @@ apply_ok(struct obj *obj)
 
     if (is_graystone(obj)) {
         /* The only case where we don't suggest a gray stone is if we KNOW it
-         * isn't a touchstone. */
+           isn't a touchstone. */
         if (!obj->dknown)
             return GETOBJ_SUGGEST;
 
         if (obj->otyp != TOUCHSTONE
             && (objects[TOUCHSTONE].oc_name_known
                 || objects[obj->otyp].oc_name_known))
-            return GETOBJ_EXCLUDE;
+            return GETOBJ_EXCLUDE_SELECTABLE;
 
         return GETOBJ_SUGGEST;
     }
 
-    return GETOBJ_EXCLUDE;
+    /* item can't be applied; if picked anyway,
+       _EXCLUDE would yield "That is a silly thing to apply.",
+       _EXCLUDE_SELECTABLE yields "Sorry, I don't know how to use that." */
+    return GETOBJ_EXCLUDE_SELECTABLE;
 }
 
 /* the 'a' command */