}
float secs = dt/Time::sec;
- // There may be negative delay remaining after previous step.
+ // There may be some delay remaining.
if(delay)
{
secs -= delay/Time::sec;
if(state==MOVING)
advance(info->speed*secs);
else if(state!=ARRIVED)
- wait_time += secs*Time::sec;
+ {
+ float remaining_distance = occupied_tracks->path_length-offset;
+ if(remaining_distance>0)
+ {
+ advance(remaining_distance);
+ wait_time += (secs-remaining_distance/info->speed)*Time::sec;
+ }
+ else
+ wait_time += secs*Time::sec;
+ }
}
void TrainRoutePlanner::TrainRoutingState::advance_track(unsigned next_path)
return;
}
- train.advance_track(0);
+ if(train.state==MOVING)
+ train.advance_track(0);
+ else
+ {
+ new_steps.push_back(next);
+ return;
+ }
const TrackType::Endpoint &entry_ep = train.track.endpoint();
if(train.critical)