routes.clear();
if(lead)
routes.push_back(lead);
+ // TODO Check if eclipsed by lead route
if(r)
routes.push_back(r);
if(planner->get_result()==TrainRoutePlanner::COMPLETE)
{
const list<Route *> &planned_routes = planner->get_routes_for(train);
+
routes.clear();
- routes.push_back(create_lead_route(0, planned_routes.front()));
- routes.insert(routes.end(), planned_routes.begin(), planned_routes.end());
+ Route *lead = create_lead_route(0, planned_routes.front());
+ routes.push_back(lead);
+
+ list<Route *>::const_iterator begin = planned_routes.begin();
+ for(; begin!=planned_routes.end(); ++begin)
+ {
+ const Route::TrackSet &tracks = (*begin)->get_tracks();
+ bool eclipsed = true;
+ for(Route::TrackSet::const_iterator i=tracks.begin(); (eclipsed && i!=tracks.end()); ++i)
+ eclipsed = lead->has_track(**i);
+ if(!eclipsed)
+ break;
+ }
+ routes.insert(routes.end(), begin, planned_routes.end());
+
sequence_points = planner->get_sequence_for(train);
current_sequence = 0;
sequence_check_pending = false;