From 54ab7c88976c860ea729e30a175fbc181f0d68cd Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 12 Apr 2014 22:45:27 +0300 Subject: [PATCH] Avoid creating looping routes If th route went past its end, adding the turnout would cause a loop to be created. Trying to add the next track would then throw bad_chain. --- source/libr2c2/trainrouteplanner.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/libr2c2/trainrouteplanner.cpp b/source/libr2c2/trainrouteplanner.cpp index 69a3bbe..dbdf293 100644 --- a/source/libr2c2/trainrouteplanner.cpp +++ b/source/libr2c2/trainrouteplanner.cpp @@ -85,7 +85,18 @@ void TrainRoutePlanner::create_routes(const RoutingStep &goal) continue; Route *route = j->info->routes.front(); - if(route->has_track(*j->track)) + bool start_new_route = route->has_track(*j->track); + if(!start_new_route) + { + unsigned nls = j->track->get_n_link_slots(); + for(unsigned k=0; (!start_new_route && ktrack->get_link(k); + start_new_route = (link && link!=history[0] && route->has_track(*link)); + } + } + + if(start_new_route) { route = new Route(j->info->train->get_layout()); route->set_name("Router"); -- 2.43.0