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.
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 && k<nls); ++k)
+ {
+ Track *link = j->track->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");