Cleanups to completion flashes: all four of these games used to

redraw the whole window _every_ time game_redraw() was called during
a flash. Now they only redraw the whole window every time the
background colour actually changes. Thanks to James H for much of
the work.

[originally from svn r6166]
This commit is contained in:
Simon Tatham
2005-08-05 17:17:23 +00:00
parent 56e01e54fa
commit c321a88408
4 changed files with 66 additions and 40 deletions

View File

@ -859,7 +859,7 @@ struct game_drawstate {
int tilesize, crad, rrad, w, h; /* w and h to make macros work... */
unsigned int *grid; /* as the game_state grid */
int started, reveal;
int flash_laserno;
int flash_laserno, isflash;
};
static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
@ -1112,6 +1112,7 @@ static game_drawstate *game_new_drawstate(game_state *state)
memset(ds->grid, 0, (state->w+2)*(state->h+2)*sizeof(unsigned int));
ds->started = ds->reveal = 0;
ds->flash_laserno = LASER_EMPTY;
ds->isflash = 0;
return ds;
}
@ -1266,7 +1267,6 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
if (flashtime > 0) {
int frame = (int)(flashtime / FLASH_FRAME);
isflash = (frame % 2) == 0;
force = 1;
debug(("game_redraw: flashtime = %f", flashtime));
}
@ -1299,6 +1299,8 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
ds->started = 1;
}
if (isflash != ds->isflash) force = 1;
/* draw the arena */
for (x = 0; x < state->w; x++) {
for (y = 0; y < state->h; y++) {
@ -1324,6 +1326,7 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
draw_update(fe, TODRAW(0), TODRAW(0), TILE_SIZE, TILE_SIZE);
ds->reveal = state->reveal;
ds->flash_laserno = ui->flash_laserno;
ds->isflash = isflash;
{
char buf[256];