aboutsummaryrefslogtreecommitdiff
path: root/flood.c
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-02-13 00:00:30 +0000
committerBen Harris <bjh21@bjh21.me.uk>2023-02-13 21:23:58 +0000
commite8668dc883e940f0852ff4520abc3d30cae90aef (patch)
treec2256257636b9527a9ff2a97b8f4f0f07f205f53 /flood.c
parentc3a5a7842eb6c41fb75a8a110a3f2cbc1c8fc5d9 (diff)
downloadpuzzles-e8668dc883e940f0852ff4520abc3d30cae90aef.zip
puzzles-e8668dc883e940f0852ff4520abc3d30cae90aef.tar.gz
puzzles-e8668dc883e940f0852ff4520abc3d30cae90aef.tar.bz2
puzzles-e8668dc883e940f0852ff4520abc3d30cae90aef.tar.xz
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.
Diffstat (limited to 'flood.c')
-rw-r--r--flood.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/flood.c b/flood.c
index f1ac5e1..7a83e52 100644
--- a/flood.c
+++ b/flood.c
@@ -945,6 +945,11 @@ static game_state *execute_move(const game_state *state, const char *move)
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;