shithub: puzzles

Download patch

ref: e8668dc883e940f0852ff4520abc3d30cae90aef
parent: c3a5a7842eb6c41fb75a8a110a3f2cbc1c8fc5d9
author: Ben Harris <[email protected]>
date: Sun Feb 12 19:00:30 EST 2023

More validation of solve moves in Flood

To avoid assertion failures while painting it, we need to ensure that
the purported solution in a solve move doesn't include filling with the
current top-left colour at any point.  That means checking the first
entry against the current top-left colours, and each later one against
its predecessor.

--- a/flood.c
+++ b/flood.c
@@ -945,6 +945,11 @@
                 return NULL;
             };
             sol->moves[i] = atoi(p);
+            if (i == 0 ?
+                sol->moves[i] == state->grid[FILLY * state->w + FILLX] :
+                sol->moves[i] == sol->moves[i-1])
+                /* Solution contains a fill with the current colour. */
+                goto badsolve;
             p += strspn(p, "0123456789");
             if (*p) {
                 if (*p != ',') goto badsolve;