From 89fdc09c29f1219a7660ad6d1839cc914a009c02 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 28 Jun 2005 11:14:09 +0000 Subject: 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] --- midend.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'midend.c') 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; } -- cgit v1.1