From b71dd7fc01f9bcc1208cb7814d2229016fa71cd3 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 1 Jun 2005 18:57:28 +0000 Subject: [PATCH] Fix Richard's patch so that it's actually C :-/ git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5899 cda61777-01e9-0310-a592-d414129be87e --- solo.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/solo.c b/solo.c index 4a0f279..134331e 100644 --- a/solo.c +++ b/solo.c @@ -1962,6 +1962,8 @@ struct game_drawstate { digit *grid; unsigned char *pencil; unsigned char *hl; + /* This is scratch space used within a single call to game_redraw. */ + int *entered_items; }; #define XSIZE(cr) ((cr) * TILE_SIZE + 2*BORDER + 1) @@ -2024,6 +2026,7 @@ static game_drawstate *game_new_drawstate(game_state *state) memset(ds->pencil, 0, cr*cr*cr); ds->hl = snewn(cr*cr, unsigned char); memset(ds->hl, 0, cr*cr); + ds->entered_items = snewn(cr*cr, int); return ds; } @@ -2033,6 +2036,7 @@ static void game_free_drawstate(game_drawstate *ds) sfree(ds->hl); sfree(ds->pencil); sfree(ds->grid); + sfree(ds->entered_items); sfree(ds); } @@ -2125,7 +2129,6 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, float animtime, float flashtime) { int c = state->c, r = state->r, cr = c*r; - int entered_items[cr*cr]; int x, y; if (!ds->started) { @@ -2157,15 +2160,15 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, * which contain a number more than once. */ for (x = 0; x < cr * cr; x++) - entered_items[x] = 0; + ds->entered_items[x] = 0; for (x = 0; x < cr; x++) for (y = 0; y < cr; y++) { digit d = state->grid[y*cr+x]; if (d) { int box = (x/r)+(y/c)*c; - entered_items[x*cr+d-1] |= ((entered_items[x*cr+d-1] & 1) << 1) | 1; - entered_items[y*cr+d-1] |= ((entered_items[y*cr+d-1] & 4) << 1) | 4; - entered_items[box*cr+d-1] |= ((entered_items[box*cr+d-1] & 16) << 1) | 16; + ds->entered_items[x*cr+d-1] |= ((ds->entered_items[x*cr+d-1] & 1) << 1) | 1; + ds->entered_items[y*cr+d-1] |= ((ds->entered_items[y*cr+d-1] & 4) << 1) | 4; + ds->entered_items[box*cr+d-1] |= ((ds->entered_items[box*cr+d-1] & 16) << 1) | 16; } } @@ -2188,9 +2191,9 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate, /* Mark obvious errors (ie, numbers which occur more than once * in a single row, column, or box). */ - if ((entered_items[x*cr+d-1] & 2) || - (entered_items[y*cr+d-1] & 8) || - (entered_items[((x/r)+(y/c)*c)*cr+d-1] & 32)) + if ((ds->entered_items[x*cr+d-1] & 2) || + (ds->entered_items[y*cr+d-1] & 8) || + (ds->entered_items[((x/r)+(y/c)*c)*cr+d-1] & 32)) highlight |= 16; draw_number(fe, ds, state, x, y, highlight); -- 2.11.0