chiark / gitweb /
New infrastructure feature. Games are now permitted to be
[sgt-puzzles.git] / sixteen.c
index 12cc134a87339657a32ceef5a499dc90065daead..ac3191c899d7baff1eaa9f8ead707d283bba4273 100644 (file)
--- a/sixteen.c
+++ b/sixteen.c
@@ -44,7 +44,6 @@ struct game_state {
     int w, h, n;
     int *tiles;
     int completed;
-    int just_used_solve;              /* used to suppress undo animation */
     int used_solve;                   /* used to suppress completion flash */
     int movecount, movetarget;
     int last_movement_sense;
@@ -474,7 +473,7 @@ static game_state *new_game(midend *me, game_params *params, char *desc)
 
     state->completed = state->movecount = 0;
     state->movetarget = params->movetarget;
-    state->used_solve = state->just_used_solve = FALSE;
+    state->used_solve = FALSE;
     state->last_movement_sense = 0;
 
     return state;
@@ -493,7 +492,6 @@ static game_state *dup_game(game_state *state)
     ret->movecount = state->movecount;
     ret->movetarget = state->movetarget;
     ret->used_solve = state->used_solve;
-    ret->just_used_solve = state->just_used_solve;
     ret->last_movement_sense = state->last_movement_sense;
 
     return ret;
@@ -511,6 +509,11 @@ static char *solve_game(game_state *state, game_state *currstate,
     return dupstr("S");
 }
 
+static int game_can_format_as_text_now(game_params *params)
+{
+    return TRUE;
+}
+
 static char *game_text_format(game_state *state)
 {
     char *ret, *p, buf[80];
@@ -636,7 +639,7 @@ static game_state *execute_move(game_state *from, char *move)
         */
        for (i = 0; i < ret->n; i++)
            ret->tiles[i] = i+1;
-       ret->used_solve = ret->just_used_solve = TRUE;
+       ret->used_solve = TRUE;
        ret->completed = ret->movecount = 1;
 
        return ret;
@@ -654,7 +657,6 @@ static game_state *execute_move(game_state *from, char *move)
        return NULL;
 
     ret = dup_game(from);
-    ret->just_used_solve = FALSE;      /* zero this in a hurry */
 
     do {
         tx = (cx - dx + from->w) % from->w;
@@ -986,11 +988,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
 static float game_anim_length(game_state *oldstate,
                              game_state *newstate, int dir, game_ui *ui)
 {
-    if ((dir > 0 && newstate->just_used_solve) ||
-       (dir < 0 && oldstate->just_used_solve))
-       return 0.0F;
-    else
-       return ANIM_TIME;
+    return ANIM_TIME;
 }
 
 static float game_flash_length(game_state *oldstate,
@@ -1021,7 +1019,7 @@ static void game_print(drawing *dr, game_state *state, int tilesize)
 #endif
 
 const struct game thegame = {
-    "Sixteen", "games.sixteen",
+    "Sixteen", "games.sixteen", "sixteen",
     default_params,
     game_fetch_preset,
     decode_params,
@@ -1036,7 +1034,7 @@ const struct game thegame = {
     dup_game,
     free_game,
     TRUE, solve_game,
-    TRUE, game_text_format,
+    TRUE, game_can_format_as_text_now, game_text_format,
     new_ui,
     free_ui,
     encode_ui,