1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-20 19:02:41 +01:00

Fix: Smooth outliers in unbunching round trip calculations (#12513)

This commit is contained in:
Tyler Trahan
2024-04-17 15:03:53 -04:00
committed by Loïc Guilloux
parent b64cd74a0c
commit b5c2357dfe

View File

@@ -1664,7 +1664,14 @@ void VehicleEnterDepot(Vehicle *v)
/* If we've entered our unbunching depot, record the round trip duration. */
if (v->current_order.GetDepotActionType() & ODATFB_UNBUNCH && v->depot_unbunching_last_departure > 0) {
v->round_trip_time = (TimerGameTick::counter - v->depot_unbunching_last_departure);
TimerGameTick::Ticks measured_round_trip = TimerGameTick::counter - v->depot_unbunching_last_departure;
if (v->round_trip_time == 0) {
/* This might be our first round trip. */
v->round_trip_time = measured_round_trip;
} else {
/* If we have a previous trip, smooth the effects of outlier trip calculations caused by jams or other interference. */
v->round_trip_time = Clamp(measured_round_trip, (v->round_trip_time / 2), ClampTo<TimerGameTick::Ticks>(v->round_trip_time * 2));
}
}
v->current_order.MakeDummy();