MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / RerouteCargo

Function RerouteCargo

src/station_cmd.cpp:4144–4158  ·  view source on GitHub ↗

* Reroute cargo of type c 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 cargo Type of cargo. * @param avoid Original next hop of cargo, avoid this. * @param avoid2 Another station to be avoided when rerouting. */

Source from the content-addressed store, hash-verified

4142 * @param avoid2 Another station to be avoided when rerouting.
4143 */
4144void RerouteCargo(Station *st, CargoType cargo, StationID avoid, StationID avoid2)
4145{
4146 GoodsEntry &ge = st->goods[cargo];
4147
4148 /* Reroute cargo in station. */
4149 if (ge.HasData()) ge.GetData().cargo.Reroute(UINT_MAX, &ge.GetData().cargo, avoid, avoid2, &ge);
4150
4151 /* Reroute cargo staged to be transferred. */
4152 for (Vehicle *v : st->loading_vehicles) {
4153 for (Vehicle *u = v; u != nullptr; u = u->Next()) {
4154 if (u->cargo_type != cargo) continue;
4155 u->cargo.Reroute(UINT_MAX, &u->cargo, avoid, avoid2, &ge);
4156 }
4157 }
4158}
4159
4160/**
4161 * Check all next hops of cargo packets in this station for existence of a

Callers 3

DeleteStaleLinksFunction · 0.85
~StationMethod · 0.85
~LinkGraphJobMethod · 0.85

Calls 3

RerouteMethod · 0.80
HasDataMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected