X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/b760b8bdf1ff5b603e3076c8e21cf246d08937f7..HEAD:/loopy.c diff --git a/loopy.c b/loopy.c index 85590fa..0ee1098 100644 --- a/loopy.c +++ b/loopy.c @@ -2813,7 +2813,7 @@ static char *solve_game(game_state *state, game_state *currstate, * Drawing and mouse-handling */ -static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds, +static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds, int x, int y, int button) { grid *g = state->game_grid; @@ -3193,60 +3193,63 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate, * what needs doing, and the second actually does it. */ - if (!ds->started) + if (!ds->started) { redraw_everything = TRUE; - else { - - /* First, trundle through the faces. */ - for (i = 0; i < g->num_faces; i++) { - grid_face *f = g->faces + i; - int sides = f->order; - int clue_mistake; - int clue_satisfied; - int n = state->clues[i]; - if (n < 0) - continue; - - clue_mistake = (face_order(state, i, LINE_YES) > n || - face_order(state, i, LINE_NO ) > (sides-n)); - clue_satisfied = (face_order(state, i, LINE_YES) == n && - face_order(state, i, LINE_NO ) == (sides-n)); - - if (clue_mistake != ds->clue_error[i] || - clue_satisfied != ds->clue_satisfied[i]) { - ds->clue_error[i] = clue_mistake; - ds->clue_satisfied[i] = clue_satisfied; - if (nfaces == REDRAW_OBJECTS_LIMIT) - redraw_everything = TRUE; - else - faces[nfaces++] = i; - } - } + /* + * But we must still go through the upcoming loops, so that we + * set up stuff in ds correctly for the initial redraw. + */ + } - /* Work out what the flash state needs to be. */ - if (flashtime > 0 && - (flashtime <= FLASH_TIME/3 || - flashtime >= FLASH_TIME*2/3)) { - flash_changed = !ds->flashing; - ds->flashing = TRUE; - } else { - flash_changed = ds->flashing; - ds->flashing = FALSE; - } + /* First, trundle through the faces. */ + for (i = 0; i < g->num_faces; i++) { + grid_face *f = g->faces + i; + int sides = f->order; + int clue_mistake; + int clue_satisfied; + int n = state->clues[i]; + if (n < 0) + continue; - /* Now, trundle through the edges. */ - for (i = 0; i < g->num_edges; i++) { - char new_ds = - state->line_errors[i] ? DS_LINE_ERROR : state->lines[i]; - if (new_ds != ds->lines[i] || - (flash_changed && state->lines[i] == LINE_YES)) { - ds->lines[i] = new_ds; - if (nedges == REDRAW_OBJECTS_LIMIT) - redraw_everything = TRUE; - else - edges[nedges++] = i; - } - } + clue_mistake = (face_order(state, i, LINE_YES) > n || + face_order(state, i, LINE_NO ) > (sides-n)); + clue_satisfied = (face_order(state, i, LINE_YES) == n && + face_order(state, i, LINE_NO ) == (sides-n)); + + if (clue_mistake != ds->clue_error[i] || + clue_satisfied != ds->clue_satisfied[i]) { + ds->clue_error[i] = clue_mistake; + ds->clue_satisfied[i] = clue_satisfied; + if (nfaces == REDRAW_OBJECTS_LIMIT) + redraw_everything = TRUE; + else + faces[nfaces++] = i; + } + } + + /* Work out what the flash state needs to be. */ + if (flashtime > 0 && + (flashtime <= FLASH_TIME/3 || + flashtime >= FLASH_TIME*2/3)) { + flash_changed = !ds->flashing; + ds->flashing = TRUE; + } else { + flash_changed = ds->flashing; + ds->flashing = FALSE; + } + + /* Now, trundle through the edges. */ + for (i = 0; i < g->num_edges; i++) { + char new_ds = + state->line_errors[i] ? DS_LINE_ERROR : state->lines[i]; + if (new_ds != ds->lines[i] || + (flash_changed && state->lines[i] == LINE_YES)) { + ds->lines[i] = new_ds; + if (nedges == REDRAW_OBJECTS_LIMIT) + redraw_everything = TRUE; + else + edges[nedges++] = i; + } } /* Pass one is now done. Now we do the actual drawing. */