]> granicus.if.org Git - nethack/commitdiff
'color' in simple options menu
authorPatR <rankin@nethack.org>
Fri, 19 Aug 2022 21:54:59 +0000 (14:54 -0700)
committerPatR <rankin@nethack.org>
Fri, 19 Aug 2022 21:54:59 +0000 (14:54 -0700)
'color' appears in the simplified O menu for curses, but was not
showing up for tty.  That's because it is hidden when tiles are in
use, and tty has had a bogus value for iflags.wc_tiled_map.

Presence of USE_TILES is not a reliable way to tell whether tiles
are available in a multi-interface binary.  Nor is the setting of
DEFAULT_WC_TILED_MAP from config.h.

include/optlist.h
src/options.c

index eaaa02a5dbd9153acbefb7e099f0a941ba73f979..a301502361212e985bd03f16fa73071520a859bf 100644 (file)
@@ -78,6 +78,8 @@ static int optfn_##a(int, int, boolean, char *, char *);
     { m, OptS_##sec, 0, b, opt_##a, s, OthrOpt, n, v, d, No, c,         \
       (boolean *) 0, &optfn_##a, al, z, (const char *) 0, On, On, 0 },
 
+/* this is not reliable because USE_TILES might be defined in a
+   multi-interface binary but not apply to the current interface */
 #ifdef USE_TILES
 #define tiled_map_Def On
 #define ascii_map_Def Off
index 0ce353274539a9dae0bc2aace157c14edd1a1644..7563acf120b27800dbfc6c835f18d32929794d16 100644 (file)
@@ -72,12 +72,6 @@ static struct allopt_t allopt_init[] = {
 #undef NHOPT_PARSE
 
 
-#if defined(USE_TILES) && defined(DEFAULT_WC_TILED_MAP)
-#define PREFER_TILED TRUE
-#else
-#define PREFER_TILED FALSE
-#endif
-
 #define PILE_LIMIT_DFLT 5
 #define rolestring(val, array, field) \
     ((val >= 0) ? array[val].field : (val == ROLE_RANDOM) ? randomrole : none)
@@ -6461,6 +6455,17 @@ initoptions_finish(void)
     }
 #endif
     update_rest_on_space();
+
+    /* these can't rely on compile-time initialization for their defaults
+       because a multi-interface binary might need different values for
+       different interfaces; if neither tiled_map nor ascii_map pass the
+       wc_supported() test, assume ascii_map */
+    if (iflags.wc_tiled_map && !wc_supported("tiled_map"))
+        iflags.wc_tiled_map = FALSE, iflags.wc_ascii_map = TRUE;
+    else if (iflags.wc_ascii_map && !wc_supported("ascii_map")
+             && wc_supported("tiled_map"))
+        iflags.wc_ascii_map = FALSE, iflags.wc_tiled_map = TRUE;
+
 #ifdef ENHANCED_SYMBOLS
     if (glyphid_cache_status())
         free_glyphid_cache();