]> granicus.if.org Git - nethack/commitdiff
Expose some debug flags in options
authorPasi Kallinen <paxed@alt.org>
Wed, 17 Aug 2022 11:28:04 +0000 (14:28 +0300)
committerPasi Kallinen <paxed@alt.org>
Wed, 17 Aug 2022 17:17:30 +0000 (20:17 +0300)
Show and allow changing the debugging flags in options:

debug_fuzzer: turn on the fuzzer
debug_hunger: prevent hunger
debug_mongen: prevent monster generation
debug_overwrite_stairs: allow level generation overwrite stairs

These are wizard-mode only, cannot be set via config file,
and the fuzzer cannot change these either.

include/hack.h
include/optlist.h
src/options.c

index 6471ac1750e89adc23898ec74debe3192a14f77b..df0aab3e537e49dca338add062accfc2c6531292 100644 (file)
@@ -674,9 +674,10 @@ enum optset_restrictions {
     set_gameview   = 3, /* may be set via extern program, displayed in game */
     set_in_game    = 4, /* may be set via extern program or set in the game */
     set_wizonly    = 5, /* may be set set in the game if wizmode */
-    set_hidden     = 6  /* placeholder for prefixed entries, never show it  */
+    set_wiznofuz   = 6, /* wizard-mode only, but not by fuzzer */
+    set_hidden     = 7  /* placeholder for prefixed entries, never show it  */
 };
-#define SET__IS_VALUE_VALID(s) ((s < set_in_sysconf) || (s > set_wizonly))
+#define SET__IS_VALUE_VALID(s) ((s < set_in_sysconf) || (s > set_wiznofuz))
 
 #define FEATURE_NOTICE_VER(major, minor, patch)                    \
     (((unsigned long) major << 24) | ((unsigned long) minor << 16) \
index f94519c898a2f2b823932152ae2210b6fa36fae0..eaaa02a5dbd9153acbefb7e099f0a941ba73f979 100644 (file)
@@ -180,6 +180,14 @@ static int optfn_##a(int, int, boolean, char *, char *);
                 Yes, Yes, No, No, NoAlias,
                 "load DECGraphics display symbols into symset")
 #endif
+    NHOPTB(debug_fuzzer, Advanced, 0, opt_in, set_wiznofuz,
+                Off, Yes, No, No, NoAlias, &iflags.debug_fuzzer)
+    NHOPTB(debug_hunger, Advanced, 0, opt_in, set_wiznofuz,
+                Off, Yes, No, No, NoAlias, &iflags.debug_hunger)
+    NHOPTB(debug_mongen, Advanced, 0, opt_in, set_wiznofuz,
+                Off, Yes, No, No, NoAlias, &iflags.debug_mongen)
+    NHOPTB(debug_overwrite_stairs, Advanced, 0, opt_in, set_wiznofuz,
+                Off, Yes, No, No, NoAlias, &iflags.debug_overwrite_stairs)
     NHOPTC(disclose, Advanced, sizeof flags.end_disclose * 2,
                 opt_in, set_in_game,
                 Yes, Yes, No, Yes, NoAlias,
index 0e47e0c1318b0363a2c4280bd155b7525cd70b17..bf4e75762a782445af5a0a13c43c7e1fa3d9787c 100644 (file)
@@ -4494,6 +4494,10 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op)
         if (!g.opt_initial && (allopt[optidx].setwhere == set_in_config))
             return optn_err;
 
+        /* options that must NOT come from config file */
+        if (g.opt_initial && allopt[optidx].setwhere == set_wiznofuz)
+            return optn_err;
+
         op = string_for_opt(opts, TRUE);
         if (op != empty_optstr) {
             int ln;
@@ -8090,7 +8094,7 @@ doset(void) /* changing options via menu by Per Liboriussen */
     else
 #endif
         startpass = set_gameview;
-    endpass = (wizard) ? set_wizonly : set_in_game;
+    endpass = (wizard) ? set_wiznofuz : set_in_game;
 
     if (!made_fmtstr && !iflags.menu_tab_sep) {
         Sprintf(fmtstr_doset, "%%s%%-%us [%%s]",
@@ -8114,6 +8118,9 @@ doset(void) /* changing options via menu by Per Liboriussen */
                     continue; /* obsolete */
                 if (allopt[i].setwhere == set_wizonly && !wizard)
                     continue;
+                if (allopt[i].setwhere == set_wiznofuz
+                    && (!wizard || iflags.debug_fuzzer))
+                    continue;
                 if ((is_wc_option(name) && !wc_supported(name))
                     || (is_wc2_option(name) && !wc2_supported(name)))
                     continue;
@@ -8729,6 +8736,9 @@ option_help(void)
         if ((allopt[i].opttyp != BoolOpt || !allopt[i].addr)
             || (allopt[i].setwhere == set_wizonly && !wizard))
             continue;
+        if (allopt[i].setwhere == set_wiznofuz
+            && (!wizard || iflags.debug_fuzzer))
+            continue;
         optname = allopt[i].name;
         if ((is_wc_option(optname) && !wc_supported(optname))
             || (is_wc2_option(optname) && !wc2_supported(optname)))
@@ -8743,6 +8753,9 @@ option_help(void)
         if (allopt[i].opttyp != CompOpt
             || (allopt[i].setwhere == set_wizonly && !wizard))
             continue;
+        if (allopt[i].setwhere == set_wiznofuz
+            && (!wizard || iflags.debug_fuzzer))
+            continue;
         optname = allopt[i].name;
         if ((is_wc_option(optname) && !wc_supported(optname))
             || (is_wc2_option(optname) && !wc2_supported(optname)))