- unsigned cur_route = 0;
- unsigned tid = track->get_turnout_id();
- if(tid)
- {
- Turnout &turnout = trfc_mgr.get_control().get_turnout(tid);
- cur_route = turnout.get_route();
- }
-
- if(len)
- *len += track->get_type().get_route_length(cur_route);
-
- int other_ep = track->traverse(track_ep, cur_route);
- if(other_ep<0)
- return -1;
-
- for(unsigned i=0; i<endpoints.size(); ++i)
- if(endpoints[i].track==track && endpoints[i].track_ep==static_cast<unsigned>(other_ep))
- return i;
+ unsigned path = (route ? route->get_path(*t_iter) : t_iter->get_active_path());
+ result += t_iter->get_type().get_path_length(path);