From: simon Date: Wed, 23 Feb 2011 20:05:40 +0000 (+0000) Subject: Patch from Chris Moore to improve the generality of X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/commitdiff_plain/d84df751171cf7bc126a081faaf562d89ef5e78d 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. git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9106 cda61777-01e9-0310-a592-d414129be87e --- 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) {