From: Mikko Rasa Date: Sat, 12 Apr 2014 19:45:27 +0000 (+0300) Subject: Avoid creating looping routes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=54ab7c88976c860ea729e30a175fbc181f0d68cd;p=r2c2.git 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. --- 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");