* Check if an engine is refittable. * Note: Likely you want to use IsArticulatedVehicleRefittable(). * @param engine index of the engine to check. * @return true if the engine is refittable. */
| 1285 | * @return true if the engine is refittable. |
| 1286 | */ |
| 1287 | bool IsEngineRefittable(EngineID engine) |
| 1288 | { |
| 1289 | const Engine *e = Engine::GetIfValid(engine); |
| 1290 | |
| 1291 | /* check if it's an engine that is in the engine array */ |
| 1292 | if (e == nullptr) return false; |
| 1293 | |
| 1294 | if (!e->CanCarryCargo()) return false; |
| 1295 | |
| 1296 | const EngineInfo *ei = &e->info; |
| 1297 | if (ei->refit_mask == 0) return false; |
| 1298 | |
| 1299 | /* Are there suffixes? |
| 1300 | * Note: This does not mean the suffixes are actually available for every consist at any time. */ |
| 1301 | if (ei->callback_mask.Test(VehicleCallbackMask::CargoSuffix)) return true; |
| 1302 | |
| 1303 | /* Is there any cargo except the default cargo? */ |
| 1304 | CargoType default_cargo = e->GetDefaultCargoType(); |
| 1305 | CargoTypes default_cargo_mask = 0; |
| 1306 | SetBit(default_cargo_mask, default_cargo); |
| 1307 | return IsValidCargoType(default_cargo) && ei->refit_mask != default_cargo_mask; |
| 1308 | } |
| 1309 | |
| 1310 | /** |
| 1311 | * Check for engines that have an appropriate availability. |
no test coverage detected