From 57fc8f10a6a9c1fe3d471b67f378763a570bf2cf Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 12 Oct 2024 10:14:44 -0400 Subject: [PATCH] replace fuzzer state magic numbers --- include/flag.h | 6 ++++++ src/end.c | 2 +- src/pline.c | 2 +- src/wizcmds.c | 10 ++++++++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/flag.h b/include/flag.h index e774a1c31..4fbfad0e7 100644 --- a/include/flag.h +++ b/include/flag.h @@ -224,6 +224,12 @@ struct accessibility_data { a11y.mon_notices_blocked = 0; \ } } while(0) +enum debug_fuzzer_states { + fuzzer_off, + fuzzer_impossible_panic, + fuzzer_impossible_continue +}; + /* * Stuff that really isn't option or platform related and does not * get saved and restored. They are set and cleared during the game diff --git a/src/end.c b/src/end.c index 519b599dc..1c10e192b 100644 --- a/src/end.c +++ b/src/end.c @@ -77,7 +77,7 @@ done1(int sig_unused UNUSED) #ifndef NO_SIGNAL (void) signal(SIGINT, SIG_IGN); #endif - iflags.debug_fuzzer = FALSE; + iflags.debug_fuzzer = fuzzer_off; if (flags.ignintr) { #ifndef NO_SIGNAL (void) signal(SIGINT, (SIG_RET_TYPE) done1); diff --git a/src/pline.c b/src/pline.c index 1e23846ce..4ca4a79a7 100644 --- a/src/pline.c +++ b/src/pline.c @@ -587,7 +587,7 @@ impossible(const char *s, ...) va_end(the_args); pbuf[BUFSZ - 1] = '\0'; /* sanity */ paniclog("impossible", pbuf); - if (iflags.debug_fuzzer == 1) + if (iflags.debug_fuzzer == fuzzer_impossible_panic) panic("%s", pbuf); gp.pline_flags = URGENT_MESSAGE; diff --git a/src/wizcmds.c b/src/wizcmds.c index 88dd27aac..12f51758c 100644 --- a/src/wizcmds.c +++ b/src/wizcmds.c @@ -551,8 +551,14 @@ wiz_fuzzer(void) pline("The fuzz tester will make NetHack execute random keypresses."); There("is no conventional way out of this mode."); } - if (paranoid_query(TRUE, "Do you want to start fuzz testing?")) - iflags.debug_fuzzer = TRUE; /* Thoth, take the reins */ + if (paranoid_query(TRUE, "Do you want to start fuzz testing?")) { + /* Thoth, take the reins */ + if (y_n("Do you want to call panic() after impossible()?") == 'n') { + iflags.debug_fuzzer = fuzzer_impossible_continue; + } else { + iflags.debug_fuzzer = fuzzer_impossible_panic; + } + } return ECMD_OK; }