From 1f8b3dfef5b0619412de40657b7bb98c7305c1b5 Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 22 May 2023 00:32:25 -0700 Subject: [PATCH] ^P vs sanity_check Normally when sanity_check is enabled it will take place for every command executed. Avoid that when the command is ^P because if a sanity warning is a recurring one and the msg_window setting is single or combination (tty-only) which shows one message, ^P will just repeat each new warning without having any chance to cycle back to earlier messages. --- doc/fixes3-7-0.txt | 3 +++ src/cmd.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 938290c8d..fa205f7b2 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1187,6 +1187,9 @@ don't exclude map column 1 from consideration when rloc() picks a random spot for destination of a teleported monster covetous monster attacking another monster to acquire special item would not do so if positioned diagonally adjacent +skip sanity_check handling when current command is ^P, otherwise it might + re-trigger and show new sanity warning every time when set for + line-at-a-line feedback Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/cmd.c b/src/cmd.c index 186a568ff..c943b739c 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -188,11 +188,14 @@ static const char *readchar_queue = ""; static const char unavailcmd[] = "Unavailable command '%s'."; /* for rejecting #if !SHELL, !SUSPEND */ static const char cmdnotavail[] = "'%s' command not available."; +/* doesn't need to be in struct g|gw */ +static boolean was_doprev = FALSE; /* the #prevmsg command */ static int doprev_message(void) { + was_doprev = TRUE; (void) nh_doprev_message(); return ECMD_OK; } @@ -4265,6 +4268,14 @@ you_sanity_check(void) void sanity_check(void) { + if (was_doprev) { + /* in case a recurring sanity_check warning occurs, we mustn't + re-trigger it when ^P is used, otherwise msg_window:Single + and msg_window:Combination will always repeat the most recent + instance, never able to go back to any earlier messages */ + was_doprev = FALSE; + return; + } you_sanity_check(); obj_sanity_check(); timer_sanity_check();