summaryrefslogtreecommitdiff
path: root/src/linkgraph/refresh.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/linkgraph/refresh.cpp')
-rw-r--r--src/linkgraph/refresh.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/linkgraph/refresh.cpp b/src/linkgraph/refresh.cpp
index 430e29072..78fdd1643 100644
--- a/src/linkgraph/refresh.cpp
+++ b/src/linkgraph/refresh.cpp
@@ -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);
}
}
}