Commit a0cbf811 authored by PurkkaKoodari's avatar PurkkaKoodari

Fix stack overflow for adjacent mines

parent 5321181c
......@@ -168,6 +168,7 @@ public class Board {
return;
int state = tiles[index];
if (state != (state &= ~Tile.SUPER_MINE)) {
tiles[index] = (state & ~(Tile.OPPONENT | Tile.SUPER_MINE)) | Tile.PLAYER;
takeTile(tiles, x - 1, y - 1, index - 11);
takeTile(tiles, x + 1, y - 1, index - 9);
takeTile(tiles, x - 1, y + 1, index + 9);
......@@ -177,13 +178,15 @@ public class Board {
takeTile(tiles, x + 1, y, index + 1);
takeTile(tiles, x, y + 1, index + 10);
} else if (state != (state &= ~Tile.MINE)) {
tiles[index] = (state & ~(Tile.OPPONENT | Tile.MINE)) | Tile.PLAYER;
takeTile(tiles, x, y - 1, index - 10);
takeTile(tiles, x - 1, y, index - 1);
takeTile(tiles, x + 1, y, index + 1);
takeTile(tiles, x, y + 1, index + 10);
}
} else {
tiles[index] = (state & ~Tile.OPPONENT) | Tile.PLAYER;
}
}
private void addConnected(int[] tiles, int x, int y, int index, boolean[] positions) {
if (x < 0 || x > 9 || y < 0 || y > 12 || positions[index] || (tiles[index] & Tile.OPPONENT) == 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment