* 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. */
| 4142 | * @param avoid2 Another station to be avoided when rerouting. |
| 4143 | */ |
| 4144 | void 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 |
no test coverage detected