From 6c4ddb242ac69d339796a1b33e41c0d0a0b66740 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 30 Jan 2025 21:03:43 +0000 Subject: [PATCH] Codechange: Use EnumBitSet for EngineMiscFlags. --- src/autoreplace_cmd.cpp | 2 +- src/economy.cpp | 2 +- src/engine.cpp | 2 +- src/engine_type.h | 36 ++++++++++++++++++++---------------- src/newgrf.cpp | 18 +++++++++--------- src/newgrf_engine.cpp | 4 ++-- src/order_gui.cpp | 2 +- src/saveload/afterload.cpp | 2 +- src/table/engines.h | 12 ++++++------ src/train_cmd.cpp | 8 ++++---- src/vehicle.cpp | 10 +++++----- src/vehicle_cmd.cpp | 2 +- src/vehicle_gui.cpp | 2 +- 13 files changed, 53 insertions(+), 49 deletions(-) diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 46f4d6b2de..c1bb851064 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -83,7 +83,7 @@ bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company) if ((GetRoadTypeInfo(e_from->u.road.roadtype)->powered_roadtypes & GetRoadTypeInfo(e_to->u.road.roadtype)->powered_roadtypes) == ROADTYPES_NONE) return false; /* make sure that we do not replace a tram with a normal road vehicles or vice versa */ - if (HasBit(e_from->info.misc_flags, EF_ROAD_TRAM) != HasBit(e_to->info.misc_flags, EF_ROAD_TRAM)) return false; + if (e_from->info.misc_flags.Test(EngineMiscFlag::RoadIsTram) != e_to->info.misc_flags.Test(EngineMiscFlag::RoadIsTram)) return false; break; case VEH_AIRCRAFT: diff --git a/src/economy.cpp b/src/economy.cpp index 67ab8b3368..2992ac3332 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1346,7 +1346,7 @@ static uint GetLoadAmount(Vehicle *v) } /* Scale load amount the same as capacity */ - if (HasBit(e->info.misc_flags, EF_NO_DEFAULT_CARGO_MULTIPLIER) && !air_mail) load_amount = CeilDiv(load_amount * CargoSpec::Get(v->cargo_type)->multiplier, 0x100); + if (e->info.misc_flags.Test(EngineMiscFlag::NoDefaultCargoMultiplier) && !air_mail) load_amount = CeilDiv(load_amount * CargoSpec::Get(v->cargo_type)->multiplier, 0x100); /* Zero load amount breaks a lot of things. */ return std::max(1u, load_amount); diff --git a/src/engine.cpp b/src/engine.cpp index 66de7b2173..170f144e26 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -205,7 +205,7 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16_t *mail_capacity) const if (!this->CanCarryCargo()) return 0; - bool new_multipliers = HasBit(this->info.misc_flags, EF_NO_DEFAULT_CARGO_MULTIPLIER); + bool new_multipliers = this->info.misc_flags.Test(EngineMiscFlag::NoDefaultCargoMultiplier); CargoType default_cargo = this->GetDefaultCargoType(); CargoType cargo_type = (v != nullptr) ? v->cargo_type : default_cargo; diff --git a/src/engine_type.h b/src/engine_type.h index 17e66daeb6..8d9ca848e7 100644 --- a/src/engine_type.h +++ b/src/engine_type.h @@ -141,6 +141,25 @@ enum class ExtraEngineFlag : uint8_t { }; using ExtraEngineFlags = EnumBitSet; +/** + * EngineInfo.misc_flags is a bitmask, with the following values + */ +enum class EngineMiscFlag : uint8_t { + RailTilts = 0, ///< Rail vehicle tilts in curves + RoadIsTram = 0, ///< Road vehicle is a tram/light rail vehicle + + Uses2CC = 1, ///< Vehicle uses two company colours + + RailIsMU = 2, ///< Rail vehicle is a multiple-unit (DMU/EMU) + RailFlips = 3, ///< Rail vehicle has old depot-flip handling + + AutoRefit = 4, ///< Automatic refitting is allowed + NoDefaultCargoMultiplier = 5, ///< Use the new capacity algorithm. The default cargotype of the vehicle does not affect capacity multipliers. CB 15 is also called in purchase list. + NoBreakdownSmoke = 6, ///< Do not show black smoke during a breakdown. + SpriteStack = 7, ///< Draw vehicle by stacking multiple sprites. +}; +using EngineMiscFlags = EnumBitSet; + /** * Information about a vehicle * @see table/engines.h @@ -156,7 +175,7 @@ struct EngineInfo { std::variant cargo_label; CargoTypes refit_mask; uint8_t refit_cost; - uint8_t misc_flags; ///< Miscellaneous flags. @see EngineMiscFlags + EngineMiscFlags misc_flags; ///< Miscellaneous flags. @see EngineMiscFlags VehicleCallbackMasks callback_mask; ///< Bitmask of vehicle callbacks that have to be called int8_t retire_early; ///< Number of years early to retire vehicle ExtraEngineFlags extra_flags; @@ -165,21 +184,6 @@ struct EngineInfo { EngineID variant_id; ///< Engine variant ID. If set, will be treated specially in purchase lists. }; -/** - * EngineInfo.misc_flags is a bitmask, with the following values - */ -enum EngineMiscFlags : uint8_t { - EF_RAIL_TILTS = 0, ///< Rail vehicle tilts in curves - EF_ROAD_TRAM = 0, ///< Road vehicle is a tram/light rail vehicle - EF_USES_2CC = 1, ///< Vehicle uses two company colours - EF_RAIL_IS_MU = 2, ///< Rail vehicle is a multiple-unit (DMU/EMU) - EF_RAIL_FLIPS = 3, ///< Rail vehicle has old depot-flip handling - EF_AUTO_REFIT = 4, ///< Automatic refitting is allowed - EF_NO_DEFAULT_CARGO_MULTIPLIER = 5, ///< Use the new capacity algorithm. The default cargotype of the vehicle does not affect capacity multipliers. CB 15 is also called in purchase list. - EF_NO_BREAKDOWN_SMOKE = 6, ///< Do not show black smoke during a breakdown. - EF_SPRITE_STACK = 7, ///< Draw vehicle by stacking multiple sprites. -}; - /** * Engine.flags is a bitmask, with the following values. */ diff --git a/src/newgrf.cpp b/src/newgrf.cpp index a1c9da216b..7910d63a2a 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -1294,8 +1294,8 @@ static ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, B break; case 0x27: // Miscellaneous flags - ei->misc_flags = buf.ReadByte(); - _loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); + ei->misc_flags = static_cast(buf.ReadByte()); + _loaded_newgrf_features.has_2CC |= ei->misc_flags.Test(EngineMiscFlag::Uses2CC); break; case 0x28: // Cargo classes allowed @@ -1491,8 +1491,8 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, B break; case 0x1C: // Miscellaneous flags - ei->misc_flags = buf.ReadByte(); - _loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); + ei->misc_flags = static_cast(buf.ReadByte()); + _loaded_newgrf_features.has_2CC |= ei->misc_flags.Test(EngineMiscFlag::Uses2CC); break; case 0x1D: // Cargo classes allowed @@ -1684,8 +1684,8 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint first, uint last, int prop, B break; case 0x17: // Miscellaneous flags - ei->misc_flags = buf.ReadByte(); - _loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); + ei->misc_flags = static_cast(buf.ReadByte()); + _loaded_newgrf_features.has_2CC |= ei->misc_flags.Test(EngineMiscFlag::Uses2CC); break; case 0x18: // Cargo classes allowed @@ -1873,8 +1873,8 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint first, uint last, int pro break; case 0x17: // Miscellaneous flags - ei->misc_flags = buf.ReadByte(); - _loaded_newgrf_features.has_2CC |= HasBit(ei->misc_flags, EF_USES_2CC); + ei->misc_flags = static_cast(buf.ReadByte()); + _loaded_newgrf_features.has_2CC |= ei->misc_flags.Test(EngineMiscFlag::Uses2CC); break; case 0x18: // Cargo classes allowed @@ -10016,7 +10016,7 @@ static void AfterLoadGRFs() e->u.road.max_speed = _gted[e->index].rv_max_speed * 4; } - RoadTramType rtt = HasBit(e->info.misc_flags, EF_ROAD_TRAM) ? RTT_TRAM : RTT_ROAD; + RoadTramType rtt = e->info.misc_flags.Test(EngineMiscFlag::RoadIsTram) ? RTT_TRAM : RTT_ROAD; const GRFFile *file = e->GetGRF(); if (file == nullptr || _gted[e->index].roadtramtype == 0) { diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 46dc748b33..f86605ff99 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -1076,7 +1076,7 @@ void GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction directio VehicleResolverObject object(engine, v, VehicleResolverObject::WO_CACHED, false, CBID_NO_CALLBACK); result->Clear(); - bool sprite_stack = HasBit(EngInfo(engine)->misc_flags, EF_SPRITE_STACK); + bool sprite_stack = EngInfo(engine)->misc_flags.Test(EngineMiscFlag::SpriteStack); uint max_stack = sprite_stack ? lengthof(result->seq) : 1; for (uint stack = 0; stack < max_stack; ++stack) { object.ResetState(); @@ -1110,7 +1110,7 @@ void GetRotorOverrideSprite(EngineID engine, const struct Aircraft *v, EngineIma result->Clear(); uint rotor_pos = v == nullptr || rotor_in_gui ? 0 : v->Next()->Next()->state; - bool sprite_stack = HasBit(e->info.misc_flags, EF_SPRITE_STACK); + bool sprite_stack = e->info.misc_flags.Test(EngineMiscFlag::SpriteStack); uint max_stack = sprite_stack ? lengthof(result->seq) : 1; for (uint stack = 0; stack < max_stack; ++stack) { object.ResetState(); diff --git a/src/order_gui.cpp b/src/order_gui.cpp index c0091ae110..680c369cf9 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -800,7 +800,7 @@ private: this->can_do_autorefit = false; for (const Vehicle *w = this->vehicle; w != nullptr; w = w->IsGroundVehicle() ? w->Next() : nullptr) { if (IsEngineRefittable(w->engine_type)) this->can_do_refit = true; - if (HasBit(Engine::Get(w->engine_type)->info.misc_flags, EF_AUTO_REFIT)) this->can_do_autorefit = true; + if (Engine::Get(w->engine_type)->info.misc_flags.Test(EngineMiscFlag::AutoRefit)) this->can_do_autorefit = true; } } diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 20eb12dd1c..9f373a521f 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1940,7 +1940,7 @@ bool AfterLoadGame() /* Remove all trams from savegames without tram support. * There would be trams without tram track under causing crashes sooner or later. */ for (RoadVehicle *v : RoadVehicle::Iterate()) { - if (v->First() == v && HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM)) { + if (v->First() == v && EngInfo(v->engine_type)->misc_flags.Test(EngineMiscFlag::RoadIsTram)) { ShowErrorMessage(STR_WARNING_LOADGAME_REMOVED_TRAMS, INVALID_STRING_ID, WL_CRITICAL); delete v; } diff --git a/src/table/engines.h b/src/table/engines.h index eef9c0d8d6..5f673ef7d7 100644 --- a/src/table/engines.h +++ b/src/table/engines.h @@ -24,7 +24,7 @@ * @param f Bitmask of the climates * @note the 5 between b and f is the load amount */ -#define MT(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, TimerGameCalendar::Year{c}, TimerGameCalendar::Year{d}, b, 5, f, INVALID_CARGO, e, 0, 8, 0, VehicleCallbackMasks{}, 0, {}, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE } +#define MT(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, TimerGameCalendar::Year{c}, TimerGameCalendar::Year{d}, b, 5, f, INVALID_CARGO, e, 0, 8, EngineMiscFlags{}, VehicleCallbackMasks{}, 0, {}, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE } /** * Writes the properties of a multiple-unit train into the EngineInfo struct. @@ -37,7 +37,7 @@ * @param f Bitmask of the climates * @note the 5 between b and f is the load amount */ -#define MM(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, TimerGameCalendar::Year{c}, TimerGameCalendar::Year{d}, b, 5, f, INVALID_CARGO, e, 0, 8, 1 << EF_RAIL_IS_MU, VehicleCallbackMasks{}, 0, {}, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE } +#define MM(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, TimerGameCalendar::Year{c}, TimerGameCalendar::Year{d}, b, 5, f, INVALID_CARGO, e, 0, 8, EngineMiscFlags{EngineMiscFlag::RailIsMU}, VehicleCallbackMasks{}, 0, {}, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE } /** * Writes the properties of a train carriage into the EngineInfo struct. @@ -50,7 +50,7 @@ * @see MT * @note the 5 between b and f is the load amount */ -#define MW(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, TimerGameCalendar::Year{c}, TimerGameCalendar::Year{d}, b, 5, f, INVALID_CARGO, e, 0, 8, 0, VehicleCallbackMasks{}, 0, {}, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE } +#define MW(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, TimerGameCalendar::Year{c}, TimerGameCalendar::Year{d}, b, 5, f, INVALID_CARGO, e, 0, 8, EngineMiscFlags{}, VehicleCallbackMasks{}, 0, {}, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE } /** * Writes the properties of a road vehicle into the EngineInfo struct. @@ -63,7 +63,7 @@ * @param f Bitmask of the climates * @note the 5 between b and f is the load amount */ -#define MR(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, TimerGameCalendar::Year{c}, TimerGameCalendar::Year{d}, b, 5, f, INVALID_CARGO, e, 0, 8, 0, VehicleCallbackMasks{}, 0, {}, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE } +#define MR(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, TimerGameCalendar::Year{c}, TimerGameCalendar::Year{d}, b, 5, f, INVALID_CARGO, e, 0, 8, EngineMiscFlags{}, VehicleCallbackMasks{}, 0, {}, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE } /** * Writes the properties of a ship into the EngineInfo struct. @@ -75,7 +75,7 @@ * @param f Bitmask of the climates * @note the 10 between b and f is the load amount */ -#define MS(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, TimerGameCalendar::Year{c}, TimerGameCalendar::Year{d}, b, 10, f, INVALID_CARGO, e, 0, 8, 0, VehicleCallbackMasks{}, 0, {}, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE } +#define MS(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, TimerGameCalendar::Year{c}, TimerGameCalendar::Year{d}, b, 10, f, INVALID_CARGO, e, 0, 8, EngineMiscFlags{}, VehicleCallbackMasks{}, 0, {}, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE } /** * Writes the properties of an aeroplane into the EngineInfo struct. @@ -86,7 +86,7 @@ * @param e Bitmask of the climates * @note the 20 between b and e is the load amount */ -#define MA(a, b, c, d, e) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, TimerGameCalendar::Year{c}, TimerGameCalendar::Year{d}, b, 20, e, INVALID_CARGO, CT_INVALID, 0, 8, 0, VehicleCallbackMasks{}, 0, {}, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE } +#define MA(a, b, c, d, e) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, TimerGameCalendar::Year{c}, TimerGameCalendar::Year{d}, b, 20, e, INVALID_CARGO, CT_INVALID, 0, 8, EngineMiscFlags{}, VehicleCallbackMasks{}, 0, {}, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE } /* Climates * T = Temperate diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 7ce88b4662..795a9fba8f 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -150,7 +150,7 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes) const Engine *e_u = u->GetEngine(); const RailVehicleInfo *rvi_u = &e_u->u.rail; - if (!HasBit(e_u->info.misc_flags, EF_RAIL_TILTS)) train_can_tilt = false; + if (!e_u->info.misc_flags.Test(EngineMiscFlag::RailTilts)) train_can_tilt = false; min_curve_speed_mod = std::min(min_curve_speed_mod, u->GetCurveSpeedModifier()); /* Cache wagon override sprite group. nullptr is returned if there is none */ @@ -439,7 +439,7 @@ void Train::UpdateAcceleration() int Train::GetCursorImageOffset() const { - if (this->gcache.cached_veh_length != 8 && HasBit(this->flags, VRF_REVERSE_DIRECTION) && !HasBit(EngInfo(this->engine_type)->misc_flags, EF_RAIL_FLIPS)) { + if (this->gcache.cached_veh_length != 8 && HasBit(this->flags, VRF_REVERSE_DIRECTION) && !EngInfo(this->engine_type)->misc_flags.Test(EngineMiscFlag::RailFlips)) { int reference_width = TRAININFO_DEFAULT_VEHICLE_WIDTH; const Engine *e = this->GetEngine(); @@ -469,7 +469,7 @@ int Train::GetDisplayImageWidth(Point *offset) const } if (offset != nullptr) { - if (HasBit(this->flags, VRF_REVERSE_DIRECTION) && !HasBit(EngInfo(this->engine_type)->misc_flags, EF_RAIL_FLIPS)) { + if (HasBit(this->flags, VRF_REVERSE_DIRECTION) && !EngInfo(this->engine_type)->misc_flags.Test(EngineMiscFlag::RailFlips)) { offset->x = ScaleSpriteTrad(((int)this->gcache.cached_veh_length - (int)VEHICLE_LENGTH / 2) * reference_width / (int)VEHICLE_LENGTH); } else { offset->x = ScaleSpriteTrad(reference_width) / 2; @@ -1474,7 +1474,7 @@ void Train::UpdateDeltaXY() this->y_bb_offs = 0; /* Set if flipped and engine is NOT flagged with custom flip handling. */ - int flipped = HasBit(this->flags, VRF_REVERSE_DIRECTION) && !HasBit(EngInfo(this->engine_type)->misc_flags, EF_RAIL_FLIPS); + int flipped = HasBit(this->flags, VRF_REVERSE_DIRECTION) && !EngInfo(this->engine_type)->misc_flags.Test(EngineMiscFlag::RailFlips); /* If flipped and vehicle length is odd, we need to adjust the bounding box offset slightly. */ int flip_offs = flipped && (this->gcache.cached_veh_length & 1); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index d2204548e5..b3861dbc58 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1391,7 +1391,7 @@ bool Vehicle::HandleBreakdown() (train_or_ship ? SND_3A_BREAKDOWN_TRAIN_SHIP_TOYLAND : SND_35_BREAKDOWN_ROADVEHICLE_TOYLAND), this); } - if (!(this->vehstatus & VS_HIDDEN) && !HasBit(EngInfo(this->engine_type)->misc_flags, EF_NO_BREAKDOWN_SMOKE)) { + if (!(this->vehstatus & VS_HIDDEN) && !EngInfo(this->engine_type)->misc_flags.Test(EngineMiscFlag::NoBreakdownSmoke)) { EffectVehicle *u = CreateEffectVehicleRel(this, 4, 4, 5, EV_BREAKDOWN_SMOKE); if (u != nullptr) u->animation_state = this->breakdown_delay * 2; } @@ -1990,7 +1990,7 @@ LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_ if (parent_engine_type == INVALID_ENGINE) { return LS_PASSENGER_WAGON_STEAM; } else { - bool is_mu = HasBit(EngInfo(parent_engine_type)->misc_flags, EF_RAIL_IS_MU); + bool is_mu = EngInfo(parent_engine_type)->misc_flags.Test(EngineMiscFlag::RailIsMU); switch (RailVehInfo(parent_engine_type)->engclass) { default: NOT_REACHED(); case EC_STEAM: return LS_PASSENGER_WAGON_STEAM; @@ -2004,7 +2004,7 @@ LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_ return LS_FREIGHT_WAGON; } } else { - bool is_mu = HasBit(e->info.misc_flags, EF_RAIL_IS_MU); + bool is_mu = e->info.misc_flags.Test(EngineMiscFlag::RailIsMU); switch (e->u.rail.engclass) { default: NOT_REACHED(); @@ -2028,7 +2028,7 @@ LiveryScheme GetEngineLiveryScheme(EngineID engine_type, EngineID parent_engine_ assert(IsValidCargoType(cargo_type)); /* 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)) { + if (e->info.misc_flags.Test(EngineMiscFlag::RoadIsTram)) { /* Tram */ return IsCargoInClass(cargo_type, CC_PASSENGERS) ? LS_PASSENGER_TRAM : LS_FREIGHT_TRAM; } else { @@ -2116,7 +2116,7 @@ static PaletteID GetEngineColourMap(EngineID engine_type, CompanyID company, Eng } } - bool twocc = HasBit(e->info.misc_flags, EF_USES_2CC); + bool twocc = e->info.misc_flags.Test(EngineMiscFlag::Uses2CC); if (map == PAL_NONE) map = twocc ? (PaletteID)SPR_2CCMAP_BASE : (PaletteID)PALETTE_RECOLOUR_START; diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 2e2a26e6c2..b13ceaf6ea 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -386,7 +386,7 @@ static std::tuple RefitVehicle(Vehicle /* If the vehicle is not refittable, or does not allow automatic refitting, * count its capacity nevertheless if the cargo matches */ - bool refittable = HasBit(e->info.refit_mask, new_cargo_type) && (!auto_refit || HasBit(e->info.misc_flags, EF_AUTO_REFIT)); + bool refittable = HasBit(e->info.refit_mask, new_cargo_type) && (!auto_refit || e->info.misc_flags.Test(EngineMiscFlag::AutoRefit)); if (!refittable && v->cargo_type != new_cargo_type) { uint amount = e->DetermineCapacity(v, nullptr); if (amount > 0) cargo_capacities[v->cargo_type] += amount; diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 2f5f298fe2..8fcee1f9ec 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -795,7 +795,7 @@ struct RefitWindow : public Window { /* Skip this engine if it does not carry anything */ if (!e->CanCarryCargo()) continue; /* Skip this engine if we build the list for auto-refitting and engine doesn't allow it. */ - if (this->auto_refit && !HasBit(e->info.misc_flags, EF_AUTO_REFIT)) continue; + if (this->auto_refit && !e->info.misc_flags.Test(EngineMiscFlag::AutoRefit)) continue; /* Loop through all cargoes in the refit mask */ for (const auto &cs : _sorted_cargo_specs) {