^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.
This commit is contained in:
PatR
2023-05-22 00:32:25 -07:00
parent 4e46a7de69
commit 1f8b3dfef5
2 changed files with 14 additions and 0 deletions

View File

@@ -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

View File

@@ -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();