Skip to content

Commit

Permalink
Tracks: let solve make illegal moves
Browse files Browse the repository at this point in the history
Not only does it set the outer edges to NOTRACK, but it may also overwrite
any mistakes the user has previously made elsewhere. Otherwise, the entire
solve is rejected ("Solve unavailable" error on Android) if the user has
made a single mistake, which is inconsistent with the other games.

This may be giving a free pass to corrupted moves that occur after a solve,
so this may still want tightening up in some way, but it's still limited to
squares within the grid, so I agree with Ben's assessment that this is
likely not to be exploitable.

Fixes #584
  • Loading branch information
chrisboyle committed Jan 18, 2023
1 parent d28f710 commit 33bd14f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/src/main/jni/tracks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2435,7 +2435,7 @@ 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))
if (!ui_can_flip_square(ret, x, y, f == S_NOTRACK) && !ret->used_solve)
goto badmove;
if (c == 'T' || c == 'N')
ret->sflags[y*w+x] |= f;
Expand All @@ -2446,7 +2446,7 @@ 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))
if (!ui_can_flip_edge(ret, x, y, df, f == S_NOTRACK) && !ret->used_solve)
goto badmove;
if (c == 'T' || c == 'N')
S_E_SET(ret, x, y, df, f);
Expand Down

0 comments on commit 33bd14f

Please sign in to comment.