General robustness patch from James Harvey:

- most game_size() functions now work in doubles internally and
   round to nearest, meaning that they have less tendency to try to
   alter a size they returned happily from a previous call
 - couple of fiddly fixes (memory leaks, precautionary casts in
   printf argument lists)
 - midend_deserialise() now constructs an appropriate drawstate,
   which I can't think how I overlooked myself since I _thought_ I
   went through the entire midend structure field by field!

[originally from svn r6041]
This commit is contained in:
Simon Tatham
2005-06-30 09:07:00 +00:00
parent 101324af67
commit 118abb4fc9
9 changed files with 50 additions and 42 deletions

View File

@ -149,6 +149,7 @@ void midend_free(midend_data *me)
random_free(me->random);
sfree(me->states);
sfree(me->desc);
sfree(me->privdesc);
sfree(me->seedstr);
sfree(me->aux_info);
me->ourgame->free_params(me->params);
@ -1351,7 +1352,7 @@ char *midend_deserialise(midend_data *me,
uistr = val;
val = NULL;
} else if (!strcmp(key, "TIME")) {
elapsed = strtod(val, NULL);
elapsed = atof(val);
} else if (!strcmp(key, "NSTATES")) {
nstates = atoi(val);
if (nstates <= 0) {
@ -1516,6 +1517,12 @@ char *midend_deserialise(midend_data *me,
midend_set_timer(me);
if (me->drawstate)
me->ourgame->free_drawstate(me->drawstate);
me->drawstate =
me->ourgame->new_drawstate(me->states[me->statepos-1].state);
midend_size_new_drawstate(me);
ret = NULL; /* success! */
cleanup: