Update to 12.0-beta2

This commit is contained in:
dP
2021-08-19 23:05:31 +03:00
parent 7ade3d06e6
commit c9765f712f
45 changed files with 396 additions and 104 deletions

View File

@@ -218,6 +218,12 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next)
/* A link is at least partly restricted if a vehicle can't load at its source. */
EdgeUpdateMode restricted_mode = (cur->GetLoadType() & OLFB_NO_LOAD) == 0 ?
EUM_UNRESTRICTED : EUM_RESTRICTED;
Station *st_to = Station::GetIfValid(next_station);
/* This estimates the travel time of the link as the time needed
* to travel between the stations at half the max speed of the consist.
* The result is in tiles/tick (= 2048 km-ish/h). */
uint32 time_estimate = (st_to != nullptr) ?
DistanceManhattan(st->xy, st_to->xy) * 4096U / this->vehicle->GetDisplayMaxSpeed() : 0;
/* If the vehicle is currently full loading, increase the capacities at the station
* where it is loading by an estimate of what it would have transported if it wasn't
@@ -231,15 +237,15 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next)
uint effective_capacity = cargo_quantity * this->vehicle->load_unload_ticks;
if (effective_capacity > (uint)this->vehicle->orders.list->GetTotalDuration()) {
IncreaseStats(st, c, next_station, effective_capacity /
this->vehicle->orders.list->GetTotalDuration(), 0,
this->vehicle->orders.list->GetTotalDuration(), 0, 0,
EUM_INCREASE | restricted_mode);
} else if (RandomRange(this->vehicle->orders.list->GetTotalDuration()) < effective_capacity) {
IncreaseStats(st, c, next_station, 1, 0, EUM_INCREASE | restricted_mode);
IncreaseStats(st, c, next_station, 1, 0, 0, EUM_INCREASE | restricted_mode);
} else {
IncreaseStats(st, c, next_station, cargo_quantity, 0, EUM_REFRESH | restricted_mode);
IncreaseStats(st, c, next_station, cargo_quantity, 0, time_estimate, EUM_REFRESH | restricted_mode);
}
} else {
IncreaseStats(st, c, next_station, cargo_quantity, 0, EUM_REFRESH | restricted_mode);
IncreaseStats(st, c, next_station, cargo_quantity, 0, time_estimate, EUM_REFRESH | restricted_mode);
}
}
}