X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/b760b8bdf1ff5b603e3076c8e21cf246d08937f7..f4ab9854cee90c9515eb56ced7df7871a41ba2ad:/pearl.c diff --git a/pearl.c b/pearl.c index c018d5a..248d64e 100644 --- a/pearl.c +++ b/pearl.c @@ -1335,6 +1335,8 @@ static int new_clues(game_params *params, random_state *rs, break; /* got it */ } + debug(("%d %dx%d loops before finished puzzle.\n", ngen, w, h)); + return ngen; } @@ -1343,14 +1345,12 @@ static char *new_game_desc(game_params *params, random_state *rs, { char *grid, *clues; char *desc; - int ngen, w = params->w, h = params->h, i, j; + int w = params->w, h = params->h, i, j; grid = snewn(w*h, char); clues = snewn(w*h, char); - ngen = new_clues(params, rs, clues, grid); - - debug(("%d %dx%d loops before finished puzzle.\n", ngen, w, h)); + new_clues(params, rs, clues, grid); desc = snewn(w * h + 1, char); for (i = j = 0; i < w*h; i++) { @@ -1907,7 +1907,7 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds, int gx = FROMCOORD(x), gy = FROMCOORD(y), i; char tmpbuf[80]; - if (button == LEFT_BUTTON) { + if (IS_MOUSE_DOWN(button)) { if (!INGRID(state, gx, gy)) return NULL; ui->clickx = x; ui->clicky = y; @@ -1917,7 +1917,7 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds, return ""; } - if (IS_MOUSE_DRAG(button)) { + if (button == LEFT_DRAG) { update_ui_drag(state, ui, gx, gy); return ""; } @@ -1953,11 +1953,25 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds, return buf ? buf : ""; } else { - /* Click (or tiny drag). Work out which edge we were closest to. */ - int cx = COORD(gx) + TILE_SIZE/2, cy = COORD(gy) + TILE_SIZE/2; + /* Click (or tiny drag). Work out which edge we were + * closest to. */ + int cx, cy; int gx2, gy2, l1, l2, ismark = (button == RIGHT_RELEASE); char movec = ismark ? 'M' : 'F'; + /* + * We process clicks based on the mouse-down location, + * because that's more natural for a user to carefully + * control than the mouse-up. + */ + x = ui->clickx; + y = ui->clicky; + + gx = FROMCOORD(x); + gy = FROMCOORD(y); + cx = COORD(gx) + TILE_SIZE/2; + cy = COORD(gy) + TILE_SIZE/2; + if (!INGRID(state, gx, gy)) return ""; if (max(abs(x-cx),abs(y-cy)) < TILE_SIZE/4) {