do-again vs yn_function()

This fixes the impossible from yn_function() for ^A after Z.  One
call to yn_function stored the spell letter for do-again and then
another call was unintentionally using that when getting a y/n
response for askchain() while using menustyle:Traditional [when
spell was identify and eligible objects needed confirmation about
whether to be ID'd].

Fixing that seemed to break #pray so the paranoid_confirm routine
has been changed to not rely on canned input, even for queries where
the player hasn't specified that confirmation be required.

Behavior of ^A might be different in unexpected ways, but it wasn't
working correctly before.
This commit is contained in:
PatR
2025-11-08 18:38:55 -08:00
parent 33401b0d08
commit f7e12d2801
4 changed files with 20 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 cmd.c $NHDT-Date: 1736401574 2025/01/08 21:46:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.744 $ */
/* NetHack 3.7 cmd.c $NHDT-Date: 1762680996 2025/11/09 01:36:36 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.755 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -5260,7 +5260,7 @@ yn_function(
query = qbuf;
}
if ((cmdq = cmdq_pop()) != 0) {
if (addcmdq && (cmdq = cmdq_pop()) != 0) {
cq = *cmdq;
free(cmdq);
} else {
@@ -5323,7 +5323,7 @@ yn_function(
it is most likely caused by saving a keystroke that was just used
to answer a context-sensitive prompt, then using the do-again
command with context that has changed */
if (resp && res && !strchr(resp, res)) {
if (resp && *resp && res && !strchr(resp, res)) {
/* this probably needs refinement since caller is expecting something
within 'resp' and ESC won't be (it could be present, but as a flag
for unshown possibilities rather than as acceptable input) */
@@ -5405,9 +5405,11 @@ paranoid_ynq(
/* for empty input, return value c will already be 'n' */
} while (ParanoidConfirm && strcmpi(ans, "no") && --trylimit);
} else if (accept_q) {
c = ynq(prompt); /* 'y', 'n', or 'q' */
/* 'y', 'n', or 'q' */
c = yn_function(prompt, ynqchars, 'n', FALSE);
} else {
c = y_n(prompt); /* 'y' or 'n' */
/* 'y' or 'n' */
c = yn_function(prompt, ynchars, 'n', FALSE);
}
if (c != 'y' && (c != 'q' || !accept_q))
c = 'n';