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:
nhmall
2019-11-30 11:44:07 -05:00
parent 49e4dfbc0f
commit 42a13a1198
18 changed files with 62 additions and 24 deletions
+3 -1
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,