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]
This commit is contained in:
Simon Tatham
2005-10-22 17:00:35 +00:00
parent d31f3ac3a5
commit a3b837c698
6 changed files with 18 additions and 59 deletions

View File

@ -42,7 +42,6 @@ struct game_state {
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 @@ static game_state *new_game(midend *me, game_params *params, char *desc)
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 @@ static game_state *dup_game(game_state *state)
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 @@ static game_state *execute_move(game_state *from, char *move)
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 @@ static game_state *execute_move(game_state *from, char *move)
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 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,

View File

@ -58,7 +58,7 @@ struct mine_layout {
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 @@ static game_state *new_game(midend *me, game_params *params, char *desc)
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 @@ static game_state *dup_game(game_state *state)
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 @@ static game_state *execute_move(game_state *from, char *move)
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' &&

15
net.c
View File

@ -80,7 +80,7 @@ struct game_params {
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 @@ static game_state *new_game(midend *me, game_params *params, char *desc)
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 @@ static game_state *dup_game(game_state *state)
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 @@ static game_state *execute_move(game_state *from, char *move)
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 == ';')
@ -2652,13 +2650,6 @@ static float game_anim_length(game_state *oldstate,
{
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.
*/

View File

@ -84,7 +84,7 @@ struct game_params {
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 @@ static game_state *new_game(midend *me, game_params *params, char *desc)
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 @@ static game_state *dup_game(game_state *state)
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 @@ static game_state *execute_move(game_state *from, char *move)
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 @@ static game_state *execute_move(game_state *from, char *move)
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 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)
{
/*
* 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;
}

View File

@ -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;
@ -636,7 +634,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 +652,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 +983,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,

View File

@ -46,7 +46,6 @@ struct game_state {
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 @@ static game_state *new_game(midend *me, game_params *params, char *desc)
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 @@ static game_state *dup_game(game_state *state)
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 @@ static game_state *execute_move(game_state *from, char *move)
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 @@ static game_state *execute_move(game_state *from, char *move)
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 int highlight_colour(float angle)
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,