From ef70d27737dd8333aef142e4810dc223b7bc7696 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 3 Feb 2015 17:21:33 +0200 Subject: [PATCH] Update routes for all involved trains when planning completes Sequencing is likely to have changed even if routes haven't. --- source/libr2c2/trainrouter.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) 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) -- 2.45.2