const Data &data = tracks[Key(track.track(), track.entry())];
const TrackType::Endpoint &ep = track.endpoint();
+
+ float multiplier = get_travel_multiplier(*track, track.entry());
for(unsigned i=0; ep.paths>>i; ++i)
if(ep.has_path(i))
{
continue;
Data &target = tracks[Key(next.track(), next.entry())];
- float dist = data.distance+track->get_type().get_path_length(i);
+ float dist = data.distance+track->get_type().get_path_length(i)*multiplier;
if(target.distance<0 || target.distance>dist)
{
target = Data(dist, data.goal);
return i->second.distance+i->second.goal->base_distance;
}
+float TrainRouteMetric::get_travel_multiplier(const Track &track, unsigned exit) const
+{
+ int pref = track.get_preferred_exit();
+ if(pref>=0 && exit!=static_cast<unsigned>(pref))
+ return 5;
+
+ return 1;
+}
+
TrainRouteMetric::Goal::Goal():
base_distance(0)
iter = iter.next();
}
+ travel_multiplier = info->metrics[waypoint]->get_travel_multiplier(*track, track.reverse(path).entry());
+
update_estimate();
}
delay(other.delay),
duration(other.duration),
waypoint(other.waypoint),
+ travel_multiplier(other.travel_multiplier),
distance_traveled(other.distance_traveled),
remaining_estimate(other.remaining_estimate),
wait_time(other.wait_time),
occupied_tracks->n_tracks -= count_to_free;
}
- distance_traveled += distance;
- remaining_estimate -= distance;
+ distance_traveled += distance*travel_multiplier;
+ remaining_estimate -= distance*travel_multiplier;
}
void TrainRoutePlanner::TrainRoutingState::advance(const Time::TimeDelta &dt)
advance(distance);
offset = 0;
+ travel_multiplier = info->metrics[waypoint]->get_travel_multiplier(*track, track.reverse(path).entry());
}
void TrainRoutePlanner::TrainRoutingState::set_path(unsigned p)
void TrainRoutePlanner::TrainRoutingState::update_estimate()
{
TrackIter iter = track.reverse(path);
- remaining_estimate = info->metrics[waypoint]->get_distance_from(*iter.track(), iter.entry());
+ const TrainRouteMetric *metric = info->metrics[waypoint];
+ remaining_estimate = metric->get_distance_from(*iter, iter.entry());
+ travel_multiplier = metric->get_travel_multiplier(*iter, iter.entry());
if(remaining_estimate>=0)
- remaining_estimate += occupied_tracks->path_length-offset;
+ remaining_estimate += (occupied_tracks->path_length-offset)*travel_multiplier;
}
bool TrainRoutePlanner::TrainRoutingState::is_viable() const