_near_point_dist_squared = near_dist_squared;
for (wnext = wcurr = _next_way; wcurr != _route.wtail; wcurr++) {
- if (wcurr->point < near
+ if (wcurr->point < near || (wcurr->point == near && quick
+ && (_next_wpt && (DISTANCE_SQUARED(_pos, *near) > _next_way_dist_squared
+ && DISTANCE_SQUARED(_pos, *_next_wpt) < _next_wpt_dist_squared))))
/* Okay, this else if expression warrants explanation. If the
* nearest track point happens to be a waypoint, then we want to
* check if we have "passed" that waypoint. To check this, we
* decreasing, then we have passed the waypoint, and thus we
* should skip it. Note that if there is no _next_wpt, then
* there is no next waypoint, so we do not skip it in that case. */
- || (wcurr->point == near && quick
- && (_next_wpt && (DISTANCE_SQUARED(_pos, *near) > _next_way_dist_squared
- && DISTANCE_SQUARED(_pos, *_next_wpt) < _next_wpt_dist_squared))))
wnext = wcurr + 1;
else
break;
}
- if (wnext == _route.wtail && (wnext->point < near
- || (wnext->point == near && quick
+ if (wnext == _route.wtail && (wnext->point < near || (wnext->point == near && quick
&& (_next_wpt && (DISTANCE_SQUARED (_pos, *near) > _next_way_dist_squared
&& DISTANCE_SQUARED(_pos, *_next_wpt) < _next_wpt_dist_squared)))))
{
_near_point++;
/* Initialize _next_way. */
-if (_route.wtail == _route.whead - 1
- || (_autoroute_data.enabled && _route.wtail == _route.whead))
+if (_route.wtail == _route.whead - 1 || (_autoroute_data.enabled && _route.wtail == _route.whead))
_next_way = NULL;
else
/* We have at least one waypoint. */