shithub: puzzles

Download patch

ref: 562b29e102cdfa019b0f9d79e105f3f7d7e7bb0e
parent: 712abb7719440e132750fedf1bab60db9c1023fd
author: Ben Harris <bjh21@bjh21.me.uk>
date: Mon Dec 12 16:15:37 EST 2022

Don't request a highlight colour in games that don't need one

This means that Range, Singles, and Tracks can now use the default
background colour even if it's close to white.  In the case of Singles
I've left a dummy entry in the colour list so as not to renumber the
rest and break everyone's environment variables.  If Singles ever needs
a new colour it can re-use that slot.

--- a/range.c
+++ b/range.c
@@ -1624,7 +1624,6 @@
     COL_USER = COL_GRID,
     COL_ERROR,
     COL_LOWLIGHT,
-    COL_HIGHLIGHT = COL_ERROR, /* mkhighlight needs it, I don't */
     COL_CURSOR = COL_LOWLIGHT,
     NCOLOURS
 };
@@ -1649,7 +1648,7 @@
 {
     float *ret = snewn(3 * NCOLOURS, float);
 
-    game_mkhighlight(fe, ret, COL_BACKGROUND, COL_HIGHLIGHT, COL_LOWLIGHT);
+    game_mkhighlight(fe, ret, COL_BACKGROUND, -1, COL_LOWLIGHT);
     COLOUR(ret, COL_GRID,  0.0F, 0.0F, 0.0F);
     COLOUR(ret, COL_ERROR, 1.0F, 0.0F, 0.0F);
 
--- a/singles.c
+++ b/singles.c
@@ -82,7 +82,7 @@
 #define FLASH_TIME 0.7F
 
 enum {
-    COL_BACKGROUND, COL_HIGHLIGHT, COL_LOWLIGHT,
+    COL_BACKGROUND, COL_UNUSED1, COL_LOWLIGHT,
     COL_BLACK, COL_WHITE, COL_BLACKNUM, COL_GRID,
     COL_CURSOR, COL_ERROR,
     NCOLOURS
@@ -1620,12 +1620,13 @@
     float *ret = snewn(3 * NCOLOURS, float);
     int i;
 
-    game_mkhighlight(fe, ret, COL_BACKGROUND, COL_HIGHLIGHT, COL_LOWLIGHT);
+    game_mkhighlight(fe, ret, COL_BACKGROUND, -1, COL_LOWLIGHT);
     for (i = 0; i < 3; i++) {
         ret[COL_BLACK * 3 + i] = 0.0F;
         ret[COL_BLACKNUM * 3 + i] = 0.4F;
         ret[COL_WHITE * 3 + i] = 1.0F;
         ret[COL_GRID * 3 + i] = ret[COL_LOWLIGHT * 3 + i];
+        ret[COL_UNUSED1 * 3 + i] = 0.0F; /* To placate an assertion. */
     }
     ret[COL_CURSOR * 3 + 0] = 0.2F;
     ret[COL_CURSOR * 3 + 1] = 0.8F;
--- a/tracks.c
+++ b/tracks.c
@@ -2463,8 +2463,7 @@
 }
 
 enum {
-    COL_BACKGROUND, COL_LOWLIGHT, COL_HIGHLIGHT,
-    COL_TRACK_BACKGROUND = COL_LOWLIGHT,
+    COL_BACKGROUND, COL_TRACK_BACKGROUND,
     COL_GRID, COL_CLUE, COL_CURSOR,
     COL_TRACK, COL_TRACK_CLUE, COL_SLEEPER,
     COL_DRAGON, COL_DRAGOFF,
@@ -2477,7 +2476,7 @@
     float *ret = snewn(3 * NCOLOURS, float);
     int i;
 
-    game_mkhighlight(fe, ret, COL_BACKGROUND, COL_HIGHLIGHT, COL_LOWLIGHT);
+    game_mkhighlight(fe, ret, COL_BACKGROUND, -1, COL_TRACK_BACKGROUND);
 
     for (i = 0; i < 3; i++) {
         ret[COL_TRACK_CLUE       * 3 + i] = 0.0F;