has_color() performance fixes
Performance profiling showed that multiple strcmpi() calls were occurring each and every time a character was going to the map. This update: - honors the WC_COLOR capability - It allows a window-port to control individual color availability should the window-port wish to do so. - Makes checking on the individual colors for the active window-port is a straightforward table lookup at the CLR_ offset. iflags.use_color remains a master on/off switch for use of color, regardless of the capability compiled into the game (default TRUE). The has_color() routine, which is now a shared routine in src/windows.c, could likely be made into a simple macro to eliminate the function call, but this update does not go that far. This hits a lot of port files due to the window-port interface change, mostly cookie-cutter.
This commit is contained in:
@@ -525,7 +525,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 */
|
||||
@@ -1373,4 +1375,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*/
|
||||
|
||||
Reference in New Issue
Block a user