diff --git a/include/hack.h b/include/hack.h index d9d7ba156..e60a3b060 100644 --- a/include/hack.h +++ b/include/hack.h @@ -453,6 +453,8 @@ typedef uint32_t mmflags_nht; /* makemon MM_ flags */ #define nyaq(query) yn_function(query, ynaqchars, 'n', TRUE) #define nyNaq(query) yn_function(query, ynNaqchars, 'n', TRUE) #define ynNaq(query) yn_function(query, ynNaqchars, 'y', TRUE) +/* YN() is same as yn() except doesn't save the response in do-again buffer */ +#define YN(query) yn_function(query, ynchars, 'n', FALSE) /* Macros for scatter */ #define VIS_EFFECTS 0x01 /* display visual effects */ diff --git a/src/pray.c b/src/pray.c index 2ea00d2b3..bdb1fe6fd 100644 --- a/src/pray.c +++ b/src/pray.c @@ -2016,8 +2016,13 @@ pray_revive(void) int dopray(void) { - /* Confirm accidental slips of Alt-P */ - if (ParanoidPray && yn("Are you sure you want to pray?") != 'y') + /* + * If ParanoidPray is set, confirm prayer to avoid accidental slips + * of Alt+p. + * YN(): don't save response in do-again buffer since if it is 'y', + * ^A would bypass confirmation, or if 'n', ^A would be pointless. + */ + if (ParanoidPray && YN("Are you sure you want to pray?") != 'y') return ECMD_OK; if (!u.uconduct.gnostic++) @@ -2033,7 +2038,13 @@ dopray(void) return ECMD_OK; if (wizard && g.p_type >= 0) { - if (yn("Force the gods to be pleased?") == 'y') { + static const char forcesuccess[] = "Force the gods to be pleased?"; + + /* if we asked "are you sure?" above we suppressed the response + from the do-again buffer, so need to suppress this response too; + otherwise subsequent ^A would use this answer for "are you sure?" + and bypass confirmation */ + if ((ParanoidPray ? YN(forcesuccess) : yn(forcesuccess)) == 'y') { u.ublesscnt = 0; if (u.uluck < 0) u.uluck = 0;