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.

[originally from svn r5892]
This commit is contained in:
Simon Tatham
2005-06-01 07:01:32 +00:00
parent 695b6be363
commit 5b5fc1417b
2 changed files with 39 additions and 19 deletions

View File

@ -1221,7 +1221,7 @@ int main(int argc, char **argv)
fprintf(stderr, "%s: %s\n", argv[0], err); fprintf(stderr, "%s: %s\n", argv[0], err);
return 1; 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; int w = p->w, h = p->h, i, j, done_any, max;

56
solo.c
View File

@ -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; tx = (x + TILE_SIZE - BORDER) / TILE_SIZE - 1;
ty = (y + TILE_SIZE - BORDER) / TILE_SIZE - 1; ty = (y + TILE_SIZE - BORDER) / TILE_SIZE - 1;
if (tx >= 0 && tx < cr && ty >= 0 && ty < cr && if (tx >= 0 && tx < cr && ty >= 0 && ty < cr) {
(button == LEFT_BUTTON || button == RIGHT_BUTTON)) { if (button == LEFT_BUTTON) {
/* if (from->immutable[ty*cr+tx]) {
* Prevent pencil-mode highlighting of a filled square. ui->hx = ui->hy = -1;
*/ } else if (tx == ui->hx && ty == ui->hy && ui->hpencil == 0) {
if (button == RIGHT_BUTTON && from->grid[ty*cr+tx]) ui->hx = ui->hy = -1;
return NULL; } else {
ui->hx = tx;
if (tx == ui->hx && ty == ui->hy) { ui->hy = ty;
ui->hx = ui->hy = -1; ui->hpencil = 0;
} else { }
ui->hx = tx; return from; /* UI activity occurred */
ui->hy = ty; }
} if (button == RIGHT_BUTTON) {
ui->hpencil = (button == RIGHT_BUTTON); /*
return from; /* UI activity occurred */ * 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 && 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 == ' ') if (button == ' ')
n = 0; 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]) 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 * 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); fprintf(stderr, "%s: %s\n", argv[0], err);
return 1; return 1;
} }
s = new_game(p, desc); s = new_game(NULL, p, desc);
if (recurse) { if (recurse) {
int ret = rsolve(p->c, p->r, s->grid, NULL, 2); int ret = rsolve(p->c, p->r, s->grid, NULL, 2);