From 1ed685b5c161e3ecc94da05bbecb501f3b4a3818 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 9 Feb 2025 20:16:16 +0000 Subject: [PATCH] Codechange: Use EnumBitSet.Any(). (#13512) --- src/newgrf.cpp | 12 ++++++------ src/pathfinder/yapf/yapf_costrail.hpp | 2 +- src/saveload/afterload.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/newgrf.cpp b/src/newgrf.cpp index ede6313cb7..cb87315c06 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -1300,7 +1300,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint first, uint last, int prop, B case 0x28: // Cargo classes allowed _gted[e->index].cargo_allowed = CargoClasses{buf.ReadWord()}; - _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != CargoClasses{}); + _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed.Any()); _gted[e->index].defaultcargo_grf = _cur.grffile; break; @@ -1497,7 +1497,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint first, uint last, int prop, B case 0x1D: // Cargo classes allowed _gted[e->index].cargo_allowed = CargoClasses{buf.ReadWord()}; - _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != CargoClasses{}); + _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed.Any()); _gted[e->index].defaultcargo_grf = _cur.grffile; break; @@ -1690,7 +1690,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint first, uint last, int prop, B case 0x18: // Cargo classes allowed _gted[e->index].cargo_allowed = CargoClasses{buf.ReadWord()}; - _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != CargoClasses{}); + _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed.Any()); _gted[e->index].defaultcargo_grf = _cur.grffile; break; @@ -1879,7 +1879,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint first, uint last, int pro case 0x18: // Cargo classes allowed _gted[e->index].cargo_allowed = CargoClasses{buf.ReadWord()}; - _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed != CargoClasses{}); + _gted[e->index].UpdateRefittability(_gted[e->index].cargo_allowed.Any()); _gted[e->index].defaultcargo_grf = _cur.grffile; break; @@ -9123,7 +9123,7 @@ static void CalculateRefitMasks() _gted[engine].ctt_exclude_mask = original_known_cargoes; } } - _gted[engine].UpdateRefittability(_gted[engine].cargo_allowed != CargoClasses{}); + _gted[engine].UpdateRefittability(_gted[engine].cargo_allowed.Any()); if (IsValidCargoType(ei->cargo_type)) ClrBit(_gted[engine].ctt_exclude_mask, ei->cargo_type); } @@ -9138,7 +9138,7 @@ static void CalculateRefitMasks() * Note: After applying the translations, the vehicle may end up carrying no defined cargo. It becomes unavailable in that case. */ only_defaultcargo = _gted[engine].refittability != GRFTempEngineData::NONEMPTY; - if (_gted[engine].cargo_allowed != CargoClasses{}) { + if (_gted[engine].cargo_allowed.Any()) { /* Build up the list of cargo types from the set cargo classes. */ for (const CargoSpec *cs : CargoSpec::Iterate()) { if (cs->classes.Any(_gted[engine].cargo_allowed) && cs->classes.All(_gted[engine].cargo_allowed_required)) SetBit(mask, cs->Index()); diff --git a/src/pathfinder/yapf/yapf_costrail.hpp b/src/pathfinder/yapf/yapf_costrail.hpp index 4c24ff066d..65e0c59648 100644 --- a/src/pathfinder/yapf/yapf_costrail.hpp +++ b/src/pathfinder/yapf/yapf_costrail.hpp @@ -546,7 +546,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th } /* Any other reason bit set? */ - if (end_segment_reason != EndSegmentReasons{}) { + if (end_segment_reason.Any()) { break; } diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 53a4705e5a..4e75b995cd 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -3202,7 +3202,7 @@ bool AfterLoadGame() if (c->settings.renew_keep_length) wagon_removal.Set(c->index); } for (Group *g : Group::Iterate()) { - if (g->flags != GroupFlags{}) { + if (g->flags.Any()) { /* Convert old replace_protection value to flag. */ g->flags = GroupFlag::ReplaceProtection; }