Infrastructure change which I've been thinking about for a while:

the back end function solve_game() now takes the _current_
game_state in addition to the initial one.

[originally from svn r5969]
This commit is contained in:
Simon Tatham
2005-06-17 18:54:58 +00:00
parent 32111ef901
commit f01f82105e
15 changed files with 31 additions and 28 deletions

4
cube.c
View File

@ -984,8 +984,8 @@ static void free_game(game_state *state)
sfree(state); sfree(state);
} }
static game_state *solve_game(game_state *state, game_aux_info *aux, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *aux, char **error)
{ {
return NULL; return NULL;
} }

View File

@ -379,8 +379,8 @@ static void free_game(game_state *state)
sfree(state); sfree(state);
} }
static game_state *solve_game(game_state *state, game_aux_info *aux, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *aux, char **error)
{ {
game_state *ret = dup_game(state); game_state *ret = dup_game(state);
int i; int i;

4
flip.c
View File

@ -670,8 +670,8 @@ static void free_game(game_state *state)
sfree(state); sfree(state);
} }
static game_state *solve_game(game_state *state, game_aux_info *aux, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *aux, char **error)
{ {
return NULL; return NULL;
} }

View File

@ -947,7 +947,9 @@ char *midend_solve(midend_data *me)
return "No game set up to solve"; /* _shouldn't_ happen! */ return "No game set up to solve"; /* _shouldn't_ happen! */
msg = "Solve operation failed"; /* game _should_ overwrite on error */ msg = "Solve operation failed"; /* game _should_ overwrite on error */
s = me->ourgame->solve(me->states[0].state, me->aux_info, &msg); s = me->ourgame->solve(me->states[0].state,
me->states[me->statepos-1].state,
me->aux_info, &msg);
if (!s) if (!s)
return msg; return msg;

View File

@ -2385,8 +2385,8 @@ static void free_game(game_state *state)
sfree(state); sfree(state);
} }
static game_state *solve_game(game_state *state, game_aux_info *aux, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *aux, char **error)
{ {
/* /*
* Simply expose the entire grid as if it were a completed * Simply expose the entire grid as if it were a completed

4
net.c
View File

@ -1666,8 +1666,8 @@ static void free_game(game_state *state)
sfree(state); sfree(state);
} }
static game_state *solve_game(game_state *state, game_aux_info *aux, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *aux, char **error)
{ {
game_state *ret; game_state *ret;

View File

@ -893,8 +893,8 @@ static void free_game(game_state *state)
sfree(state); sfree(state);
} }
static game_state *solve_game(game_state *state, game_aux_info *aux, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *aux, char **error)
{ {
game_state *ret; game_state *ret;

View File

@ -122,8 +122,8 @@ static void free_game(game_state *state)
sfree(state); sfree(state);
} }
static game_state *solve_game(game_state *state, game_aux_info *aux, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *aux, char **error)
{ {
return NULL; return NULL;
} }

View File

@ -664,8 +664,8 @@ static void free_game(game_state *state)
sfree(state); sfree(state);
} }
static game_state *solve_game(game_state *state, game_aux_info *ai, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *ai, char **error)
{ {
game_state *ret; game_state *ret;

View File

@ -248,7 +248,8 @@ struct game {
game_state *(*dup_game)(game_state *state); game_state *(*dup_game)(game_state *state);
void (*free_game)(game_state *state); void (*free_game)(game_state *state);
int can_solve; int can_solve;
game_state *(*solve)(game_state *state, game_aux_info *aux, char **error); game_state *(*solve)(game_state *orig, game_state *curr,
game_aux_info *aux, char **error);
int can_format_as_text; int can_format_as_text;
char *(*text_format)(game_state *state); char *(*text_format)(game_state *state);
game_ui *(*new_ui)(game_state *state); game_ui *(*new_ui)(game_state *state);

4
rect.c
View File

@ -1769,8 +1769,8 @@ static void free_game(game_state *state)
sfree(state); sfree(state);
} }
static game_state *solve_game(game_state *state, game_aux_info *ai, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *ai, char **error)
{ {
game_state *ret; game_state *ret;

View File

@ -354,8 +354,8 @@ static void free_game(game_state *state)
sfree(state); sfree(state);
} }
static game_state *solve_game(game_state *state, game_aux_info *aux, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *aux, char **error)
{ {
return NULL; return NULL;
} }

View File

@ -510,8 +510,8 @@ static void free_game(game_state *state)
sfree(state); sfree(state);
} }
static game_state *solve_game(game_state *state, game_aux_info *aux, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *aux, char **error)
{ {
game_state *ret = dup_game(state); game_state *ret = dup_game(state);
int i; int i;

4
solo.c
View File

@ -1759,8 +1759,8 @@ static void free_game(game_state *state)
sfree(state); sfree(state);
} }
static game_state *solve_game(game_state *state, game_aux_info *ai, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *ai, char **error)
{ {
game_state *ret; game_state *ret;
int c = state->c, r = state->r, cr = c*r; int c = state->c, r = state->r, cr = c*r;

View File

@ -546,8 +546,8 @@ static int compare_int(const void *av, const void *bv)
return 0; return 0;
} }
static game_state *solve_game(game_state *state, game_aux_info *aux, static game_state *solve_game(game_state *state, game_state *currstate,
char **error) game_aux_info *aux, char **error)
{ {
game_state *ret = dup_game(state); game_state *ret = dup_game(state);
int i; int i;