Fix re-routing of unrelated cargo when removing invalidated link graph flow
This commit is contained in:
@@ -4094,6 +4094,31 @@ void RerouteCargo(Station *st, CargoID c, StationID avoid, StationID avoid2)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reroute cargo of type c from source at station st or in any vehicles unloading there.
|
||||
* Make sure the cargo's new next hop is neither "avoid" nor "avoid2".
|
||||
* @param st Station to be rerouted at.
|
||||
* @param c Type of cargo.
|
||||
* @param source Source station.
|
||||
* @param avoid Original next hop of cargo, avoid this.
|
||||
* @param avoid2 Another station to be avoided when rerouting.
|
||||
*/
|
||||
void RerouteCargoFromSource(Station *st, CargoID c, StationID source, StationID avoid, StationID avoid2)
|
||||
{
|
||||
GoodsEntry &ge = st->goods[c];
|
||||
|
||||
/* Reroute cargo in station. */
|
||||
ge.cargo.RerouteFromSource(UINT_MAX, &ge.cargo, source, avoid, avoid2, &ge);
|
||||
|
||||
/* Reroute cargo staged to be transferred. */
|
||||
for (Vehicle *v : st->loading_vehicles) {
|
||||
for (; v != nullptr; v = v->Next()) {
|
||||
if (v->cargo_type != c) continue;
|
||||
v->cargo.RerouteFromSource(UINT_MAX, &v->cargo, source, avoid, avoid2, &ge);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
btree::btree_set<VehicleID> _delete_stale_links_vehicle_cache;
|
||||
|
||||
void ClearDeleteStaleLinksVehicleCache()
|
||||
|
Reference in New Issue
Block a user