path = trfc_mgr.get_control().get_turnout(cur_track->get_turnout_id()).get_path();
offset += get_real_speed(loco.get_speed())*(dt/Time::sec);
- if(offset>cur_track->get_type().get_path_length(path))
+ float path_len = cur_track->get_type().get_path_length(path);
+ if(offset>path_len)
{
- int out = cur_track->traverse(cur_track_ep, path);
- if(out>=0)
+ unsigned out = cur_track->traverse(cur_track_ep, path);
+ Track *next = cur_track->get_link(out);
+
+ bool ok = false;
+ for(list<BlockRef>::const_iterator i=cur_blocks.begin(); (!ok && i!=cur_blocks.end()); ++i)
+ ok = i->block->get_tracks().count(next);
+
+ if(ok)
{
- Track *next = cur_track->get_link(out);
if(next)
cur_track_ep = next->get_endpoint_by_link(*cur_track);
cur_track = next;
offset = 0;
}
else
- cur_track = 0;
+ offset = path_len-0.001;
}
if(cur_track)