aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-06-28 11:14:09 +0000
committerSimon Tatham <anakin@pobox.com>2005-06-28 11:14:09 +0000
commit89fdc09c29f1219a7660ad6d1839cc914a009c02 (patch)
treec9e9e95e109aa01df1a0ca8d310467929cf3049b /midend.c
parent6c9beb697bd61c7e8d0eac8b7fce54cde134d9c9 (diff)
downloadpuzzles-89fdc09c29f1219a7660ad6d1839cc914a009c02.zip
puzzles-89fdc09c29f1219a7660ad6d1839cc914a009c02.tar.gz
puzzles-89fdc09c29f1219a7660ad6d1839cc914a009c02.tar.bz2
puzzles-89fdc09c29f1219a7660ad6d1839cc914a009c02.tar.xz
More serialisation changes: the game_aux_info structure has now been
retired, and replaced with a simple string. Most of the games which use it simply encode the string in the same way that the Solve move will also be encoded, i.e. solve_game() simply returns dupstr(aux_info). Again, this is a better approach than writing separate game_aux_info serialise/deserialise functions because doing it this way is self-testing (the strings are created and parsed during the course of any Solve operation at all). [originally from svn r6029]
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/midend.c b/midend.c
index e545841..a6d2d40 100644
--- a/midend.c
+++ b/midend.c
@@ -48,7 +48,7 @@ struct midend_data {
* may also be typed directly into Mines if you like.)
*/
char *desc, *privdesc, *seedstr;
- game_aux_info *aux_info;
+ char *aux_info;
enum { GOT_SEED, GOT_DESC, GOT_NOTHING } genmode;
int nstates, statesize, statepos;
@@ -140,8 +140,7 @@ void midend_free(midend_data *me)
sfree(me->states);
sfree(me->desc);
sfree(me->seedstr);
- if (me->aux_info)
- me->ourgame->free_aux_info(me->aux_info);
+ sfree(me->aux_info);
me->ourgame->free_params(me->params);
if (me->npresets) {
for (i = 0; i < me->npresets; i++) {
@@ -235,8 +234,7 @@ void midend_new_game(midend_data *me)
sfree(me->desc);
sfree(me->privdesc);
- if (me->aux_info)
- me->ourgame->free_aux_info(me->aux_info);
+ sfree(me->aux_info);
me->aux_info = NULL;
rs = random_init(me->seedstr, strlen(me->seedstr));
@@ -634,13 +632,12 @@ float *midend_colours(midend_data *me, int *ncolours)
float *ret;
if (me->nstates == 0) {
- game_aux_info *aux = NULL;
+ char *aux = NULL;
char *desc = me->ourgame->new_desc(me->params, me->random,
&aux, TRUE);
state = me->ourgame->new_game(me, me->params, desc);
sfree(desc);
- if (aux)
- me->ourgame->free_aux_info(aux);
+ sfree(aux);
} else
state = me->states[0].state;
@@ -925,8 +922,7 @@ static char *midend_game_id_int(midend_data *me, char *id, int defmode)
me->desc = dupstr(desc);
me->genmode = GOT_DESC;
- if (me->aux_info)
- me->ourgame->free_aux_info(me->aux_info);
+ sfree(me->aux_info);
me->aux_info = NULL;
}