From 14d0e48e73ae575608204cf97f5f75fbaaac97e4 Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 1 Jul 2024 00:44:42 -0700 Subject: [PATCH] less verbose sanity checking If the 'sanity_check' option triggers a warning, don't show the "Program in disorder! (Save and restore might fix this.)" and "Report these messages to ." messages and also don't run the crash report submission. Doesn't affect the fuzzer because it escalates impossible() to panic() before reaching those extra messages. --- include/extern.h | 2 +- include/hack.h | 1 + src/pline.c | 10 ++++++++-- src/wizcmds.c | 2 ++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/extern.h b/include/extern.h index 7da52c591..a5d0f24e4 100644 --- a/include/extern.h +++ b/include/extern.h @@ -428,7 +428,6 @@ extern void end_of_input(void); #endif extern char readchar(void); extern char readchar_poskey(coordxy *, coordxy *, int *); -extern void sanity_check(void); extern char* key2txt(uchar, char *); extern char yn_function(const char *, const char *, char, boolean); extern char paranoid_ynq(boolean, const char *, boolean); @@ -3743,6 +3742,7 @@ extern void wizcustom_callback(winid win, int glyphnum, char *id); extern int wiz_display_macros(void); extern int wiz_mon_diff(void); #endif +extern void sanity_check(void); /* ### worm.c ### */ diff --git a/include/hack.h b/include/hack.h index b385fc37f..81f97632b 100644 --- a/include/hack.h +++ b/include/hack.h @@ -783,6 +783,7 @@ struct sinfo { int in_parseoptions; /* in parseoptions */ int in_role_selection; /* role/race/&c selection menus in progress */ int in_getlin; /* inside interface getlin routine */ + int in_sanity_check; /* for impossible() during sanity checking */ int config_error_ready; /* config_error_add is ready, available */ int beyond_savefile_load; /* set when past savefile loading */ #ifdef PANICLOG diff --git a/src/pline.c b/src/pline.c index 811d5a2fe..7e22c1a85 100644 --- a/src/pline.c +++ b/src/pline.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 pline.c $NHDT-Date: 1693083243 2023/08/26 20:54:03 $ $NHDT-Branch: keni-crashweb2 $:$NHDT-Revision: 1.124 $ */ +/* NetHack 3.7 pline.c $NHDT-Date: 1719819280 2024/07/01 07:34:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.130 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -594,6 +594,12 @@ impossible(const char *s, ...) pline("%s", pbuf); gp.pline_flags = 0; + if (gp.program_state.in_sanity_check) { + /* skip rest of multi-line feedback */ + gp.program_state.in_impossible = 0; + return; + } + Strcpy(pbuf2, "Program in disorder!"); if (gp.program_state.something_worth_saving) Strcat(pbuf2, " (Saving and reloading may fix this problem.)"); @@ -608,7 +614,7 @@ impossible(const char *s, ...) boolean report = ('y' == yn_function("Report now?", ynchars, 'n', FALSE)); - raw_print(""); // prove to the user the character was accepted + raw_print(""); /* prove to the user the character was accepted */ if (report) { submit_web_report(1, "Impossible", pbuf); } diff --git a/src/wizcmds.c b/src/wizcmds.c index f4f3006f2..6d1585ce9 100644 --- a/src/wizcmds.c +++ b/src/wizcmds.c @@ -1435,6 +1435,7 @@ sanity_check(void) iflags.sanity_no_check = FALSE; return; } + gp.program_state.in_sanity_check++; you_sanity_check(); obj_sanity_check(); timer_sanity_check(); @@ -1443,6 +1444,7 @@ sanity_check(void) bc_sanity_check(); trap_sanity_check(); engraving_sanity_check(); + gp.program_state.in_sanity_check--; } /* qsort() comparison routine for use in list_migrating_mons() */