1
0
Fork 0

Fix: Smooth outliers in unbunching round trip calculations

pull/12513/head
Tyler Trahan 2024-04-16 22:34:27 -04:00
parent 257d312a58
commit 557cc4d14f
1 changed files with 8 additions and 1 deletions

View File

@ -1666,7 +1666,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();