chiark / gitweb /
solve_game() is passed the _initial_ game state, not the most recent
authorSimon Tatham <anakin@pobox.com>
Sat, 7 May 2005 16:07:26 +0000 (16:07 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 7 May 2005 16:07:26 +0000 (16:07 +0000)
one; so we can't just set `ret->completed = ret->movecount' and hope
it's been set to something other than zero. Instead, we set both
move counts to 1, which is entirely arbitrary but works.

This fixes a subtle bug with the Solve feature: if you pressed
Solve, then disturbed the grid, then brought it back to the solved
state by making more forward moves (rather than using Undo), then
the first time you did this the `Moves since auto-solve' status line
would reset to zero.

[originally from svn r5759]

fifteen.c
netslide.c
sixteen.c
twiddle.c

index 0ed50676d0eaee92490bb669d7ef2e829e5d4da9..3aba7fa1db416063a156069d5b089e240f228bbc 100644 (file)
--- a/fifteen.c
+++ b/fifteen.c
@@ -398,7 +398,7 @@ static game_state *solve_game(game_state *state, game_aux_info *aux,
        ret->tiles[i] = (i+1) % ret->n;
     ret->gap_pos = ret->n-1;
     ret->used_solve = ret->just_used_solve = TRUE;
-    ret->completed = ret->movecount;
+    ret->completed = ret->movecount = 1;
 
     return ret;
 }
index f367621826ee8d1427a3766356fd50de667c2192..02fa43816c1a6d770b74d01517eae22d769eee68 100644 (file)
@@ -805,7 +805,7 @@ static game_state *solve_game(game_state *state, game_aux_info *aux,
     ret = dup_game(state);
     memcpy(ret->tiles, state->solution->tiles, ret->width * ret->height);
     ret->used_solve = ret->just_used_solve = TRUE;
-    ret->completed = ret->move_count;
+    ret->completed = ret->move_count = 1;
 
     return ret;
 }
index 950f72422417d4058585995aa5c96dafa8b84f2d..3a5ce8a0f2afe080abf2ccd978f1cc8216046a21 100644 (file)
--- a/sixteen.c
+++ b/sixteen.c
@@ -406,7 +406,7 @@ static game_state *solve_game(game_state *state, game_aux_info *aux,
     for (i = 0; i < ret->n; i++)
        ret->tiles[i] = i+1;
     ret->used_solve = ret->just_used_solve = TRUE;
-    ret->completed = ret->movecount;
+    ret->completed = ret->movecount = 1;
 
     return ret;
 }
index 8fd0b21004b0425be80360c394c09aae33f95777..6c51cb7eabb6aa528fce78ef7f033ce1dfb86a88 100644 (file)
--- a/twiddle.c
+++ b/twiddle.c
@@ -492,7 +492,7 @@ static game_state *solve_game(game_state *state, game_aux_info *aux,
     for (i = 0; i < ret->w*ret->h; i++)
        ret->grid[i] &= ~3;
     ret->used_solve = ret->just_used_solve = TRUE;
-    ret->completed = ret->movecount;
+    ret->completed = ret->movecount = 1;
 
     return ret;
 }