diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-01-09 20:24:15 +0000 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-01-15 16:24:27 +0000 |
| commit | 5782e29db43034574763b1d10c48486c3e95f0d2 (patch) | |
| tree | 55d341a03b2dd46f673cb560a8b97fcb198579f4 /tracks.c | |
| parent | 15974d06bbaad287382c6eeb8deb7c6f3a627278 (diff) | |
| download | puzzles-5782e29db43034574763b1d10c48486c3e95f0d2.zip puzzles-5782e29db43034574763b1d10c48486c3e95f0d2.tar.gz puzzles-5782e29db43034574763b1d10c48486c3e95f0d2.tar.bz2 puzzles-5782e29db43034574763b1d10c48486c3e95f0d2.tar.xz | |
Tracks: make sure moves are valid in execute_move()
Tracks allowed moves in execute_move() that shouldn't have been allowed,
like changing the state of the edges of the board. This moves couldn't
be generated by interpret_move(), but could be loaded from a save file.
Now execute_move() uses the same ui_can_flip_*() functions as
interpret_move() to decide whether a particular move is allowed. This
should prevent some assertion failures when loading corrupted save
files.
Diffstat (limited to 'tracks.c')
| -rw-r--r-- | tracks.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -2429,6 +2429,8 @@ static game_state *execute_move(const game_state *state, const char *move) f = (c == 'T' || c == 't') ? S_TRACK : S_NOTRACK; if (d == 'S') { + if (!ui_can_flip_square(ret, x, y, f == S_NOTRACK)) + goto badmove; if (c == 'T' || c == 'N') ret->sflags[y*w+x] |= f; else @@ -2438,6 +2440,8 @@ static game_state *execute_move(const game_state *state, const char *move) unsigned df = 1<<i; if (MOVECHAR(df) == d) { + if (!ui_can_flip_edge(ret, x, y, df, f == S_NOTRACK)) + goto badmove; if (c == 'T' || c == 'N') S_E_SET(ret, x, y, df, f); else |