memoryfix

This commit is contained in:
Peter Petrek 2022-01-14 02:20:01 +01:00
parent 32ccd86934
commit 45badc437a

View File

@ -32,9 +32,9 @@ int solve_maze(char* maze, int size) {
while (1) { while (1) {
enum direction next_step; enum direction next_step;
if (posX + 1 != size && maze2d[posY][posX + 1] != 'x' && !(maze2d[posY][posX + 1] & CHECKED_BIT)) { if (posX + 1 < size && maze2d[posY][posX + 1] != 'x' && !(maze2d[posY][posX + 1] & CHECKED_BIT)) {
next_step = EAST; next_step = EAST;
} else if (posY + 1 != size && maze2d[posY + 1][posX] != 'x' && !(maze2d[posY + 1][posX] & CHECKED_BIT)) { } else if (posY + 1 < size && maze2d[posY + 1][posX] != 'x' && !(maze2d[posY + 1][posX] & CHECKED_BIT)) {
next_step = SOUTH; next_step = SOUTH;
} else if (posX - 1 >= 0 && maze2d[posY][posX - 1] != 'x' && !(maze2d[posY][posX - 1] & CHECKED_BIT)) { } else if (posX - 1 >= 0 && maze2d[posY][posX - 1] != 'x' && !(maze2d[posY][posX - 1] & CHECKED_BIT)) {
next_step = WEST; next_step = WEST;
@ -104,14 +104,14 @@ int solve_maze(char* maze, int size) {
} }
//cleanup redundant routes //cleanup redundant routes
/*for (int i = size - 2; i >= 0; i--) { for (int i = size - 2; i >= 0; i--) {
for (int j = size - 2; j >= 0; j--) { for (int j = size - 2; j >= 0; j--) {
if (maze2d[i][j] == '*' && maze2d[i + 1][j] == '*' && maze2d[i + 1][j + 1] == '*' && maze2d[i][j + 1] == '*') { if (maze2d[i][j] == '*' && maze2d[i + 1][j] == '*' && maze2d[i + 1][j + 1] == '*' && maze2d[i][j + 1] == '*') {
maze2d[i + 1][j + 1] = ' '; maze2d[i + 1][j + 1] = ' ';
maze2d[i][j + 1] = ' '; maze2d[i][j + 1] = ' ';
} }
} }
}*/ }
//serialize //serialize
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {