- 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
+{
+ if(remaining_estimate<0)
+ return false;
+ if(critical && state==BLOCKED)
+ return false;
+ return true;