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();
|
StationID next_station = next->GetDestination();
|
||||||
Station *st = Station::GetIfValid(cur->GetDestination());
|
Station *st = Station::GetIfValid(cur->GetDestination());
|
||||||
if (st != nullptr && next_station != INVALID_STATION && next_station != st->index) {
|
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++) {
|
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
||||||
/* Refresh the link and give it a minimum capacity. */
|
/* 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
|
/* If not allowed to merge link graphs, make sure the stations are
|
||||||
* already in the same link graph. */
|
* 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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A link is at least partly restricted if a vehicle can't load at its source. */
|
/* 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 ?
|
EdgeUpdateMode restricted_mode = (cur->GetLoadType() & OLFB_NO_LOAD) == 0 ?
|
||||||
EUM_UNRESTRICTED : EUM_RESTRICTED;
|
EUM_UNRESTRICTED : EUM_RESTRICTED;
|
||||||
Station *st_to = Station::GetIfValid(next_station);
|
|
||||||
/* This estimates the travel time of the link as the time needed
|
/* 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.
|
* to travel between the stations at half the max speed of the consist.
|
||||||
* The result is in tiles/tick (= 2048 km-ish/h). */
|
* The result is in tiles/tick (= 2048 km-ish/h). */
|
||||||
uint32 time_estimate = (st_to != nullptr) ?
|
uint32 time_estimate = DistanceManhattan(st->xy, st_to->xy) * 4096U / this->vehicle->GetDisplayMaxSpeed();
|
||||||
DistanceManhattan(st->xy, st_to->xy) * 4096U / this->vehicle->GetDisplayMaxSpeed() : 0;
|
|
||||||
|
|
||||||
/* If the vehicle is currently full loading, increase the capacities at the station
|
/* 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
|
* where it is loading by an estimate of what it would have transported if it wasn't
|
||||||
|
|
Loading…
Reference in New Issue