From: PatR Date: Sat, 28 May 2016 07:51:54 +0000 (-0700) Subject: black&white lava X-Git-Tag: NetHack-3.6.1_RC01~733 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6459b5d30112d4a9972a5b5adf88a92fe95a87c7;p=nethack black&white lava Add MG_BW_LAVA to mapglyph() instead of hijacking MG_DETECT. Used to display lava in inverse video if color is disabled and lava is using the same display character as water (which is the default). (The use_inverse option must be enabled for tty to honor it. X11's text mode doesn't care. Win32 does care but probably shouldn't--it's not a case like tty where the hardware might not support it.) This implements both MG_DETECT and MG_BW_LAVA for X11, but only if the program is built with TEXTCOLOR enabled. Those should work even when color is not supported, but I suspect that configuration is unlikely to ever be used so didn't want to spend the time to figure out how to do it. (The relevant data is overloaded on the color data, so not available when TEXTCOLOR is disabled.) The win32 revision is untested. --- diff --git a/include/hack.h b/include/hack.h index fb25a1672..eeb5ce3e6 100644 --- a/include/hack.h +++ b/include/hack.h @@ -57,13 +57,15 @@ #define DISMOUNT_BYCHOICE 6 /* Special returns from mapglyph() */ -#define MG_CORPSE 0x01 -#define MG_INVIS 0x02 -#define MG_DETECT 0x04 -#define MG_PET 0x08 -#define MG_RIDDEN 0x10 -#define MG_STATUE 0x20 +#define MG_CORPSE 0x01 +#define MG_INVIS 0x02 +#define MG_DETECT 0x04 +#define MG_PET 0x08 +#define MG_RIDDEN 0x10 +#define MG_STATUE 0x20 #define MG_OBJPILE 0x40 /* more than one stack of objects */ +#define MG_BW_LAVA 0x80 /* 'black & white lava': highlight lava if it + can't be distringuished from water by color */ /* sellobj_state() states */ #define SELL_NORMAL (0) diff --git a/src/mapglyph.c b/src/mapglyph.c index c0c640164..dab688620 100644 --- a/src/mapglyph.c +++ b/src/mapglyph.c @@ -134,9 +134,7 @@ unsigned *ospecial; } else if (!iflags.use_color && offset == S_lava && (showsyms[idx] == showsyms[S_pool + SYM_OFF_P] || showsyms[idx] == showsyms[S_water + SYM_OFF_P])) { - /* temporary? hack; makes tty use inverse video if the - corresponding boolean option is enabled */ - special |= MG_DETECT; + special |= MG_BW_LAVA; } else { cmap_color(offset); } diff --git a/win/X11/winmap.c b/win/X11/winmap.c index bd7639e03..ec5e5fa4a 100644 --- a/win/X11/winmap.c +++ b/win/X11/winmap.c @@ -124,8 +124,9 @@ int bkglyph UNUSED; } #ifdef TEXTCOLOR co_ptr = &map_info->text_map.colors[y][x]; - colordif = (((special & MG_PET) && iflags.hilite_pet) - || ((special & MG_OBJPILE) && iflags.hilite_pile)) + colordif = (((special & MG_PET) != 0 && iflags.hilite_pet) + || ((special & MG_OBJPILE) != 0 && iflags.hilite_pile) + || ((special & (MG_DETECT | MG_BW_LAVA)) != 0)) ? CLR_MAX : 0; if (*co_ptr != (uchar) (color + colordif)) { *co_ptr = (uchar) (color + colordif); @@ -1223,7 +1224,7 @@ XtPointer widget_data; /* expose event from Window widget */ /* * Do the actual work of the putting characters onto our X window. This * is called from the expose event routine, the display window (flush) - * routine, and the display cursor routine. The later involves inverting + * routine, and the display cursor routine. The last involves inverting * the foreground and background colors, which are also inverted when the * position's color is above CLR_MAX. * @@ -1332,7 +1333,7 @@ boolean inverted; struct text_map_info_t *text_map = &map_info->text_map; #ifdef TEXTCOLOR - if (iflags.use_color) { + { register char *c_ptr; char *t_ptr; int cur_col, color, win_ystart; @@ -1359,8 +1360,13 @@ boolean inverted; } XDrawImageString(XtDisplay(wp->w), XtWindow(wp->w), - cur_inv ? text_map->inv_color_gcs[color] - : text_map->color_gcs[color], + iflags.use_color + ? (cur_inv + ? text_map->inv_color_gcs[color] + : text_map->color_gcs[color]) + : (cur_inv + ? text_map->inv_copy_gc + : text_map->copy_gc), text_map->square_lbearing + (text_map->square_width * cur_col), win_ystart, t_ptr, count); @@ -1370,8 +1376,8 @@ boolean inverted; cur_col += count; } /* col loop */ } /* row loop */ - } else -#endif /* TEXTCOLOR */ + } +#else /* !TEXTCOLOR */ { int win_row, win_xstart; @@ -1393,6 +1399,7 @@ boolean inverted; count); } } +#endif /* ?TEXTCOLOR */ } } diff --git a/win/tty/wintty.c b/win/tty/wintty.c index ed7eefd23..8ceb1dc4e 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -3220,7 +3220,8 @@ int bkglyph UNUSED; /* must be after color check; term_end_color may turn off inverse too */ if (((special & MG_PET) && iflags.hilite_pet) || ((special & MG_OBJPILE) && iflags.hilite_pile) - || ((special & MG_DETECT) && iflags.use_inverse)) { + || ((special & MG_DETECT) && iflags.use_inverse) + || ((special & MG_BW_LAVA) && iflags.use_inverse)) { term_start_attr(ATR_INVERSE); reverse_on = TRUE; } diff --git a/win/win32/mhmap.c b/win/win32/mhmap.c index 5e9ac2630..821c91802 100644 --- a/win/win32/mhmap.c +++ b/win/win32/mhmap.c @@ -682,7 +682,7 @@ onPaint(HWND hWnd) &special, i, j); ch = (char) mgch; if (((special & MG_PET) && iflags.hilite_pet) - || ((special & MG_DETECT) + || ((special & (MG_DETECT | MG_BW_LAVA)) && iflags.use_inverse)) { back_brush = CreateSolidBrush(nhcolor_to_RGB(CLR_GRAY));