From a533350537e1bb355622014c88ecfebd09d58350 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 15 May 2026 20:21:48 +0300 Subject: [PATCH] TTY: allow custom glyph colors on more limited terminals Previously changing glyph colors required a terminal with more than 256 colors, even if the color was one of the basic 16 colors used by NetHack. --- doc/fixes5-0-1.txt | 2 ++ win/tty/wintty.c | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/fixes5-0-1.txt b/doc/fixes5-0-1.txt index 3cacb63c0..6cd737192 100644 --- a/doc/fixes5-0-1.txt +++ b/doc/fixes5-0-1.txt @@ -114,6 +114,8 @@ Windows: correct a NetHack 5.0.0 packaging error if visual studio was used; a remnant hard-coded 370 was in package.nmake Windows: setting any map_mode option in the config file could trigger an app failure on launch by dereferencing a null pointer +tty: allow custom glyph colors if they're basic 16 nethack colors + on terminals with less than 256 colors General New Features diff --git a/win/tty/wintty.c b/win/tty/wintty.c index c9bdd4b06..68cce5c6a 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -3897,18 +3897,17 @@ tty_print_glyph( if (ttyDisplay->color != NO_COLOR) term_end_color(); } - /* we don't link with termcap.o if NO_TERMS is defined */ - if ((tty_procs.wincap2 & WC2_EXTRACOLORS) - && glyphinfo->gm.customcolor != 0 - && iflags.colorcount >= 256 + if (glyphinfo->gm.customcolor != 0 && !calling_from_update_inventory) { - if ((glyphinfo->gm.customcolor & NH_BASIC_COLOR) == 0) { + if ((glyphinfo->gm.customcolor & NH_BASIC_COLOR) != 0) { + /* NH_BASIC_COLOR */ + color = COLORVAL(glyphinfo->gm.customcolor); + } else if ((tty_procs.wincap2 & WC2_EXTRACOLORS) + && iflags.colorcount >= 256) { term_start_extracolor(glyphinfo->gm.customcolor, glyphinfo->gm.color256idx); ttyDisplay->colorflags = 0; colordone = TRUE; - } else { - color = COLORVAL(glyphinfo->gm.customcolor); } } if (!colordone) {