X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/4496362fadb5f60b8ecf431fb220d26df7280f99..HEAD:/unfinished/group.c diff --git a/unfinished/group.c b/unfinished/group.c index 869ff04..1c2c02e 100644 --- a/unfinished/group.c +++ b/unfinished/group.c @@ -1201,8 +1201,20 @@ static int check_errors(game_state *state, long *errors) return errs; } -static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds, - int x, int y, int button) +static int find_in_sequence(digit *seq, int len, digit n) +{ + int i; + + for (i = 0; i < len; i++) + if (seq[i] == n) + return i; + + assert(!"Should never get here"); + return -1; +} + +static char *interpret_move(game_state *state, game_ui *ui, + const game_drawstate *ds, int x, int y, int button) { int w = state->par.w; int tx, ty; @@ -1292,7 +1304,11 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds, } if (IS_CURSOR_MOVE(button)) { - move_cursor(button, &ui->hx, &ui->hy, w, w, 0); + int cx = find_in_sequence(state->sequence, w, ui->hx); + int cy = find_in_sequence(state->sequence, w, ui->hy); + move_cursor(button, &cx, &cy, w, w, 0); + ui->hx = state->sequence[cx]; + ui->hy = state->sequence[cy]; ui->hshow = ui->hcursor = 1; return ""; } @@ -1813,9 +1829,9 @@ static float game_flash_length(game_state *oldstate, game_state *newstate, return 0.0F; } -static int game_is_solved(game_state *state) +static int game_status(game_state *state) { - return state->completed; + return state->completed ? +1 : 0; } static int game_timing_state(game_state *state, game_ui *ui) @@ -1936,7 +1952,7 @@ const struct game thegame = { game_redraw, game_anim_length, game_flash_length, - game_is_solved, + game_status, TRUE, FALSE, game_print_size, game_print, FALSE, /* wants_statusbar */ FALSE, game_timing_state,