From e8668dc883e940f0852ff4520abc3d30cae90aef Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 13 Feb 2023 00:00:30 +0000 Subject: [PATCH] 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. --- flood.c | 5 +++++ 1 file changed, 5 insertions(+) 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;