--occupied_tracks->n_tracks;
}
- remaining_estimate -= (distance/info->speed)*Time::sec;
- if(remaining_estimate<Time::zero)
- remaining_estimate = Time::zero;
+ remaining_estimate -= distance;
}
void TrainRoutePlanner::TrainRoutingState::advance_track(unsigned next_path)
TrackIter iter = track.reverse(path);
float distance = info->router->get_metric(waypoint).get_distance_from(*iter.track(), iter.entry());
distance += track->get_type().get_path_length(path)-offset;
- remaining_estimate = (distance/info->speed)*Time::sec+delay;
+ remaining_estimate = distance;
}
{
for(vector<TrainRoutingState>::const_iterator i=trains.begin(); i!=trains.end(); ++i)
{
- if(i->remaining_estimate<Time::zero)
- {
- total_estimate = i->remaining_estimate;
- return;
- }
-
- Time::TimeDelta t = time+i->remaining_estimate;
+ Time::TimeDelta t = time+(i->remaining_estimate/i->info->speed)*Time::sec+i->delay;
if(i==trains.begin() || t>total_estimate)
total_estimate = t;
}
if(total_estimate<Time::zero)
return false;
+ for(vector<TrainRoutingState>::const_iterator i=trains.begin(); i!=trains.end(); ++i)
+ if(i->remaining_estimate<0)
+ return false;
+
for(vector<TrainRoutingState>::const_iterator i=trains.begin(); i!=trains.end(); ++i)
if(i->state==MOVING)
return true;