]> git.tdb.fi Git - r2c2.git/commitdiff
Update routes for all involved trains when planning completes
authorMikko Rasa <tdb@tdb.fi>
Tue, 3 Feb 2015 15:21:33 +0000 (17:21 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 3 Feb 2015 15:21:33 +0000 (17:21 +0200)
Sequencing is likely to have changed even if routes haven't.

source/libr2c2/trainrouter.cpp

index d1cb6ff4a3a9b8eca35c439edcf8db3258e6e17b..01205fa834a3fc5575a334be2f67ed8a47109cf4 100644 (file)
@@ -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<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());
-                               sequence_points = planner->get_sequence_for(train);
-                               current_sequence = 0;
-                               sequence_check_pending = false;
-
-                               route_changed();
-                       }
-                       planner = 0;
+                       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());
+                       sequence_points = planner->get_sequence_for(train);
+                       current_sequence = 0;
+                       sequence_check_pending = false;
+
+                       route_changed();
                }
+               planner = 0;
        }
 
        if(sequence_check_pending)