shithub: puzzles

Download patch

ref: a3b837c69845e5ccfd3bc29ee72c9b3e6ea9adec
parent: d31f3ac3a5e1770c4fb9743480dfddcc8ec3dc11
author: Simon Tatham <anakin@pobox.com>
date: Sat Oct 22 13:00:35 EDT 2005

Cleanup: remove the `just_used_solve' field from a number of games
which didn't actually need it. It was originally introduced in
Fifteen to suppress animation on Solve moves, but midend.c now does
that centrally unless the game specifically instructs it otherwise.
Therefore, just_used_solve is obsolete in all games which previously
used it. (Mines was even worse: it scrupulously maintained the
correctness of the field but never used it!)

Untangle is exempt from this cleanup: its `just_solved' field is
used to change the _length_ of the animation on Solve moves, not to
suppress it entirely, and so it has to stay.

[originally from svn r6419]

--- a/fifteen.c
+++ b/fifteen.c
@@ -42,7 +42,6 @@
     int *tiles;
     int gap_pos;
     int completed;
-    int just_used_solve;	       /* used to suppress undo animation */
     int used_solve;		       /* used to suppress completion flash */
     int movecount;
 };
@@ -345,7 +344,7 @@
     assert(state->tiles[state->gap_pos] == 0);
 
     state->completed = state->movecount = 0;
-    state->used_solve = state->just_used_solve = FALSE;
+    state->used_solve = FALSE;
 
     return state;
 }
@@ -363,7 +362,6 @@
     ret->completed = state->completed;
     ret->movecount = state->movecount;
     ret->used_solve = state->used_solve;
-    ret->just_used_solve = state->just_used_solve;
 
     return ret;
 }
@@ -509,7 +507,7 @@
 	for (i = 0; i < ret->n; i++)
 	    ret->tiles[i] = (i+1) % ret->n;
 	ret->gap_pos = ret->n-1;
-	ret->used_solve = ret->just_used_solve = TRUE;
+	ret->used_solve = TRUE;
 	ret->completed = ret->movecount = 1;
 
 	return ret;
@@ -533,7 +531,6 @@
     up = C(from, ux, uy);
 
     ret = dup_game(from);
-    ret->just_used_solve = FALSE;      /* zero this in a hurry */
 
     ret->gap_pos = C(from, dx, dy);
     assert(ret->gap_pos >= 0 && ret->gap_pos < ret->n);
@@ -810,11 +807,7 @@
 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,
--- a/mines.c
+++ b/mines.c
@@ -58,7 +58,7 @@
 
 struct game_state {
     int w, h, n, dead, won;
-    int used_solve, just_used_solve;
+    int used_solve;
     struct mine_layout *layout;	       /* real mine positions */
     signed char *grid;			       /* player knowledge */
     /*
@@ -2169,7 +2169,7 @@
     state->h = params->h;
     state->n = params->n;
     state->dead = state->won = FALSE;
-    state->used_solve = state->just_used_solve = FALSE;
+    state->used_solve = FALSE;
 
     wh = state->w * state->h;
 
@@ -2274,7 +2274,6 @@
     ret->dead = state->dead;
     ret->won = state->won;
     ret->used_solve = state->used_solve;
-    ret->just_used_solve = state->just_used_solve;
     ret->layout = state->layout;
     ret->layout->refcount++;
     ret->grid = snewn(ret->w * ret->h, signed char);
@@ -2575,13 +2574,12 @@
 		    ret->grid[yy*ret->w+xx] = v;
 		}
 	    }
-	ret->used_solve = ret->just_used_solve = TRUE;
+	ret->used_solve = TRUE;
 	ret->won = TRUE;
 
 	return ret;
     } else {
 	ret = dup_game(from);
-	ret->just_used_solve = FALSE;
 
 	while (*move) {
 	    if (move[0] == 'F' &&
--- a/net.c
+++ b/net.c
@@ -80,7 +80,7 @@
 struct game_state {
     int width, height, wrapping, completed;
     int last_rotate_x, last_rotate_y, last_rotate_dir;
-    int used_solve, just_used_solve;
+    int used_solve;
     unsigned char *tiles;
     unsigned char *barriers;
 };
@@ -1526,7 +1526,7 @@
     h = state->height = params->height;
     state->wrapping = params->wrapping;
     state->last_rotate_dir = state->last_rotate_x = state->last_rotate_y = 0;
-    state->completed = state->used_solve = state->just_used_solve = FALSE;
+    state->completed = state->used_solve = FALSE;
     state->tiles = snewn(state->width * state->height, unsigned char);
     memset(state->tiles, 0, state->width * state->height);
     state->barriers = snewn(state->width * state->height, unsigned char);
@@ -1606,7 +1606,6 @@
     ret->wrapping = state->wrapping;
     ret->completed = state->completed;
     ret->used_solve = state->used_solve;
-    ret->just_used_solve = state->just_used_solve;
     ret->last_rotate_dir = state->last_rotate_dir;
     ret->last_rotate_x = state->last_rotate_x;
     ret->last_rotate_y = state->last_rotate_y;
@@ -2019,11 +2018,10 @@
     int tx, ty, n, noanim, orig;
 
     ret = dup_game(from);
-    ret->just_used_solve = FALSE;
 
     if (move[0] == 'J' || move[0] == 'S') {
 	if (move[0] == 'S')
-	    ret->just_used_solve = ret->used_solve = TRUE;
+	    ret->used_solve = TRUE;
 
 	move++;
 	if (*move == ';')
@@ -2651,13 +2649,6 @@
 			      game_state *newstate, int dir, game_ui *ui)
 {
     int last_rotate_dir;
-
-    /*
-     * Don't animate an auto-solve move.
-     */
-    if ((dir > 0 && newstate->just_used_solve) ||
-       (dir < 0 && oldstate->just_used_solve))
-       return 0.0F;
 
     /*
      * Don't animate if last_rotate_dir is zero.
--- a/netslide.c
+++ b/netslide.c
@@ -84,7 +84,7 @@
 
 struct game_state {
     int width, height, cx, cy, wrapping, completed;
-    int used_solve, just_used_solve;
+    int used_solve;
     int move_count, movetarget;
 
     /* position (row or col number, starting at 0) of last move. */
@@ -745,7 +745,7 @@
     state->wrapping = params->wrapping;
     state->movetarget = params->movetarget;
     state->completed = 0;
-    state->used_solve = state->just_used_solve = FALSE;
+    state->used_solve = FALSE;
     state->move_count = 0;
     state->last_move_row = -1;
     state->last_move_col = -1;
@@ -865,7 +865,6 @@
     ret->movetarget = state->movetarget;
     ret->completed = state->completed;
     ret->used_solve = state->used_solve;
-    ret->just_used_solve = state->just_used_solve;
     ret->move_count = state->move_count;
     ret->last_move_row = state->last_move_row;
     ret->last_move_col = state->last_move_col;
@@ -1111,7 +1110,7 @@
 	       strlen(move) == from->width * from->height + 1) {
 	int i;
 	ret = dup_game(from);
-	ret->used_solve = ret->just_used_solve = TRUE;
+	ret->used_solve = TRUE;
 	ret->completed = ret->move_count = 1;
 
 	for (i = 0; i < from->width * from->height; i++) {
@@ -1133,7 +1132,6 @@
 	return NULL;		       /* can't parse move string */
 
     ret = dup_game(from);
-    ret->just_used_solve = FALSE;
 
     if (col)
 	slide_col(ret, d, c);
@@ -1736,13 +1734,6 @@
 static float game_anim_length(game_state *oldstate,
 			      game_state *newstate, int dir, game_ui *ui)
 {
-    /*
-     * Don't animate an auto-solve move.
-     */
-    if ((dir > 0 && newstate->just_used_solve) ||
-	(dir < 0 && oldstate->just_used_solve))
-	return 0.0F;
-
     return ANIM_TIME;
 }
 
--- a/sixteen.c
+++ b/sixteen.c
@@ -44,7 +44,6 @@
     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 @@
 
     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 @@
     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;
@@ -636,7 +634,7 @@
 	 */
 	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 +652,6 @@
 	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 +983,7 @@
 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,
--- a/twiddle.c
+++ b/twiddle.c
@@ -46,7 +46,6 @@
     int orientable;
     int *grid;
     int completed;
-    int just_used_solve;	       /* used to suppress undo animation */
     int used_solve;		       /* used to suppress completion flash */
     int movecount, movetarget;
     int lastx, lasty, lastr;	       /* coordinates of last rotation */
@@ -472,7 +471,7 @@
     state->n = n;
     state->orientable = params->orientable;
     state->completed = 0;
-    state->used_solve = state->just_used_solve = FALSE;
+    state->used_solve = FALSE;
     state->movecount = 0;
     state->movetarget = params->movetarget;
     state->lastx = state->lasty = state->lastr = -1;
@@ -515,7 +514,6 @@
     ret->lasty = state->lasty;
     ret->lastr = state->lastr;
     ret->used_solve = state->used_solve;
-    ret->just_used_solve = state->just_used_solve;
 
     ret->grid = snewn(ret->w * ret->h, int);
     memcpy(ret->grid, state->grid, ret->w * ret->h * sizeof(int));
@@ -712,7 +710,7 @@
 	qsort(ret->grid, ret->w*ret->h, sizeof(int), compare_int);
 	for (i = 0; i < ret->w*ret->h; i++)
 	    ret->grid[i] &= ~3;
-	ret->used_solve = ret->just_used_solve = TRUE;
+	ret->used_solve = TRUE;
 	ret->completed = ret->movecount = 1;
 
 	return ret;
@@ -724,7 +722,6 @@
 	return NULL;		       /* can't parse this move string */
 
     ret = dup_game(from);
-    ret->just_used_solve = FALSE;  /* zero this in a hurry */
     ret->movecount++;
     do_rotate(ret->grid, w, h, n, ret->orientable, x, y, dir);
     ret->lastx = x;
@@ -1006,11 +1003,7 @@
 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_PER_RADIUS_UNIT * sqrt(newstate->n-1);
+    return ANIM_PER_RADIUS_UNIT * sqrt(newstate->n-1);
 }
 
 static float game_flash_length(game_state *oldstate, game_state *newstate,