Codechange: Use IsValidCargoID/IsValidCargoType.

IsValidCargoType() is used only for unmapped IDs.
This commit is contained in:
Peter Nelson
2023-05-04 11:29:21 +01:00
committed by PeterN
parent c4ca6a0f74
commit 76516d7f70
30 changed files with 130 additions and 134 deletions

View File

@@ -232,7 +232,7 @@ bool Vehicle::NeedsServicing() const
if (IsArticulatedVehicleCarryingDifferentCargoes(v, &cargo_type)) continue;
/* Did the old vehicle carry anything? */
if (cargo_type != CT_INVALID) {
if (IsValidCargoID(cargo_type)) {
/* We can't refit the vehicle to carry the cargo we want */
if (!HasBit(available_cargo_types, cargo_type)) continue;
}
@@ -1884,8 +1884,8 @@ LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_
/* Note: Luckily cargo_type is not needed for engines */
}
if (cargo_type == CT_INVALID) cargo_type = e->GetDefaultCargoType();
if (cargo_type == CT_INVALID) cargo_type = CT_GOODS; // The vehicle does not carry anything, let's pick some freight cargo
if (!IsValidCargoID(cargo_type)) cargo_type = e->GetDefaultCargoType();
if (!IsValidCargoID(cargo_type)) cargo_type = CT_GOODS; // The vehicle does not carry anything, let's pick some freight cargo
if (e->u.rail.railveh_type == RAILVEH_WAGON) {
if (!CargoSpec::Get(cargo_type)->is_freight) {
if (parent_engine_type == INVALID_ENGINE) {
@@ -1924,8 +1924,8 @@ LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_
e = Engine::Get(engine_type);
cargo_type = v->First()->cargo_type;
}
if (cargo_type == CT_INVALID) cargo_type = e->GetDefaultCargoType();
if (cargo_type == CT_INVALID) cargo_type = CT_GOODS; // The vehicle does not carry anything, let's pick some freight cargo
if (!IsValidCargoID(cargo_type)) cargo_type = e->GetDefaultCargoType();
if (!IsValidCargoID(cargo_type)) cargo_type = CT_GOODS; // The vehicle does not carry anything, let's pick some freight cargo
/* Important: Use Tram Flag of front part. Luckily engine_type refers to the front part here. */
if (HasBit(e->info.misc_flags, EF_ROAD_TRAM)) {
@@ -1937,8 +1937,8 @@ LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_
}
case VEH_SHIP:
if (cargo_type == CT_INVALID) cargo_type = e->GetDefaultCargoType();
if (cargo_type == CT_INVALID) cargo_type = CT_GOODS; // The vehicle does not carry anything, let's pick some freight cargo
if (!IsValidCargoID(cargo_type)) cargo_type = e->GetDefaultCargoType();
if (!IsValidCargoID(cargo_type)) cargo_type = CT_GOODS; // The vehicle does not carry anything, let's pick some freight cargo
return IsCargoInClass(cargo_type, CC_PASSENGERS) ? LS_PASSENGER_SHIP : LS_FREIGHT_SHIP;
case VEH_AIRCRAFT: