From: Mikko Rasa Date: Tue, 3 Feb 2015 15:29:22 +0000 (+0200) Subject: Skip routes that are completely covered by the lead route X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7ee0b97b7bea5b1b315d3d7847e15b987b0751f5;p=r2c2.git Skip routes that are completely covered by the lead route Advance_to_track throws a fit if no advancement happens from one route to the next. --- diff --git a/source/libr2c2/trainrouter.cpp b/source/libr2c2/trainrouter.cpp index 01205fa..a0f30e9 100644 --- a/source/libr2c2/trainrouter.cpp +++ b/source/libr2c2/trainrouter.cpp @@ -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 &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::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;