]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/trainrouteplanner.cpp
Eliminate the one step delay in adding tracks to routes
[r2c2.git] / source / libr2c2 / trainrouteplanner.cpp
index b4f01ab6a860084901add49d3ab21de3405d49d0..30d9f5e482ee054aa4a5dee7df770abbddd743a7 100644 (file)
@@ -133,7 +133,7 @@ void TrainRoutePlanner::finalize_plan()
        {
                i->routes.clear();
                i->sequence.clear();
-               for(unsigned j=0; j<3; ++j)
+               for(unsigned j=0; j<2; ++j)
                        i->track_history[j] = 0;
        }
 
@@ -168,16 +168,13 @@ void TrainRoutePlanner::finalize_plan()
                                route = new Route(j->info->train->get_layout());
                                route->set_name("Router");
                                route->set_temporary(true);
-                               for(unsigned k=2; k>0; --k)
-                                       if(history[k])
-                                               route->add_track(*history[k]);
+                               for(unsigned k=0; (k<2 && history[k]); ++k)
+                                       route->add_track(*history[k]);
                                j->info->routes.push_front(route);
                        }
 
-                       if(history[0])
-                               route->add_track(*history[0]);
-                       for(unsigned k=2; k>0; --k)
-                               history[k] = history[k-1];
+                       route->add_track(*j->track.track());
+                       history[1] = history[0];
                        history[0] = j->track.track();
 
                        bool waitable = j->track.endpoint().paths!=j->track->get_type().get_paths();