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.
This commit is contained in:
Pasi Kallinen
2026-05-15 20:21:52 +03:00
parent e05864544c
commit a533350537
2 changed files with 8 additions and 7 deletions
+2
View File
@@ -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 used; a remnant hard-coded 370 was in package.nmake
Windows: setting any map_mode option in the config file could trigger Windows: setting any map_mode option in the config file could trigger
an app failure on launch by dereferencing a null pointer 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 General New Features
+6 -7
View File
@@ -3897,18 +3897,17 @@ tty_print_glyph(
if (ttyDisplay->color != NO_COLOR) if (ttyDisplay->color != NO_COLOR)
term_end_color(); term_end_color();
} }
/* we don't link with termcap.o if NO_TERMS is defined */ if (glyphinfo->gm.customcolor != 0
if ((tty_procs.wincap2 & WC2_EXTRACOLORS)
&& glyphinfo->gm.customcolor != 0
&& iflags.colorcount >= 256
&& !calling_from_update_inventory) { && !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, term_start_extracolor(glyphinfo->gm.customcolor,
glyphinfo->gm.color256idx); glyphinfo->gm.color256idx);
ttyDisplay->colorflags = 0; ttyDisplay->colorflags = 0;
colordone = TRUE; colordone = TRUE;
} else {
color = COLORVAL(glyphinfo->gm.customcolor);
} }
} }
if (!colordone) { if (!colordone) {