]> git.tdb.fi Git - r2c2.git/commitdiff
Skip routes that are completely covered by the lead route
authorMikko Rasa <tdb@tdb.fi>
Tue, 3 Feb 2015 15:29:22 +0000 (17:29 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 3 Feb 2015 15:29:22 +0000 (17:29 +0200)
Advance_to_track throws a fit if no advancement happens from one route to
the next.

source/libr2c2/trainrouter.cpp

index 01205fa834a3fc5575a334be2f67ed8a47109cf4..a0f30e92ae43d9a7f2bde2a6a85046245d836dfa 100644 (file)
@@ -62,6 +62,7 @@ bool TrainRouter::set_route(const Route *r)
        routes.clear();
        if(lead)
                routes.push_back(lead);
+       // TODO Check if eclipsed by lead route
        if(r)
                routes.push_back(r);
 
@@ -227,9 +228,23 @@ void TrainRouter::tick(const Time::TimeDelta &dt)
                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;