chiark / gitweb /
Introduce a new game backend function (there seem to have been a lot
[sgt-puzzles.git] / cube.c
diff --git a/cube.c b/cube.c
index cb6a1f970c02cc61e26ef6712fd66ea4245f88e6..ffefa2f17e20950d5b75dcad1df99ced6809113d 100644 (file)
--- a/cube.c
+++ b/cube.c
@@ -300,10 +300,9 @@ static char *encode_params(game_params *params, int full)
 
     return dupstr(data);
 }
+typedef void (*egc_callback)(void *, struct grid_square *);
 
-static void enum_grid_squares(game_params *params,
-                              void (*callback)(void *, struct grid_square *),
-                              void *ctx)
+static void enum_grid_squares(game_params *params, egc_callback callback, void *ctx)
 {
     const struct solid *solid = solids[params->solid];
 
@@ -979,6 +978,8 @@ static game_state *dup_game(game_state *state)
 
 static void free_game(game_state *state)
 {
+    sfree(state->squares);
+    sfree(state->facecolours);
     sfree(state);
 }
 
@@ -1002,6 +1003,11 @@ static void free_ui(game_ui *ui)
 {
 }
 
+static void game_changed_state(game_ui *ui, game_state *oldstate,
+                               game_state *newstate)
+{
+}
+
 struct game_drawstate {
     int ox, oy;                        /* pixel position of float origin */
 };
@@ -1233,6 +1239,7 @@ static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds,
         success = align_poly(poly, &from->squares[ret->current], all_pkey);
 
         if (!success) {
+            sfree(poly);
             angle = -angle;
             poly = transform_poly(from->solid,
                                   from->squares[from->current].flip,
@@ -1572,8 +1579,8 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
     }
     sfree(poly);
 
-    draw_update(fe, 0, 0, (int)((bb.r-bb.l+2.0F) * GRID_SCALE),
-                (int)((bb.d-bb.u+2.0F) * GRID_SCALE));
+    game_size(&state->params, &i, &j);
+    draw_update(fe, 0, 0, i, j);
 
     /*
      * Update the status bar.
@@ -1635,6 +1642,7 @@ const struct game thegame = {
     FALSE, game_text_format,
     new_ui,
     free_ui,
+    game_changed_state,
     make_move,
     game_size,
     game_colours,