From: PatR Date: Mon, 19 Apr 2021 00:02:11 +0000 (-0700) Subject: fix pull request #488 - regressions for 'a'pply X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=221d82f8997639b24155d2f6f6187c58768ff53c;p=nethack fix pull request #488 - regressions for 'a'pply 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." --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 1ab56a469..207845c46 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -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 diff --git a/include/hack.h b/include/hack.h index ae563165f..5e0fb203a 100644 --- a/include/hack.h +++ b/include/hack.h @@ -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, diff --git a/src/apply.c b/src/apply.c index 868871e04..cc986a11b 100644 --- a/src/apply.c +++ b/src/apply.c @@ -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 */