+ return false;
+}
+
+void TrainRouter::get_routers(Layout &layout, vector<TrainRouter *> &routers, TrainRoutePlanner *planner)
+{
+ const map<unsigned, Train *> &trains = layout.get_trains();
+ routers.reserve(trains.size());
+ for(map<unsigned, Train *>::const_iterator i=trains.begin(); i!=trains.end(); ++i)
+ if(TrainRouter *router = i->second->get_ai_of_type<TrainRouter>())
+ if(!planner || router->planner.get()==planner)
+ routers.push_back(router);
+}
+
+void TrainRouter::start_planning(Layout &layout)
+{
+ vector<TrainRouter *> routers;
+ get_routers(layout, routers);
+
+ for(vector<TrainRouter *>::const_iterator i=routers.begin(); i!=routers.end(); ++i)
+ if((*i)->metrics_stale)
+ (*i)->create_metrics();
+
+ RefPtr<TrainRoutePlanner> planner = new TrainRoutePlanner(layout);
+ for(vector<TrainRouter *>::const_iterator i=routers.begin(); i!=routers.end(); ++i)