Merge branch 'NetHack-3.6'

This commit is contained in:
nhmall
2019-11-30 15:41:52 -05:00
22 changed files with 102 additions and 63 deletions

View File

@@ -315,6 +315,11 @@ clairvoyance showed all monsters in range, then after player viewed the map,
object at same spot, so skip it for locations where monster refresh
is going to immediately redisplay a monster
take holes that you avoided into consideration when you're on the brink
update window port spec to include a color-availability table that the window
port can set; merge all has_color() implementations into one central
function in src/windows.c which uses a few data checks only and
elminates multiple string function calls for each map cell update
that were being done in some cases previously
unix: fix double DLB definition in linux hints file
windows: fix --showpaths output for the data file which relies on being
constructed programmatically to incorporate the version suffix

View File

@@ -663,6 +663,10 @@ port can access the fields directly.
Your window port identifies what options it will react to and support
by setting bits in the window_procs wincap mask and/or wincap2 mask.
Your window port can also fill in the color-availability table for
the window port, has_color[CLR_MAX] to flag the colors it supports
1 it does, or 0 it doesn't. [CLR_MAX is 16 as of 3.6.3.]
See section IX for details of where the wincap masks reside.
Two things control whether any preference setting appears in the

View File

@@ -14,6 +14,7 @@ struct window_procs {
* '+' are reserved for processors. */
unsigned long wincap; /* window port capability options supported */
unsigned long wincap2; /* additional window port capability options */
boolean has_color[CLR_MAX];
void FDECL((*win_init_nhwindows), (int *, char **));
void NDECL((*win_player_selection));
void NDECL((*win_askname));

View File

@@ -245,16 +245,11 @@ unsigned mgflags;
#ifdef TEXTCOLOR
/* Turn off color if no color defined, or rogue level w/o PC graphics. */
if (!has_color(color) || (Is_rogue_level(&u.uz) && !has_rogue_color))
color = NO_COLOR;
#endif
color = NO_COLOR;
*ochar = (int) ch;
*ospecial = special;
#ifdef TEXTCOLOR
*ocolor = color;
#else
nhUse(ocolor);
#endif
return idx;
}

View File

@@ -107,11 +107,7 @@ static const struct Bool_Opt {
#endif
{ "clicklook", &iflags.clicklook, FALSE, SET_IN_GAME },
{ "cmdassist", &iflags.cmdassist, TRUE, SET_IN_GAME },
#if defined(MICRO) || defined(WIN32) || defined(CURSES_GRAPHICS)
{ "color", &iflags.wc_color, TRUE, SET_IN_GAME }, /*WC*/
#else /* systems that support multiple terminals, many monochrome */
{ "color", &iflags.wc_color, FALSE, SET_IN_GAME }, /*WC*/
#endif
{ "color", &iflags.wc_color, TRUE, SET_IN_GAME }, /* on/off: use WC or not */
{ "confirm", &flags.confirm, TRUE, SET_IN_GAME },
{ "dark_room", &flags.dark_room, TRUE, SET_IN_GAME },
{ "eight_bit_tty", &iflags.wc_eight_bit_input, FALSE, SET_IN_GAME }, /*WC*/

View File

@@ -523,7 +523,9 @@ static void FDECL(hup_void_fdecl_winid, (winid));
static void FDECL(hup_void_fdecl_constchar_p, (const char *));
static struct window_procs hup_procs = {
"hup", 0L, 0L, hup_init_nhwindows,
"hup", 0L, 0L,
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
hup_init_nhwindows,
hup_void_ndecl, /* player_selection */
hup_void_ndecl, /* askname */
hup_void_ndecl, /* get_nh_event */
@@ -1371,4 +1373,28 @@ boolean onoff_flag;
}
}
#ifdef TTY_GRAPHICS
#ifdef TEXTCOLOR
#ifdef TOS
extern const char *hilites[CLR_MAX];
#else
extern NEARDATA char *hilites[CLR_MAX];
#endif
#endif
#endif
int
has_color(color)
int color;
{
return (iflags.use_color && windowprocs.name
&& (windowprocs.wincap & WC_COLOR) && windowprocs.has_color[color]
#ifdef TTY_GRAPHICS
#if defined(TEXTCOLOR) && defined(TERMLIB) && !defined(NO_TERMS)
&& (hilites[color] != 0)
#endif
#endif
);
}
/*windows.c*/

View File

@@ -28,7 +28,9 @@ long amii_scrnmode;
* the intuition interface for the amiga...
*/
struct window_procs amii_procs = {
"amii", WC_COLOR | WC_HILITE_PET | WC_INVERSE, 0L, amii_init_nhwindows,
"amii", WC_COLOR | WC_HILITE_PET | WC_INVERSE,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
0L, amii_init_nhwindows,
amii_player_selection, amii_askname, amii_get_nh_event,
amii_exit_nhwindows, amii_suspend_nhwindows, amii_resume_nhwindows,
amii_create_nhwindow, amii_clear_nhwindow, amii_display_nhwindow,
@@ -60,7 +62,9 @@ struct window_procs amii_procs = {
* a shared library to allow the executable to be smaller.
*/
struct window_procs amiv_procs = {
"amitile", WC_COLOR | WC_HILITE_PET | WC_INVERSE, 0L, amii_init_nhwindows,
"amitile", WC_COLOR | WC_HILITE_PET | WC_INVERSE,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
0L, amii_init_nhwindows,
amii_player_selection, amii_askname, amii_get_nh_event,
amii_exit_nhwindows, amii_suspend_nhwindows, amii_resume_nhwindows,
amii_create_nhwindow, amii_clear_nhwindow, amii_display_nhwindow,

View File

@@ -3251,7 +3251,9 @@ struct window_procs mac_procs = {
WC_COLOR | WC_HILITE_PET | WC_FONT_MAP | WC_FONT_MENU | WC_FONT_MESSAGE
| WC_FONT_STATUS | WC_FONT_TEXT | WC_FONTSIZ_MAP | WC_FONTSIZ_MENU
| WC_FONTSIZ_MESSAGE | WC_FONTSIZ_STATUS | WC_FONTSIZ_TEXT,
0L, mac_init_nhwindows,
0L,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
mac_init_nhwindows,
mac_unimplemented, /* see macmenu.c:mac_askname() for player selection */
mac_askname, mac_get_nh_event, mac_exit_nhwindows, mac_suspend_nhwindows,
mac_unimplemented, mac_create_nhwindow, mac_clear_nhwindow,

View File

@@ -269,6 +269,33 @@ _mt_init_stuff(void)
clear_tty(_mt_window);
InitMenuRes();
{
/* update the window proc has_color table */
int i, setting = 0;
Rect r;
// Point p = {0, 0};
GDHandle gh = (GDHandle) 0;
if (_mt_in_color) {
GetWindowBounds(_mt_window, kWindowContentRgn, &r);
// SetPortWindowPort(_mt_window);
// LocalToGlobal (&p);
// OffsetRect (&r, p.h, p.v);
gh = GetMaxDevice(&r);
/* > 4 bpp */
setting = ((*((*gh)->gdPMap))->pixelSize > 4) ? 1 : 0;
}
for (i = 0; i < CLR_MAX ; ++i) {
tty_procs.has_color[i] =
(i == CLR_BLACK || i == NO_COLOR || i == CLR_WHITE)
? 1
: (_mt_in_color && gh)
? setting
: 0;
}
}
}
int
@@ -302,6 +329,8 @@ getreturn(char *str)
(void) tgetch();
}
#if 0 /* this function is commented out */
/* the tty has_color[] table is filled in during init above */
int
has_color(int color)
{
@@ -327,6 +356,7 @@ has_color(int color)
return (*((*gh)->gdPMap))->pixelSize > 4; /* > 4 bpp */
}
#endif
void
tty_delay_output(void)

View File

@@ -50,6 +50,7 @@ struct window_procs mswin_procs = {
| WC_TILE_WIDTH | WC_TILE_HEIGHT | WC_TILE_FILE | WC_VARY_MSGCOUNT
| WC_WINDOWCOLORS | WC_PLAYER_SELECTION,
WC2_FULLSCREEN | WC2_SOFTKEYBOARD | WC2_WRAPTEXT, mswin_init_nhwindows,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
mswin_player_selection, mswin_askname, mswin_get_nh_event,
mswin_exit_nhwindows, mswin_suspend_nhwindows, mswin_resume_nhwindows,
mswin_create_nhwindow, mswin_clear_nhwindow, mswin_display_nhwindow,

View File

@@ -722,7 +722,6 @@ tty_delay_output()
}
}
#ifdef TEXTCOLOR
/*
* CLR_BLACK 0
* CLR_RED 1
@@ -795,10 +794,10 @@ init_ttycolor()
#endif
init_ttycolor_completed = TRUE;
}
#endif /* TEXTCOLOR */
#if 0
int
has_color(int color)
has_color(int color) /* this function is commented out */
{
#ifdef TEXTCOLOR
if ((color >= 0) && (color < CLR_MAX))
@@ -810,6 +809,7 @@ has_color(int color)
else
return 0;
}
#endif
int
term_attr_fixup(int attrmask)

View File

@@ -114,12 +114,6 @@ backsp()
return;
}
int
has_color(int color)
{
return 1;
}
#ifndef NO_MOUSE_ALLOWED
void
toggle_mouse_support()

View File

@@ -5229,6 +5229,7 @@ struct window_procs Qt_procs = {
WC_FONT_MAP|WC_TILE_FILE|WC_TILE_WIDTH|WC_TILE_HEIGHT|
WC_PLAYER_SELECTION|WC_SPLASH_SCREEN,
0L,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
NetHackQtBind::qt_init_nhwindows,
NetHackQtBind::qt_player_selection,
NetHackQtBind::qt_askname,

View File

@@ -730,6 +730,7 @@ struct window_procs Qt_procs = {
| WC_FONT_MAP | WC_TILE_FILE | WC_TILE_WIDTH | WC_TILE_HEIGHT
| WC_PLAYER_SELECTION | WC_SPLASH_SCREEN,
0L,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
nethack_qt4::NetHackQtBind::qt_init_nhwindows,
nethack_qt4::NetHackQtBind::qt_player_selection,
nethack_qt4::NetHackQtBind::qt_askname,

View File

@@ -107,6 +107,7 @@ struct window_procs X11_procs = {
WC2_FLUSH_STATUS | WC2_RESET_STATUS | WC2_HILITE_STATUS |
#endif
0L,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
X11_init_nhwindows,
X11_player_selection, X11_askname, X11_get_nh_event, X11_exit_nhwindows,
X11_suspend_nhwindows, X11_resume_nhwindows, X11_create_nhwindow,

View File

@@ -51,6 +51,7 @@ struct window_procs curses_procs = {
| WC2_FLUSH_STATUS | WC2_TERM_SIZE
| WC2_STATUSLINES | WC2_WINDOWBORDERS | WC2_PETATTR | WC2_GUICOLOR
| WC2_SUPPRESS_HIST),
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
curses_init_nhwindows,
curses_player_selection,
curses_askname,

View File

@@ -43,7 +43,9 @@ struct window_procs Gem_procs = {
| WC_FONT_TEXT | WC_FONT_MAP | WC_FONTSIZ_MESSAGE | WC_FONTSIZ_STATUS
| WC_FONTSIZ_MENU | WC_FONTSIZ_TEXT | WC_FONTSIZ_MAP | WC_TILE_WIDTH
| WC_TILE_HEIGHT | WC_TILE_FILE | WC_VARY_MSGCOUNT | WC_ASCII_MAP,
0L, Gem_init_nhwindows, Gem_player_selection, Gem_askname,
0L,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
Gem_init_nhwindows, Gem_player_selection, Gem_askname,
Gem_get_nh_event, Gem_exit_nhwindows, Gem_suspend_nhwindows,
Gem_resume_nhwindows, Gem_create_nhwindow, Gem_clear_nhwindow,
Gem_display_nhwindow, Gem_destroy_nhwindow, Gem_curs, Gem_putstr,

View File

@@ -24,7 +24,9 @@ extern NEARDATA winid WIN_STATUS;
/* Interface definition, for windows.c */
struct window_procs Gnome_procs = {
"Gnome", WC_COLOR | WC_HILITE_PET | WC_INVERSE, 0L, gnome_init_nhwindows,
"Gnome", WC_COLOR | WC_HILITE_PET | WC_INVERSE, 0L,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
gnome_init_nhwindows,
gnome_player_selection, gnome_askname, gnome_get_nh_event,
gnome_exit_nhwindows, gnome_suspend_nhwindows, gnome_resume_nhwindows,
gnome_create_nhwindow, gnome_clear_nhwindow, gnome_display_nhwindow,

View File

@@ -67,6 +67,7 @@
struct window_procs safe_procs = {
"safe-startup", 0L, 0L,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
safe_init_nhwindows, safe_player_selection, safe_askname, safe_get_nh_event,
safe_exit_nhwindows, safe_suspend_nhwindows, safe_resume_nhwindows,
safe_create_nhwindow, safe_clear_nhwindow, safe_display_nhwindow,

View File

@@ -1282,41 +1282,6 @@ int color;
xputs(hilites[color]);
}
/* not to be confused with has_colors() in unixtty.c */
int
has_color(color)
int color;
{
#ifdef X11_GRAPHICS
/* XXX has_color() should be added to windowprocs */
if (windowprocs.name != NULL && !strcmpi(windowprocs.name, "X11"))
return 1;
#endif
#ifdef GEM_GRAPHICS
/* XXX has_color() should be added to windowprocs */
if (windowprocs.name != NULL && !strcmpi(windowprocs.name, "Gem"))
return 1;
#endif
#ifdef QT_GRAPHICS
/* XXX has_color() should be added to windowprocs */
if (windowprocs.name != NULL && !strcmpi(windowprocs.name, "Qt"))
return 1;
#endif
#ifdef CURSES_GRAPHICS
/* XXX has_color() should be added to windowprocs */
/* iflags.wc_color is set to false and the option disabled if the
terminal cannot display color */
if (windowprocs.name != NULL && !strcmpi(windowprocs.name, "curses"))
return iflags.wc_color;
#endif
#ifdef AMII_GRAPHICS
/* hilites[] not used */
return iflags.use_color ? 1 : 0;
#else
return hilites[color] != (char *) 0;
#endif
}
#endif /* TEXTCOLOR */
#endif /* TTY_GRAPHICS && !NO_TERMS */

View File

@@ -95,6 +95,11 @@ struct window_procs tty_procs = {
| WC2_RESET_STATUS
#endif
| WC2_DARKGRAY | WC2_SUPPRESS_HIST | WC2_STATUSLINES),
#ifdef TEXTCOLOR
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
#else
{1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1},
#endif
tty_init_nhwindows, tty_player_selection, tty_askname, tty_get_nh_event,
tty_exit_nhwindows, tty_suspend_nhwindows, tty_resume_nhwindows,
tty_create_nhwindow, tty_clear_nhwindow, tty_display_nhwindow,
@@ -4304,7 +4309,7 @@ unsigned long *bmarray;
the condition where this gets used always has the same value */
#define condcolor(bm,bmarray) NO_COLOR
#define term_start_color(color) /*empty*/
#define term_end_color(color) /*empty*/
#define term_end_color() /*empty*/
#endif /* TEXTCOLOR */
static int

View File

@@ -90,7 +90,9 @@ struct window_procs mswin_procs = {
#ifdef STATUS_HILITES
WC2_HITPOINTBAR | WC2_FLUSH_STATUS | WC2_RESET_STATUS | WC2_HILITE_STATUS |
#endif
0L, mswin_init_nhwindows, mswin_player_selection, mswin_askname,
0L,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
mswin_init_nhwindows, mswin_player_selection, mswin_askname,
mswin_get_nh_event, mswin_exit_nhwindows, mswin_suspend_nhwindows,
mswin_resume_nhwindows, mswin_create_nhwindow, mswin_clear_nhwindow,
mswin_display_nhwindow, mswin_destroy_nhwindow, mswin_curs, mswin_putstr,