From: Mikko Rasa Date: Tue, 3 Feb 2015 15:21:33 +0000 (+0200) Subject: Update routes for all involved trains when planning completes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=ef70d27737dd8333aef142e4810dc223b7bc7696;p=r2c2.git Update routes for all involved trains when planning completes Sequencing is likely to have changed even if routes haven't. --- diff --git a/source/libr2c2/trainrouter.cpp b/source/libr2c2/trainrouter.cpp index d1cb6ff..01205fa 100644 --- a/source/libr2c2/trainrouter.cpp +++ b/source/libr2c2/trainrouter.cpp @@ -218,27 +218,25 @@ void TrainRouter::tick(const Time::TimeDelta &dt) delay = Time::zero; } - if(destination_changed) + if(destination_changed && !planner) + start_planning(train.get_layout()); + + if(planner && planner->get_result()!=TrainRoutePlanner::PENDING) { - if(!planner) - start_planning(train.get_layout()); - else if(planner->get_result()!=TrainRoutePlanner::PENDING) + destination_changed = false; + if(planner->get_result()==TrainRoutePlanner::COMPLETE) { - destination_changed = false; - 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()); - sequence_points = planner->get_sequence_for(train); - current_sequence = 0; - sequence_check_pending = false; - - route_changed(); - } - planner = 0; + 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()); + sequence_points = planner->get_sequence_for(train); + current_sequence = 0; + sequence_check_pending = false; + + route_changed(); } + planner = 0; } if(sequence_check_pending)