From 39d682c944efb7520daadef63b75f73181d21262 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 1 Jun 2005 07:01:32 +0000 Subject: [PATCH] Patches from Richard B for Solo: - prevent highlighting a clue square at all - enable easier switching between highlight types by not requiring a left-click highlight to be left-click-cancelled before right-clicking, and vice versa - fix bit-rot in -DSTANDALONE_SOLVER Also one of mine: - replicate Richard's -DSTANDALONE_SOLVER fix in Pattern, where it was also broken. git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5892 cda61777-01e9-0310-a592-d414129be87e --- pattern.c | 2 +- solo.c | 56 ++++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/pattern.c b/pattern.c index c7c06f1..26201e8 100644 --- a/pattern.c +++ b/pattern.c @@ -1221,7 +1221,7 @@ int main(int argc, char **argv) fprintf(stderr, "%s: %s\n", argv[0], err); return 1; } - s = new_game(p, desc); + s = new_game(NULL, p, desc); { int w = p->w, h = p->h, i, j, done_any, max; diff --git a/solo.c b/solo.c index 563217a..2cd406a 100644 --- a/solo.c +++ b/solo.c @@ -1833,22 +1833,36 @@ static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds, tx = (x + TILE_SIZE - BORDER) / TILE_SIZE - 1; ty = (y + TILE_SIZE - BORDER) / TILE_SIZE - 1; - if (tx >= 0 && tx < cr && ty >= 0 && ty < cr && - (button == LEFT_BUTTON || button == RIGHT_BUTTON)) { - /* - * Prevent pencil-mode highlighting of a filled square. - */ - if (button == RIGHT_BUTTON && from->grid[ty*cr+tx]) - return NULL; - - if (tx == ui->hx && ty == ui->hy) { - ui->hx = ui->hy = -1; - } else { - ui->hx = tx; - ui->hy = ty; - } - ui->hpencil = (button == RIGHT_BUTTON); - return from; /* UI activity occurred */ + if (tx >= 0 && tx < cr && ty >= 0 && ty < cr) { + if (button == LEFT_BUTTON) { + if (from->immutable[ty*cr+tx]) { + ui->hx = ui->hy = -1; + } else if (tx == ui->hx && ty == ui->hy && ui->hpencil == 0) { + ui->hx = ui->hy = -1; + } else { + ui->hx = tx; + ui->hy = ty; + ui->hpencil = 0; + } + return from; /* UI activity occurred */ + } + if (button == RIGHT_BUTTON) { + /* + * Pencil-mode highlighting for non filled squares. + */ + if (from->grid[ty*cr+tx] == 0) { + if (tx == ui->hx && ty == ui->hy && ui->hpencil) { + ui->hx = ui->hy = -1; + } else { + ui->hpencil = 1; + ui->hx = tx; + ui->hy = ty; + } + } else { + ui->hx = ui->hy = -1; + } + return from; /* UI activity occurred */ + } } if (ui->hx != -1 && ui->hy != -1 && @@ -1864,8 +1878,14 @@ static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds, if (button == ' ') n = 0; + /* + * Can't overwrite this square. In principle this shouldn't + * happen anyway because we should never have even been + * able to highlight the square, but it never hurts to be + * careful. + */ if (from->immutable[ui->hy*cr+ui->hx]) - return NULL; /* can't overwrite this square */ + return NULL; /* * Can't make pencil marks in a filled square. In principle @@ -2267,7 +2287,7 @@ int main(int argc, char **argv) fprintf(stderr, "%s: %s\n", argv[0], err); return 1; } - s = new_game(p, desc); + s = new_game(NULL, p, desc); if (recurse) { int ret = rsolve(p->c, p->r, s->grid, NULL, 2); -- 2.11.0