* Merges the refit_masks of all articulated parts. * @param engine the first part * @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask * @param union_mask returns bit mask of CargoTypes which are a refit option for at least one articulated part * @param intersection_mask returns bit mask of CargoTypes which are a refit opti
| 220 | * @param intersection_mask returns bit mask of CargoTypes which are a refit option for every articulated part (with default capacity > 0) |
| 221 | */ |
| 222 | void GetArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type, CargoTypes *union_mask, CargoTypes *intersection_mask) |
| 223 | { |
| 224 | const Engine *e = Engine::Get(engine); |
| 225 | CargoTypes veh_cargoes = GetAvailableVehicleCargoTypes(engine, include_initial_cargo_type); |
| 226 | *union_mask = veh_cargoes; |
| 227 | *intersection_mask = (veh_cargoes != 0) ? veh_cargoes : ALL_CARGOTYPES; |
| 228 | |
| 229 | if (!e->IsGroundVehicle()) return; |
| 230 | if (!e->info.callback_mask.Test(VehicleCallbackMask::ArticEngine)) return; |
| 231 | |
| 232 | for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) { |
| 233 | EngineID artic_engine = GetNextArticulatedPart(i, engine); |
| 234 | if (artic_engine == EngineID::Invalid()) break; |
| 235 | |
| 236 | veh_cargoes = GetAvailableVehicleCargoTypes(artic_engine, include_initial_cargo_type); |
| 237 | *union_mask |= veh_cargoes; |
| 238 | if (veh_cargoes != 0) *intersection_mask &= veh_cargoes; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * Ors the refit_masks of all articulated parts. |
no test coverage detected