diff --git a/src/vehicle.cpp b/src/vehicle.cpp --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -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(Engin /* 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(Engin 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(Engin } 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: