aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-06-30 09:07:00 +0000
committerSimon Tatham <anakin@pobox.com>2005-06-30 09:07:00 +0000
commit118abb4fc9365807ad4174588eeb9aefda550415 (patch)
treeea53c5b0a1c8600912a8806ff08e356c0f95faab /midend.c
parent101324af67c5e7819849daeafb337dd4c1f45828 (diff)
downloadpuzzles-118abb4fc9365807ad4174588eeb9aefda550415.zip
puzzles-118abb4fc9365807ad4174588eeb9aefda550415.tar.gz
puzzles-118abb4fc9365807ad4174588eeb9aefda550415.tar.bz2
puzzles-118abb4fc9365807ad4174588eeb9aefda550415.tar.xz
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]
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/midend.c b/midend.c
index 15d11bb..8928fde 100644
--- a/midend.c
+++ b/midend.c
@@ -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: