diff options
| author | Simon Tatham <anakin@pobox.com> | 2012-05-14 18:42:19 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2012-05-14 18:42:19 +0000 |
| commit | 12cd1ee23522e8659d3dbf303aa5fe50064534d7 (patch) | |
| tree | 6c72c1f288df2061066d8b36f31e5a4c35c8987d | |
| parent | 1e71966e759acf08d9fe40b72232ab3b3630ba0f (diff) | |
| download | puzzles-12cd1ee23522e8659d3dbf303aa5fe50064534d7.zip puzzles-12cd1ee23522e8659d3dbf303aa5fe50064534d7.tar.gz puzzles-12cd1ee23522e8659d3dbf303aa5fe50064534d7.tar.bz2 puzzles-12cd1ee23522e8659d3dbf303aa5fe50064534d7.tar.xz | |
Patch from Jonas Koelker to improve Filling's error highlighting: as
well as marking a region as wrong if it has too many squares for the
number written in it, this patch now causes a region to be marked
wrong if it has too few squares _and no liberties_, so that it can't
just be one the user is intending to enlarge later.
[originally from svn r9534]
| -rw-r--r-- | filling.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -1494,19 +1494,35 @@ static void draw_grid(drawing *dr, game_drawstate *ds, game_state *state, /* * Determine what we need to draw in this square. */ - int v = state->board[y*w+x]; + int i = y*w+x, v = state->board[i]; int flags = 0; if (flashy || !shading) { /* clear all background flags */ - } else if (ui && ui->sel && ui->sel[y*w+x]) { + } else if (ui && ui->sel && ui->sel[i]) { flags |= HIGH_BG; } else if (v) { - int size = dsf_size(ds->dsf_scratch, y*w+x); + int size = dsf_size(ds->dsf_scratch, i); if (size == v) flags |= CORRECT_BG; else if (size > v) flags |= ERROR_BG; + else { + int rt = dsf_canonify(ds->dsf_scratch, i), j; + for (j = 0; j < w*h; ++j) { + int k; + if (dsf_canonify(ds->dsf_scratch, j) != rt) continue; + for (k = 0; k < 4; ++k) { + const int xx = j % w + dx[k], yy = j / w + dy[k]; + if (xx >= 0 && xx < w && yy >= 0 && yy < h && + state->board[yy*w + xx] == EMPTY) + goto noflag; + } + } + flags |= ERROR_BG; + noflag: + ; + } } if (ui && ui->cur_visible && x == ui->cur_x && y == ui->cur_y) flags |= CURSOR_SQ; |