mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
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.
This commit is contained in:
5
flood.c
5
flood.c
@ -945,6 +945,11 @@ static game_state *execute_move(const game_state *state, const char *move)
|
|||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
sol->moves[i] = atoi(p);
|
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");
|
p += strspn(p, "0123456789");
|
||||||
if (*p) {
|
if (*p) {
|
||||||
if (*p != ',') goto badsolve;
|
if (*p != ',') goto badsolve;
|
||||||
|
Reference in New Issue
Block a user