Redraw glitch: tiles marked black (at game-over time) were not

redrawn as non-black on undo. Introduce a new flag TILE_IMPOSSIBLE,
so that information about those black markers is cached in the
drawstate and we know when we have to erase them.

In the process I've removed the game_state argument completely from
the subfunction tile_redraw(), which gives me some confidence that
it isn't getting any _more_ privileged information out of it.

[originally from svn r5979]
This commit is contained in:
Simon Tatham
2005-06-19 14:33:06 +00:00
parent 574250995e
commit db88c9b9a4

View File

@ -49,6 +49,7 @@ struct game_params {
#define TILE_JOINDOWN 0x0400 /* used in drawstate */ #define TILE_JOINDOWN 0x0400 /* used in drawstate */
#define TILE_JOINDIAG 0x0800 /* used in drawstate */ #define TILE_JOINDIAG 0x0800 /* used in drawstate */
#define TILE_HASSEL 0x1000 /* used in drawstate */ #define TILE_HASSEL 0x1000 /* used in drawstate */
#define TILE_IMPOSSIBLE 0x2000 /* used in drawstate */
#define TILE(gs,x,y) ((gs)->tiles[(gs)->params.w*(y)+(x)]) #define TILE(gs,x,y) ((gs)->tiles[(gs)->params.w*(y)+(x)])
#define COL(gs,x,y) (TILE(gs,x,y) & TILE_COLMASK) #define COL(gs,x,y) (TILE(gs,x,y) & TILE_COLMASK)
@ -746,12 +747,12 @@ static void game_free_drawstate(game_drawstate *ds)
static void tile_redraw(frontend *fe, game_drawstate *ds, static void tile_redraw(frontend *fe, game_drawstate *ds,
int x, int y, int dright, int dbelow, int x, int y, int dright, int dbelow,
int tile, game_state *state, int bgcolour) int tile, int bgcolour)
{ {
int outer = bgcolour, inner = outer, col = tile & TILE_COLMASK; int outer = bgcolour, inner = outer, col = tile & TILE_COLMASK;
if (col) { if (col) {
if (state->impossible) { if (tile & TILE_IMPOSSIBLE) {
outer = col; outer = col;
inner = COL_IMPOSSIBLE; inner = COL_IMPOSSIBLE;
} else if (tile & TILE_SELECTED) { } else if (tile & TILE_SELECTED) {
@ -843,6 +844,8 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
int dbelow = (y+1 < state->params.h); int dbelow = (y+1 < state->params.h);
tile |= ISSEL(ui,x,y); tile |= ISSEL(ui,x,y);
if (state->impossible)
tile |= TILE_IMPOSSIBLE;
if (dright && COL(state,x+1,y) == col) if (dright && COL(state,x+1,y) == col)
tile |= TILE_JOINRIGHT; tile |= TILE_JOINRIGHT;
if (dbelow && COL(state,x,y+1) == col) if (dbelow && COL(state,x,y+1) == col)
@ -861,8 +864,7 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
(flashtime > 0.0) || (flashtime > 0.0) ||
(ds->bgcolour != bgcolour) || (ds->bgcolour != bgcolour) ||
(tile != ds->tiles[i])) { (tile != ds->tiles[i])) {
tile_redraw(fe, ds, x, y, dright, dbelow, tile_redraw(fe, ds, x, y, dright, dbelow, tile, bgcolour);
tile, state, bgcolour);
ds->tiles[i] = tile; ds->tiles[i] = tile;
} }
} }