mirror of https://github.com/OpenTTD/OpenTTD
Cleanup: simplify LinkRefresher::RefreshStats
parent
b0fd51a5ef
commit
25b3ff6423
|
@ -203,6 +203,7 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next)
|
|||
StationID next_station = next->GetDestination();
|
||||
Station *st = Station::GetIfValid(cur->GetDestination());
|
||||
if (st != nullptr && next_station != INVALID_STATION && next_station != st->index) {
|
||||
Station *st_to = Station::Get(next_station);
|
||||
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
||||
/* Refresh the link and give it a minimum capacity. */
|
||||
|
||||
|
@ -211,19 +212,17 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next)
|
|||
|
||||
/* If not allowed to merge link graphs, make sure the stations are
|
||||
* already in the same link graph. */
|
||||
if (!this->allow_merge && st->goods[c].link_graph != Station::Get(next_station)->goods[c].link_graph) {
|
||||
if (!this->allow_merge && st->goods[c].link_graph != st_to->goods[c].link_graph) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
uint32 time_estimate = DistanceManhattan(st->xy, st_to->xy) * 4096U / this->vehicle->GetDisplayMaxSpeed();
|
||||
|
||||
/* 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
|
||||
|
|
Loading…
Reference in New Issue