X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/5b502ae807b1e98a91644f179863484c61aedb4c..40785ed96c9dbe9a5a630b69faa0bbc9a8435091:/guess.c diff --git a/guess.c b/guess.c index 9a78225..8cab1a4 100644 --- a/guess.c +++ b/guess.c @@ -655,20 +655,24 @@ static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds, if (from->solved) return NULL; - if (x >= COL_OX && x <= (COL_OX + COL_W) && - y >= COL_OY && y <= (COL_OY + COL_H)) { + if (x >= COL_OX && x < (COL_OX + COL_W) && + y >= COL_OY && y < (COL_OY + COL_H)) { over_col = ((y - COL_OY) / PEGOFF) + 1; + assert(over_col >= 1 && over_col <= ds->colours->npegs); } else if (x >= guess_ox && - y >= guess_oy && y <= (guess_oy + GUESS_H)) { - if (x <= (guess_ox + GUESS_W)) { + y >= guess_oy && y < (guess_oy + GUESS_H)) { + if (x < (guess_ox + GUESS_W)) { over_guess = (x - guess_ox) / PEGOFF; + assert(over_guess >= 0 && over_guess < ds->solution->npegs); } else { over_hint = 1; } - } else if (x >= guess_ox && x <= (guess_ox + GUESS_W) && + } else if (x >= guess_ox && x < (guess_ox + GUESS_W) && y >= GUESS_OY && y < guess_oy) { over_past_guess_y = (y - GUESS_OY) / PEGOFF; over_past_guess_x = (x - guess_ox) / PEGOFF; + assert(over_past_guess_y >= 0 && over_past_guess_y < from->next_go); + assert(over_past_guess_x >= 0 && over_past_guess_x < ds->solution->npegs); } debug(("make_move: over_col %d, over_guess %d, over_hint %d," " over_past_guess (%d,%d)", over_col, over_guess, over_hint, @@ -1206,10 +1210,9 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate, game_state *state, int dir, game_ui *ui, float animtime, float flashtime) { - int i, new_move, last_go; + int i, new_move; new_move = (state->next_go != ds->next_go) || !ds->started; - last_go = (state->next_go == state->params.nguesses-1); if (!ds->started) { draw_rect(dr, 0, 0, ds->w, ds->h, COL_BACKGROUND); @@ -1310,6 +1313,18 @@ static float game_flash_length(game_state *oldstate, game_state *newstate, return 0.0F; } +static int game_is_solved(game_state *state) +{ + /* + * We return true whenever the solution has been revealed, even + * (on spoiler grounds) if it wasn't guessed correctly. + * + * However, in that situation, 'solved' is still true, so we don't + * have to make any effort to arrange this. + */ + return state->solved; +} + static int game_timing_state(game_state *state, game_ui *ui) { return TRUE; @@ -1358,6 +1373,7 @@ const struct game thegame = { game_redraw, game_anim_length, game_flash_length, + game_is_solved, FALSE, FALSE, game_print_size, game_print, FALSE, /* wants_statusbar */ FALSE, game_timing_state,