From: Mikko Rasa Date: Thu, 12 Feb 2015 14:54:27 +0000 (+0200) Subject: Ensure that remaining estimate is negative if the waypoint is unreachable X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=862d8bea6d31e6fe9a60747e0b9559f77e72bf44;p=r2c2.git Ensure that remaining estimate is negative if the waypoint is unreachable --- diff --git a/source/libr2c2/trainrouteplanner.cpp b/source/libr2c2/trainrouteplanner.cpp index 9f19ffc..ca85ac7 100644 --- a/source/libr2c2/trainrouteplanner.cpp +++ b/source/libr2c2/trainrouteplanner.cpp @@ -443,9 +443,9 @@ void TrainRoutePlanner::TrainRoutingState::advance_track(unsigned next_path) void TrainRoutePlanner::TrainRoutingState::update_estimate() { TrackIter iter = track.reverse(path); - float distance = info->metrics[waypoint]->get_distance_from(*iter.track(), iter.entry()); - distance += track->get_type().get_path_length(path)-offset; - remaining_estimate = distance; + remaining_estimate = info->metrics[waypoint]->get_distance_from(*iter.track(), iter.entry()); + if(remaining_estimate>=0) + remaining_estimate += track->get_type().get_path_length(path)-offset; } bool TrainRoutePlanner::TrainRoutingState::is_viable() const