shithub: puzzles

Download patch

ref: 78af0c821aa01f9e4a127b5b5f197fd1c8a22686
parent: 6d4b20c413811a9f88e5be97128b7dd6445bff08
author: Ben Harris <bjh21@bjh21.me.uk>
date: Tue Aug 8 05:35:06 EDT 2023

Guess: move hold marker upward by two pixels

This means that it now potentially overlaps the peg above it (part of
the current guess), rather than potentially overlapping the empty hole
below.  More importantly, it means that the hold marker is erased by
the erasure of the rest of the peg area, so there's no need to
explicitly draw absent hold markers in the background colour.  That in
turn means that absent hold markers don't nibble the tops off all the
pegs at some tile sizes.

Instead of this fix, I could have properly made the hold markers part
of the first row of empty holes, but that would have been rather
fiddly and I've long thought that the hold markers were too far from
the peg that they're holding.

I've also removed part of a comment about the drawing order of hold
markers that seems to have been obsolete even before this commit.

--- a/guess.c
+++ b/guess.c
@@ -1291,15 +1291,17 @@
         if ((dest->pegs[i] != scol) || force) {
 	    draw_peg(dr, ds, rowx + PEGOFF * i, rowy, false, labelled,
                      scol &~ 0x7000);
+            if (scol & 0x1000)
+                draw_cursor(dr, ds, rowx + PEGOFF * i, rowy);
             /*
              * Hold marker.
              */
-            draw_rect(dr, rowx + PEGOFF * i, rowy + PEGSZ + ds->gapsz/2,
-                      PEGSZ, 2, (scol & 0x2000 ? COL_HOLD : COL_BACKGROUND));
-            draw_update(dr, rowx + PEGOFF * i, rowy + PEGSZ + ds->gapsz/2,
-                        PEGSZ, 2);
-            if (scol & 0x1000)
-                draw_cursor(dr, ds, rowx + PEGOFF * i, rowy);
+            if (scol & 0x2000) {
+                draw_rect(dr, rowx + PEGOFF * i,
+                          rowy + PEGSZ + ds->gapsz/2 - 2, PEGSZ, 2, COL_HOLD);
+            }
+            draw_update(dr, rowx + PEGOFF * i,
+                        rowy + PEGSZ + ds->gapsz/2 - 2, PEGSZ, 2);
         }
         dest->pegs[i] = scol;
     }
@@ -1424,8 +1426,7 @@
         }
     }
 
-    /* draw the guesses (so far) and the hints
-     * (in reverse order to avoid trampling holds, and postponing the
+    /* draw the guesses (so far) and the hints (postponing the
      * next_go'th to not overrender the top of the circular cursor) */
     for (i = state->params.nguesses - 1; i >= 0; i--) {
         if (i < state->next_go || state->solved) {