]> git.tdb.fi Git - r2c2.git/commitdiff
Ensure that remaining estimate is negative if the waypoint is unreachable
authorMikko Rasa <tdb@tdb.fi>
Thu, 12 Feb 2015 14:54:27 +0000 (16:54 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 12 Feb 2015 15:52:19 +0000 (17:52 +0200)
source/libr2c2/trainrouteplanner.cpp

index 9f19ffcdfb06ae470447ebeb5f01154845ae49ea..ca85ac74084dace04e65d24d48cec278b9c67350 100644 (file)
@@ -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