Feature: [Linkgraph] Prioritize faster routes for passengers, mail and express cargo
Passengers usually prefer fast paths to short paths. Average travel times of links are updated in real-time for use in Dijkstra's algorithm, and newer travel times weigh more, just like capacities.
This commit is contained in:

committed by
Michael Lutz

parent
6acf204d14
commit
977604ef08
@@ -3737,7 +3737,7 @@ void DeleteStaleLinks(Station *from)
|
||||
* @param usage Usage to add to link stat.
|
||||
* @param mode Update mode to be applied.
|
||||
*/
|
||||
void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, EdgeUpdateMode mode)
|
||||
void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, uint32 time, EdgeUpdateMode mode)
|
||||
{
|
||||
GoodsEntry &ge1 = st->goods[cargo];
|
||||
Station *st2 = Station::Get(next_station_id);
|
||||
@@ -3779,7 +3779,7 @@ void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint c
|
||||
}
|
||||
}
|
||||
if (lg != nullptr) {
|
||||
(*lg)[ge1.node].UpdateEdge(ge2.node, capacity, usage, mode);
|
||||
(*lg)[ge1.node].UpdateEdge(ge2.node, capacity, usage, time, mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3789,7 +3789,7 @@ void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint c
|
||||
* @param front First vehicle in the consist.
|
||||
* @param next_station_id Station the consist will be travelling to next.
|
||||
*/
|
||||
void IncreaseStats(Station *st, const Vehicle *front, StationID next_station_id)
|
||||
void IncreaseStats(Station *st, const Vehicle *front, StationID next_station_id, uint32 time)
|
||||
{
|
||||
for (const Vehicle *v = front; v != nullptr; v = v->Next()) {
|
||||
if (v->refit_cap > 0) {
|
||||
@@ -3800,7 +3800,7 @@ void IncreaseStats(Station *st, const Vehicle *front, StationID next_station_id)
|
||||
* As usage is not such an important figure anyway we just
|
||||
* ignore the additional cargo then.*/
|
||||
IncreaseStats(st, v->cargo_type, next_station_id, v->refit_cap,
|
||||
std::min<uint>(v->refit_cap, v->cargo.StoredCount()), EUM_INCREASE);
|
||||
std::min<uint>(v->refit_cap, v->cargo.StoredCount()), time, EUM_INCREASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user