if(estimated_wait)
estimated_wait = max(estimated_wait-secs*Time::sec, Time::zero);
- if(state==MOVING)
+ float distance = info->speed*secs;
+ float remaining_on_track = occupied_tracks->path_length-offset;
+ if(state==MOVING || distance<remaining_on_track)
advance(info->speed*secs);
else if(state!=ARRIVED)
{
- float remaining_distance = occupied_tracks->path_length-offset;
- if(remaining_distance>0)
+ if(remaining_on_track>0)
{
- advance(remaining_distance);
- wait_time += (secs-remaining_distance/info->speed)*Time::sec;
+ advance(remaining_on_track);
+ wait_time += (secs-remaining_on_track/info->speed)*Time::sec;
}
else
wait_time += secs*Time::sec;