diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-02-01 17:07:12 +0000 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-02-01 20:29:45 +0000 |
| commit | 17364455186ae61e015d0f0de3f09423f78d0727 (patch) | |
| tree | ff254e39aeb53a8ee4303949093ab590a132cf30 /mines.c | |
| parent | 37df1f2bbc689d224369d963dd8007d68fcd7c6a (diff) | |
| download | puzzles-17364455186ae61e015d0f0de3f09423f78d0727.zip puzzles-17364455186ae61e015d0f0de3f09423f78d0727.tar.gz puzzles-17364455186ae61e015d0f0de3f09423f78d0727.tar.bz2 puzzles-17364455186ae61e015d0f0de3f09423f78d0727.tar.xz | |
Mines: forbid moves that flag or unflag an exposed square
interpret_move() couldn't generate them, but execute_move() also needs
to forbid them to defend against corrupt save files. I don't think this
actually caused any crashes, but it did cause unexpected "1" squares not
adjacent to mines.
Diffstat (limited to 'mines.c')
| -rw-r--r-- | mines.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -2701,7 +2701,9 @@ static game_state *execute_move(const game_state *from, const char *move) while (*move) { if (move[0] == 'F' && sscanf(move+1, "%d,%d", &cx, &cy) == 2 && - cx >= 0 && cx < from->w && cy >= 0 && cy < from->h) { + cx >= 0 && cx < from->w && cy >= 0 && cy < from->h && + (ret->grid[cy * from->w + cx] == -1 || + ret->grid[cy * from->w + cx] == -2)) { ret->grid[cy * from->w + cx] ^= (-2 ^ -1); } else if (move[0] == 'O' && sscanf(move+1, "%d,%d", &cx, &cy) == 2 && |