Galaxies: store game solution in the aux string.

Most games store a string in 'aux' during new_game_desc() that saves
solve_game() during gameplay from having to reconstruct the solution
from scratch. Galaxies had all the facilities available to do that,
but apparently just forgot to use them.

(Reindents existing code: diff best viewed with whitespace ignored.)
This commit is contained in:
Simon Tatham
2021-10-21 20:40:36 +01:00
parent 49d28f2204
commit ad1c6ade2a

View File

@ -155,6 +155,7 @@ static int solver_obvious_dot(game_state *state, space *dot);
static space *space_opposite_dot(const game_state *state, const space *sp,
const space *dot);
static space *tile_opposite(const game_state *state, const space *sp);
static game_state *execute_move(const game_state *state, const char *move);
/* ----------------------------------------------------------
* Game parameters and presets
@ -1568,6 +1569,10 @@ generate:
dbg_state(state);
#endif
game_state *blank = blank_game(params->w, params->h);
*aux = diff_game(blank, state, true, -1);
free_game(blank);
free_game(state);
sfree(scratch);
@ -2325,6 +2330,10 @@ static char *solve_game(const game_state *state, const game_state *currstate,
int i;
int diff;
if (aux) {
tosolve = execute_move(state, aux);
goto solved;
} else {
tosolve = dup_game(currstate);
diff = solver_state(tosolve, DIFF_UNREASONABLE);
if (diff != DIFF_UNFINISHED && diff != DIFF_IMPOSSIBLE) {
@ -2340,6 +2349,7 @@ static char *solve_game(const game_state *state, const game_state *currstate,
goto solved;
}
free_game(tosolve);
}
return NULL;