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

Function IsEngineRefittable

src/engine.cpp:1287–1308  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

1285 * @return true if the engine is refittable.
1286 */
1287bool 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.

Callers 3

UpdateAutoRefitStateMethod · 0.85
IsVehicleRefittableFunction · 0.85

Calls 5

SetBitFunction · 0.85
IsValidCargoTypeFunction · 0.85
CanCarryCargoMethod · 0.80
TestMethod · 0.80
GetDefaultCargoTypeMethod · 0.80

Tested by

no test coverage detected