aboutsummaryrefslogtreecommitdiff
path: root/grid.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2011-02-23 20:05:40 +0000
committerSimon Tatham <anakin@pobox.com>2011-02-23 20:05:40 +0000
commit1a628aebd8893001bc3a2e9dbc3e2dc7432b08e4 (patch)
treeda61581432ce6944dcde02529cb308cb9d9bcba7 /grid.c
parentb2e4437d5ba18bd98b5cb5d22c823457c71792c9 (diff)
downloadpuzzles-1a628aebd8893001bc3a2e9dbc3e2dc7432b08e4.zip
puzzles-1a628aebd8893001bc3a2e9dbc3e2dc7432b08e4.tar.gz
puzzles-1a628aebd8893001bc3a2e9dbc3e2dc7432b08e4.tar.bz2
puzzles-1a628aebd8893001bc3a2e9dbc3e2dc7432b08e4.tar.xz
Patch from Chris Moore to improve the generality of
grid_nearest_edge(), by having it search harder for a better dot to move to in the first loop. [originally from svn r9106]
Diffstat (limited to 'grid.c')
-rw-r--r--grid.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/grid.c b/grid.c
index dcc384a..1415e61 100644
--- a/grid.c
+++ b/grid.c
@@ -141,13 +141,11 @@ grid_edge *grid_nearest_edge(grid *g, int x, int y)
grid_dot *d = f->dots[j];
if (d == cur) continue;
new_dist = SQ((long)d->x - (long)x) + SQ((long)d->y - (long)y);
- if (new_dist < dist) {
+ if (new_dist < dist) { /* found closer dot */
new = d;
- break; /* found closer dot */
+ dist = new_dist;
}
}
- if (new != cur)
- break; /* found closer dot */
}
if (new == cur) {