diff --git a/src/openrct2-ui/scripting/ScTileSelection.hpp b/src/openrct2-ui/scripting/ScTileSelection.hpp index 276a25cb66..ed848f0d42 100644 --- a/src/openrct2-ui/scripting/ScTileSelection.hpp +++ b/src/openrct2-ui/scripting/ScTileSelection.hpp @@ -29,7 +29,7 @@ namespace OpenRCT2::Scripting DukValue range_get() const { - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) + if (gMapSelectFlags.has(MapSelectFlag::enable)) { DukObject range(_ctx); @@ -62,12 +62,12 @@ namespace OpenRCT2::Scripting gMapSelectPositionB.x = range->GetRight(); gMapSelectPositionB.y = range->GetBottom(); gMapSelectType = MAP_SELECT_TYPE_FULL; - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); } } else { - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); } MapInvalidateSelectionRect(); } @@ -75,7 +75,7 @@ namespace OpenRCT2::Scripting DukValue tiles_get() const { duk_push_array(_ctx); - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT) + if (gMapSelectFlags.has(MapSelectFlag::enableConstruct)) { duk_uarridx_t index = 0; for (const auto& tile : gMapSelectionTiles) @@ -117,12 +117,12 @@ namespace OpenRCT2::Scripting if (gMapSelectionTiles.empty()) { - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN; + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); + gMapSelectFlags.unset(MapSelectFlag::green); } else { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags.set(MapSelectFlag::enableConstruct); } MapInvalidateMapSelectionTiles(); } diff --git a/src/openrct2-ui/windows/ClearScenery.cpp b/src/openrct2-ui/windows/ClearScenery.cpp index 538a527c7b..d30ffc60ae 100644 --- a/src/openrct2-ui/windows/ClearScenery.cpp +++ b/src/openrct2-ui/windows/ClearScenery.cpp @@ -219,7 +219,7 @@ namespace OpenRCT2::Ui::Windows uint8_t state_changed = 0; MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); auto mapTile = ScreenGetMapXY(screenPos, nullptr); @@ -228,9 +228,9 @@ namespace OpenRCT2::Ui::Windows return state_changed; } - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); state_changed++; } @@ -314,7 +314,7 @@ namespace OpenRCT2::Ui::Windows switch (widgetIndex) { case WIDX_BACKGROUND: - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) + if (gMapSelectFlags.has(MapSelectFlag::enable)) { auto action = GetClearAction(); GameActions::Execute(&action, getGameState()); @@ -331,7 +331,7 @@ namespace OpenRCT2::Ui::Windows case WIDX_BACKGROUND: { auto* windowMgr = GetWindowManager(); - if (windowMgr->FindByClass(WindowClass::Error) == nullptr && (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (windowMgr->FindByClass(WindowClass::Error) == nullptr && (gMapSelectFlags.has(MapSelectFlag::enable))) { auto action = GetClearAction(); GameActions::Execute(&action, getGameState()); @@ -348,7 +348,7 @@ namespace OpenRCT2::Ui::Windows { case WIDX_BACKGROUND: MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); gCurrentToolId = Tool::bulldozer; break; } diff --git a/src/openrct2-ui/windows/EditorParkEntrance.cpp b/src/openrct2-ui/windows/EditorParkEntrance.cpp index df2af7ecd5..e55ec3b66d 100644 --- a/src/openrct2-ui/windows/EditorParkEntrance.cpp +++ b/src/openrct2-ui/windows/EditorParkEntrance.cpp @@ -165,9 +165,7 @@ namespace OpenRCT2::Ui::Windows { MapInvalidateSelectionRect(); MapInvalidateMapSelectionTiles(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags.unset(MapSelectFlag::enable, MapSelectFlag::enableArrow, MapSelectFlag::enableConstruct); CoordsXYZD parkEntrancePosition = PlaceParkEntranceGetMapPosition(screenCoords); if (parkEntrancePosition.IsNull()) { @@ -188,7 +186,7 @@ namespace OpenRCT2::Ui::Windows gMapSelectArrowPosition = parkEntrancePosition; gMapSelectArrowDirection = parkEntrancePosition.direction; - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT | MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.set(MapSelectFlag::enableConstruct, MapSelectFlag::enableArrow); MapInvalidateMapSelectionTiles(); if (gParkEntranceGhostExists && parkEntrancePosition == gParkEntranceGhostPosition) { diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 7e2bf1f914..8adceb7520 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -244,7 +244,7 @@ namespace OpenRCT2::Ui::Windows FootpathUpdateProvisional(); ViewportSetVisibility(ViewportVisibility::Default); MapInvalidateMapSelectionTiles(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); auto* windowMgr = Ui::GetWindowManager(); windowMgr->InvalidateByClass(WindowClass::TopToolbar); @@ -336,7 +336,7 @@ namespace OpenRCT2::Ui::Windows ToolCancel(); FootpathUpdateProvisional(); MapInvalidateMapSelectionTiles(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); _footpathConstructionMode = PathConstructionMode::land; ToolSet(*this, WIDX_CONSTRUCT_ON_LAND, Tool::pathDown); gInputFlags.set(InputFlag::unk6); @@ -353,7 +353,7 @@ namespace OpenRCT2::Ui::Windows ToolCancel(); FootpathUpdateProvisional(); MapInvalidateMapSelectionTiles(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); _footpathConstructionMode = PathConstructionMode::bridgeOrTunnelPick; ToolSet(*this, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, Tool::crosshair); gInputFlags.set(InputFlag::unk6); @@ -597,11 +597,11 @@ namespace OpenRCT2::Ui::Windows gMapSelectArrowDirection = _footpathConstructDirection; if (_provisionalFootpath.flags.has(ProvisionalPathFlag::showArrow)) { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.set(MapSelectFlag::enableArrow); } else { - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); } MapInvalidateTileFull(footpathLoc); } @@ -929,7 +929,7 @@ namespace OpenRCT2::Ui::Windows { if (info.interactionType == ViewportInteractionItem::None || info.Element == nullptr) { - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); FootpathUpdateProvisional(); return kTileSlopeFlat; } @@ -1007,7 +1007,7 @@ namespace OpenRCT2::Ui::Windows void WindowFootpathSetProvisionalPathAtPoint(const ScreenCoordsXY& screenCoords) { MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); // Get current map pos and handle key modifier state auto mapPos = FootpathGetPlacePositionFromScreenPosition(screenCoords); @@ -1023,7 +1023,7 @@ namespace OpenRCT2::Ui::Windows } // Set map selection - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); gMapSelectType = MAP_SELECT_TYPE_FULL; gMapSelectPositionA = *mapPos; gMapSelectPositionB = *mapPos; @@ -1048,7 +1048,7 @@ namespace OpenRCT2::Ui::Windows if (baseZ == 0) { - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); FootpathUpdateProvisional(); return; } @@ -1077,8 +1077,7 @@ namespace OpenRCT2::Ui::Windows TileElement* tileElement; MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enable, MapSelectFlag::enableArrow); auto mapCoords = FootpathBridgeGetInfoFromPos(screenCoords, &direction, &tileElement); if (mapCoords.IsNull()) @@ -1086,8 +1085,7 @@ namespace OpenRCT2::Ui::Windows return; } - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.set(MapSelectFlag::enable, MapSelectFlag::enableArrow); gMapSelectType = MAP_SELECT_TYPE_FULL; gMapSelectPositionA = mapCoords; gMapSelectPositionB = mapCoords; @@ -1419,8 +1417,7 @@ namespace OpenRCT2::Ui::Windows if (_footpathConstructionMode == PathConstructionMode::bridgeOrTunnel) { MapInvalidateMapSelectionTiles(); - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags |= MAP_SELECT_FLAG_GREEN; + gMapSelectFlags.set(MapSelectFlag::enableConstruct, MapSelectFlag::green); int32_t direction = _footpathConstructDirection; gMapSelectionTiles.clear(); @@ -1836,7 +1833,7 @@ namespace OpenRCT2::Ui::Windows { _provisionalFootpath.flags.unset(ProvisionalPathFlag::showArrow); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); MapInvalidateTileFull(gFootpathConstructFromPosition); } FootpathRemoveProvisional(); diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 6f881887c0..ae102c7095 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -976,12 +976,12 @@ namespace OpenRCT2::Ui::Windows MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); auto mapCoords = FootpathGetCoordinatesFromPos({ screenCoords.x, screenCoords.y + 16 }, nullptr, nullptr); if (!mapCoords.IsNull()) { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); gMapSelectType = MAP_SELECT_TYPE_FULL; gMapSelectPositionA = mapCoords; gMapSelectPositionB = mapCoords; diff --git a/src/openrct2-ui/windows/Land.cpp b/src/openrct2-ui/windows/Land.cpp index 5170ca359c..bfca7b80ea 100644 --- a/src/openrct2-ui/windows/Land.cpp +++ b/src/openrct2-ui/windows/Land.cpp @@ -445,7 +445,7 @@ namespace OpenRCT2::Ui::Windows uint8_t state_changed = 0; MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); auto mapTile = ScreenGetMapXY(screenPos, nullptr); @@ -454,9 +454,9 @@ namespace OpenRCT2::Ui::Windows return state_changed; } - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); state_changed++; } @@ -524,7 +524,7 @@ namespace OpenRCT2::Ui::Windows switch (widgetIndex) { case WIDX_BACKGROUND: - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) + if (gMapSelectFlags.has(MapSelectFlag::enable)) { auto surfaceSetStyleAction = GameActions::SurfaceSetStyleAction( { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, @@ -551,7 +551,7 @@ namespace OpenRCT2::Ui::Windows // Custom setting to only change land style instead of raising or lowering land if (_landToolPaintMode) { - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) + if (gMapSelectFlags.has(MapSelectFlag::enable)) { auto surfaceSetStyleAction = GameActions::SurfaceSetStyleAction( { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, @@ -583,7 +583,7 @@ namespace OpenRCT2::Ui::Windows { case WIDX_BACKGROUND: MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); gCurrentToolId = Tool::digDown; break; } @@ -613,7 +613,7 @@ namespace OpenRCT2::Ui::Windows if (gCurrentToolId == Tool::upDownArrow) { - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) return; money64 lower_cost = SelectionLowerLand(0); @@ -632,7 +632,7 @@ namespace OpenRCT2::Ui::Windows std::optional mapTile; uint8_t side{}; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); if (tool_size == 1) { int32_t selectionType; @@ -656,9 +656,9 @@ namespace OpenRCT2::Ui::Windows uint8_t state_changed = 0; - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); state_changed++; } @@ -733,9 +733,9 @@ namespace OpenRCT2::Ui::Windows uint8_t state_changed = 0; - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); state_changed++; } diff --git a/src/openrct2-ui/windows/LandRights.cpp b/src/openrct2-ui/windows/LandRights.cpp index bd9ffd9eb4..6b43894334 100644 --- a/src/openrct2-ui/windows/LandRights.cpp +++ b/src/openrct2-ui/windows/LandRights.cpp @@ -460,7 +460,7 @@ namespace OpenRCT2::Ui::Windows void OnToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override { MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); auto info = GetMapCoordinatesFromPos( screenCoords, EnumsToFlags(ViewportInteractionItem::Terrain, ViewportInteractionItem::Water)); @@ -479,9 +479,9 @@ namespace OpenRCT2::Ui::Windows uint8_t state_changed = 0; - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); state_changed++; } diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index dfd64e3abe..180b26ee4b 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -447,8 +447,7 @@ namespace OpenRCT2::Ui::Windows int32_t direction; TileElement* tileElement; MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enable, MapSelectFlag::enableArrow); auto mapCoords = FootpathBridgeGetInfoFromPos(screenCoords, &direction, &tileElement); if (mapCoords.IsNull()) return; @@ -462,8 +461,7 @@ namespace OpenRCT2::Ui::Windows mapZ += 16; } - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.set(MapSelectFlag::enable, MapSelectFlag::enableArrow); gMapSelectType = MAP_SELECT_TYPE_FULL; gMapSelectPositionA = mapCoords; gMapSelectPositionB = mapCoords; diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index f690680095..610f1f1fe4 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -119,8 +119,8 @@ namespace OpenRCT2::Ui::Windows ViewportSetVisibility(ViewportVisibility::Default); MapInvalidateMapSelectionTiles(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); + gMapSelectFlags.unset(MapSelectFlag::enableArrow); // In order to cancel the yellow arrow correctly the // selection tool should be cancelled. @@ -346,8 +346,8 @@ namespace OpenRCT2::Ui::Windows MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enable); + gMapSelectFlags.unset(MapSelectFlag::enableArrow); CoordsXYZD entranceOrExitCoords = RideGetEntranceOrExitPositionFromScreenPosition(screenCoords); if (entranceOrExitCoords.IsNull()) @@ -403,7 +403,7 @@ namespace OpenRCT2::Ui::Windows _currentTrackSelectionFlags.clearAll(); _rideConstructionNextArrowPulse = 0; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); RideConstructionInvalidateCurrentTrack(); x = _currentTrackBegin.x + (CoordsDirectionDelta[direction].x / 2); diff --git a/src/openrct2-ui/windows/PatrolArea.cpp b/src/openrct2-ui/windows/PatrolArea.cpp index e99f4c44b4..73341625d4 100644 --- a/src/openrct2-ui/windows/PatrolArea.cpp +++ b/src/openrct2-ui/windows/PatrolArea.cpp @@ -159,7 +159,7 @@ namespace OpenRCT2::Ui::Windows return; auto stateChanged = false; - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) stateChanged = true; if (gMapSelectType != MAP_SELECT_TYPE_FULL) @@ -185,7 +185,7 @@ namespace OpenRCT2::Ui::Windows MapInvalidateSelectionRect(); // Update and invalidate new area - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); gMapSelectType = MAP_SELECT_TYPE_FULL; gMapSelectPositionA = posA; gMapSelectPositionB = posB; diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 1ea87feee8..61de5eca7e 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -287,8 +287,8 @@ namespace OpenRCT2::Ui::Windows ViewportSetVisibility(ViewportVisibility::Default); MapInvalidateMapSelectionTiles(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); + gMapSelectFlags.unset(MapSelectFlag::enableArrow); // In order to cancel the yellow arrow correctly the // selection tool should be cancelled. Don't do a tool cancel if @@ -1136,12 +1136,12 @@ namespace OpenRCT2::Ui::Windows break; case WIDX_NEXT_SECTION: RideSelectNextSection(); - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) VirtualFloorSetHeight(_currentTrackBegin.z); break; case WIDX_PREVIOUS_SECTION: RideSelectPreviousSection(); - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) VirtualFloorSetHeight(_currentTrackBegin.z); break; case WIDX_LEFT_CURVE: @@ -2242,8 +2242,8 @@ namespace OpenRCT2::Ui::Windows CoordsXYZ trackPos{}; MapInvalidateMapSelectionTiles(); - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags |= MAP_SELECT_FLAG_GREEN; + gMapSelectFlags.set(MapSelectFlag::enableConstruct); + gMapSelectFlags.set(MapSelectFlag::green); switch (_rideConstructionState) { @@ -2653,8 +2653,8 @@ namespace OpenRCT2::Ui::Windows { RideConstructionInvalidateCurrentTrack(); MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enable); + gMapSelectFlags.unset(MapSelectFlag::enableArrow); CoordsXYZD entranceOrExitCoords = RideGetEntranceOrExitPositionFromScreenPosition(screenCoords); if (gRideEntranceExitPlaceDirection == kInvalidDirection) @@ -2978,7 +2978,7 @@ namespace OpenRCT2::Ui::Windows _currentTrackSelectionFlags.clearAll(); _rideConstructionState = RideConstructionState::Selected; _rideConstructionNextArrowPulse = 0; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); RideSelectNextSection(); } else @@ -3025,7 +3025,7 @@ namespace OpenRCT2::Ui::Windows _currentTrackSelectionFlags.clearAll(); _rideConstructionState = RideConstructionState::Selected; _rideConstructionNextArrowPulse = 0; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); RideSelectPreviousSection(); } else @@ -3260,7 +3260,7 @@ namespace OpenRCT2::Ui::Windows rideIndex, type, direction, liftHillAndAlternativeState, trackPos); WindowRideConstructionUpdateActiveElements(); - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) { // Set height to where the next track piece would begin VirtualFloorSetHeight(_currentTrackBegin.z); @@ -3284,9 +3284,9 @@ namespace OpenRCT2::Ui::Windows direction = DirectionReverse(direction); gMapSelectArrowPosition = trackPos; gMapSelectArrowDirection = direction; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); if (_currentTrackSelectionFlags.has(TrackSelectionFlag::arrow)) - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.set(MapSelectFlag::enableArrow); MapInvalidateTileFull(trackPos); break; } @@ -3334,9 +3334,9 @@ namespace OpenRCT2::Ui::Windows gMapSelectArrowDirection = 7; } } - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); if (_currentTrackSelectionFlags.has(TrackSelectionFlag::arrow)) - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.set(MapSelectFlag::enableArrow); MapInvalidateTileFull(trackPos); break; } @@ -3354,9 +3354,9 @@ namespace OpenRCT2::Ui::Windows int32_t z; MapInvalidateMapSelectionTiles(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enable); + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); + gMapSelectFlags.unset(MapSelectFlag::enableArrow); auto mapCoords = RideGetPlacePositionFromScreenPosition(screenCoords); if (!mapCoords) { @@ -3369,9 +3369,9 @@ namespace OpenRCT2::Ui::Windows if (z == 0) z = MapGetHighestZ(*mapCoords); - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; - gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN; + gMapSelectFlags.set(MapSelectFlag::enableConstruct); + gMapSelectFlags.set(MapSelectFlag::enableArrow); + gMapSelectFlags.unset(MapSelectFlag::green); gMapSelectArrowPosition = CoordsXYZ{ *mapCoords, z }; gMapSelectArrowDirection = _currentTrackPieceDirection; gMapSelectionTiles.clear(); @@ -3414,7 +3414,7 @@ namespace OpenRCT2::Ui::Windows if (_trackPlaceZ == 0) { // Raise z above all slopes and water - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT) + if (gMapSelectFlags.has(MapSelectFlag::enableConstruct)) { int32_t highestZ = 0; for (const auto& selectedTile : gMapSelectionTiles) @@ -3574,17 +3574,17 @@ namespace OpenRCT2::Ui::Windows { MapInvalidateSelectionRect(); MapInvalidateMapSelectionTiles(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enable); + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); + gMapSelectFlags.unset(MapSelectFlag::enableArrow); CoordsXYZD entranceOrExitCoords = RideGetEntranceOrExitPositionFromScreenPosition(screenCoords); if (gRideEntranceExitPlaceDirection == kInvalidDirection) { RideConstructionInvalidateCurrentTrack(); return; } - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.set(MapSelectFlag::enable); + gMapSelectFlags.set(MapSelectFlag::enableArrow); gMapSelectType = MAP_SELECT_TYPE_FULL; gMapSelectPositionA = entranceOrExitCoords; gMapSelectPositionB = entranceOrExitCoords; @@ -3633,7 +3633,7 @@ namespace OpenRCT2::Ui::Windows // Raise z above all slopes and water highestZ = 0; - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT) + if (gMapSelectFlags.has(MapSelectFlag::enableConstruct)) { for (const auto& selectedTile : gMapSelectionTiles) { @@ -3646,9 +3646,9 @@ namespace OpenRCT2::Ui::Windows } } - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enable); + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); + gMapSelectFlags.unset(MapSelectFlag::enableArrow); auto ridePlacePosition = RideGetPlacePositionFromScreenPosition(screenCoords); if (!ridePlacePosition) return; @@ -4819,7 +4819,7 @@ namespace OpenRCT2::Ui::Windows if (_currentTrackPitchEnd != TrackPitch::None) ViewportSetVisibility(ViewportVisibility::TrackHeights); - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) { // Set height to where the next track piece would begin VirtualFloorSetHeight(trackPos.z - zBegin + zEnd); diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index d8d291287e..e57cc32735 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -1782,8 +1782,8 @@ namespace OpenRCT2::Ui::Windows MapInvalidateSelectionRect(); MapInvalidateMapSelectionTiles(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags.unset(MapSelectFlag::enable); + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); if (_sceneryPaintEnabled) return; @@ -1815,7 +1815,7 @@ namespace OpenRCT2::Ui::Windows return; } - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); if (gWindowSceneryScatterEnabled) { uint16_t cluster_size = (gWindowSceneryScatterSize - 1) * kCoordsXYStep; @@ -1893,7 +1893,7 @@ namespace OpenRCT2::Ui::Windows return; } - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); gMapSelectPositionA.x = mapTile.x; gMapSelectPositionA.y = mapTile.y; gMapSelectPositionB.x = mapTile.x; @@ -1929,7 +1929,7 @@ namespace OpenRCT2::Ui::Windows return; } - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); gMapSelectPositionA.x = mapTile.x; gMapSelectPositionA.y = mapTile.y; gMapSelectPositionB.x = mapTile.x; @@ -1998,7 +1998,7 @@ namespace OpenRCT2::Ui::Windows gMapSelectionTiles.push_back(rotatedTileCoords); } - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags.set(MapSelectFlag::enableConstruct); MapInvalidateMapSelectionTiles(); // If no change in ghost placement @@ -2050,7 +2050,7 @@ namespace OpenRCT2::Ui::Windows return; } - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); gMapSelectPositionA.x = mapTile.x; gMapSelectPositionA.y = mapTile.y; gMapSelectPositionB.x = mapTile.x; diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index d04ddc4a8b..ab97bb4b54 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -664,12 +664,12 @@ namespace OpenRCT2::Ui::Windows MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); auto mapCoords = FootpathGetCoordinatesFromPos({ screenCoords.x, screenCoords.y + 16 }, nullptr, nullptr); if (!mapCoords.IsNull()) { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); gMapSelectType = MAP_SELECT_TYPE_FULL; gMapSelectPositionA = mapCoords; gMapSelectPositionB = mapCoords; diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 4169853f2c..cdf61e5bc9 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -967,7 +967,7 @@ static uint64_t PageDisabledWidgets[] = { void OnToolUpdate(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) override { MapInvalidateSelectionRect(); - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); CoordsXY mapCoords; TileElement* clickedElement = nullptr; @@ -993,7 +993,7 @@ static uint64_t PageDisabledWidgets[] = { else if (_tileSelected) gMapSelectPositionA = gMapSelectPositionB = _toolMap; else - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); gMapSelectType = MAP_SELECT_TYPE_FULL; MapInvalidateSelectionRect(); diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 1b5600d092..4b972c015a 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -119,8 +119,8 @@ namespace OpenRCT2::Ui::Windows ClearProvisional(); ViewportSetVisibility(ViewportVisibility::Default); MapInvalidateMapSelectionTiles(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); + gMapSelectFlags.unset(MapSelectFlag::enableArrow); HideGridlines(); _miniPreview.clear(); _miniPreview.shrink_to_fit(); @@ -170,9 +170,9 @@ namespace OpenRCT2::Ui::Windows TrackDesignState tds{}; MapInvalidateMapSelectionTiles(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enable); + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); + gMapSelectFlags.unset(MapSelectFlag::enableArrow); // Take shift modifier into account ScreenCoordsXY targetScreenCoords = screenCoords; @@ -246,9 +246,9 @@ namespace OpenRCT2::Ui::Windows { ClearProvisional(); MapInvalidateMapSelectionTiles(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enable); + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); + gMapSelectFlags.unset(MapSelectFlag::enableArrow); // Take shift modifier into account ScreenCoordsXY targetScreenCoords = screenCoords; diff --git a/src/openrct2-ui/windows/ViewClipping.cpp b/src/openrct2-ui/windows/ViewClipping.cpp index 05dae1e2ce..f56ebd536f 100644 --- a/src/openrct2-ui/windows/ViewClipping.cpp +++ b/src/openrct2-ui/windows/ViewClipping.cpp @@ -218,7 +218,7 @@ namespace OpenRCT2::Ui::Windows auto mapCoords = ScreenPosToMapPos(screenCoords, &direction); if (mapCoords.has_value()) { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); MapInvalidateTileFull(gMapSelectPositionA); gMapSelectPositionA = gMapSelectPositionB = mapCoords.value(); MapInvalidateTileFull(mapCoords.value()); @@ -249,7 +249,7 @@ namespace OpenRCT2::Ui::Windows if (mapCoords) { MapInvalidateSelectionRect(); - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); gMapSelectPositionA.x = std::min(_selectionStart.x, mapCoords->x); gMapSelectPositionB.x = std::max(_selectionStart.x, mapCoords->x); gMapSelectPositionA.y = std::min(_selectionStart.y, mapCoords->y); diff --git a/src/openrct2-ui/windows/Water.cpp b/src/openrct2-ui/windows/Water.cpp index 2d90ec7ae0..788978b28a 100644 --- a/src/openrct2-ui/windows/Water.cpp +++ b/src/openrct2-ui/windows/Water.cpp @@ -201,7 +201,7 @@ namespace OpenRCT2::Ui::Windows switch (widgetIndex) { case WIDX_BACKGROUND: - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) + if (gMapSelectFlags.has(MapSelectFlag::enable)) { gCurrentToolId = Tool::upDownArrow; } @@ -225,7 +225,7 @@ namespace OpenRCT2::Ui::Windows { case WIDX_BACKGROUND: MapInvalidateSelectionRect(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); gCurrentToolId = Tool::waterDown; break; } @@ -302,7 +302,7 @@ namespace OpenRCT2::Ui::Windows if (gCurrentToolId == Tool::upDownArrow) { - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) return; auto waterLowerAction = GameActions::WaterLowerAction( @@ -325,7 +325,7 @@ namespace OpenRCT2::Ui::Windows return; } - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.unset(MapSelectFlag::enable); auto info = GetMapCoordinatesFromPos( screenPos, EnumsToFlags(ViewportInteractionItem::Terrain, ViewportInteractionItem::Water)); @@ -345,9 +345,9 @@ namespace OpenRCT2::Ui::Windows uint8_t state_changed = 0; - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; + gMapSelectFlags.set(MapSelectFlag::enable); state_changed++; } diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 860a16f176..f57ac99df8 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -108,7 +108,7 @@ namespace OpenRCT2 gPressedWidget.window_classification = WindowClass::Null; gPickupPeepImage = ImageId(); ResetTooltipNotShown(); - gMapSelectFlags = 0; + gMapSelectFlags.clearAll(); ClearPatrolAreaToRender(); TextinputCancel(); } diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index 92a4d9eccd..73097e564a 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -698,7 +698,7 @@ static constexpr float kWindowScrollLocations[][2] = { MapInvalidateMapSelectionTiles(); // Reset map selection - gMapSelectFlags = 0; + gMapSelectFlags.clearAll(); if (gCurrentToolWidget.widget_index != kWidgetIndexNull) { diff --git a/src/openrct2/paint/VirtualFloor.cpp b/src/openrct2/paint/VirtualFloor.cpp index 30cf1c2a27..e66eb40170 100644 --- a/src/openrct2/paint/VirtualFloor.cpp +++ b/src/openrct2/paint/VirtualFloor.cpp @@ -99,13 +99,13 @@ void VirtualFloorInvalidate(const bool alwaysInvalidate) CoordsXY min_position = { std::numeric_limits::max(), std::numeric_limits::max() }; CoordsXY max_position = { std::numeric_limits::lowest(), std::numeric_limits::lowest() }; - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) + if (gMapSelectFlags.has(MapSelectFlag::enable)) { min_position = gMapSelectPositionA; max_position = gMapSelectPositionB; } - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT) + if (gMapSelectFlags.has(MapSelectFlag::enableConstruct)) { for (const auto& tile : gMapSelectionTiles) { @@ -168,12 +168,12 @@ bool VirtualFloorTileIsFloor(const CoordsXY& loc) // and if the current tile is near or on them // (short-circuit to false otherwise - we don't want to show a second // virtual floor from e. g. an open ride construction window) - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) + if (gMapSelectFlags.has(MapSelectFlag::enable)) { return loc >= gMapSelectPositionA - kVirtualFloorBaseSizeXY && loc <= gMapSelectPositionB + kVirtualFloorBaseSizeXY; } - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT) + if (gMapSelectFlags.has(MapSelectFlag::enableConstruct)) { // Check if we are anywhere near the selection tiles (larger scenery / rides) for (const auto& tile : gMapSelectionTiles) @@ -201,7 +201,7 @@ static void VirtualFloorGetTileProperties( *tileOwned = false; // See if we are a selected tile - if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if ((gMapSelectFlags.has(MapSelectFlag::enable))) { if (loc >= gMapSelectPositionA && loc <= gMapSelectPositionB) { @@ -210,7 +210,7 @@ static void VirtualFloorGetTileProperties( } // See if we are on top of the selection tiles - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT) + if (gMapSelectFlags.has(MapSelectFlag::enableConstruct)) { for (const auto& tile : gMapSelectionTiles) { diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index 5bebff37fb..707414d634 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -808,7 +808,7 @@ static std::pair SurfaceGetHeightAboveWater( std::optional GetPatrolAreaTileColour(const CoordsXY& pos) { - bool selected = gMapSelectFlags & MAP_SELECT_FLAG_ENABLE && gMapSelectType == MAP_SELECT_TYPE_FULL + bool selected = gMapSelectFlags.has(MapSelectFlag::enable) && gMapSelectType == MAP_SELECT_TYPE_FULL && pos.x >= gMapSelectPositionA.x && pos.x <= gMapSelectPositionB.x && pos.y >= gMapSelectPositionA.y && pos.y <= gMapSelectPositionB.y; @@ -1090,7 +1090,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con // ebp[4] = ebp; // ebp[8] = ebx - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) + if (gMapSelectFlags.has(MapSelectFlag::enable)) { // Loc660FB8: const CoordsXY& pos = session.MapPosition; @@ -1164,7 +1164,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con } } - if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT) + if (gMapSelectFlags.has(MapSelectFlag::enableConstruct)) { const CoordsXY& pos = session.MapPosition; @@ -1176,7 +1176,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con } FilterPaletteID fpId = FilterPaletteID::PaletteSceneryGroundMarker; - if (gMapSelectFlags & MAP_SELECT_FLAG_GREEN) + if (gMapSelectFlags.has(MapSelectFlag::green)) { fpId = FilterPaletteID::PaletteRideGroundMarker; } diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index aa8f2a514d..cce5138a8b 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -163,7 +163,7 @@ static void PaintTileElementBase(PaintSession& session, const CoordsXY& origCoor int32_t screenMinY = Translate3DTo2DWithZ(rotation, { coords, 0 }).y; // Display little yellow arrow when building footpaths? - if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_ARROW) && session.MapPosition.x == gMapSelectArrowPosition.x + if ((gMapSelectFlags.has(MapSelectFlag::enableArrow)) && session.MapPosition.x == gMapSelectArrowPosition.x && session.MapPosition.y == gMapSelectArrowPosition.y) { uint8_t arrowRotation = (rotation + (gMapSelectArrowDirection & 3)) & 3; diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index 067b73305a..b547893ace 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -526,7 +526,7 @@ void RideConstructionInvalidateCurrentTrack() if (_currentTrackSelectionFlags.has(TrackSelectionFlag::arrow)) { _currentTrackSelectionFlags.unset(TrackSelectionFlag::arrow); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); MapInvalidateTileFull(_currentTrackBegin); } RideConstructionRemoveGhosts(); @@ -769,7 +769,7 @@ void RideSelectNextSection() } else if (_rideConstructionState == RideConstructionState::Back) { - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); if (RideSelectForwardsFromBack()) { @@ -825,7 +825,7 @@ void RideSelectPreviousSection() } else if (_rideConstructionState == RideConstructionState::Front) { - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); if (RideSelectBackwardsFromFront()) { @@ -890,7 +890,7 @@ static bool ride_modify_entrance_or_exit(const CoordsXYE& tileElement) } WindowRideConstructionUpdateActiveElements(); - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); } else { @@ -934,7 +934,7 @@ static bool ride_modify_maze(const CoordsXYE& tileElement) _currentTrackBegin.z = trackElement->GetBaseZ(); _currentTrackSelectionFlags.clearAll(); _rideConstructionNextArrowPulse = 0; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); auto intent = Intent(INTENT_ACTION_UPDATE_MAZE_CONSTRUCTION); ContextBroadcastIntent(&intent); @@ -1018,7 +1018,7 @@ bool RideModify(const CoordsXYE& input) _currentTrackPieceType = type; _currentTrackSelectionFlags.clearAll(); _rideConstructionNextArrowPulse = 0; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; + gMapSelectFlags.unset(MapSelectFlag::enableArrow); if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) { diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index c3e69bc36e..40a26ba13b 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -345,9 +345,9 @@ ResultWithMessage TrackDesign::CreateTrackDesignTrack(TrackDesignState& tds, con // Resave global vars for scenery reasons. tds.origin = startPos; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; - gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN; + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); + gMapSelectFlags.unset(MapSelectFlag::enableArrow); + gMapSelectFlags.unset(MapSelectFlag::green); statistics.spaceRequired = TileCoordsXY(tds.previewMax - tds.previewMin) + TileCoordsXY{ 1, 1 }; return { true, warningMessage }; @@ -457,9 +457,9 @@ ResultWithMessage TrackDesign::CreateTrackDesignMaze(TrackDesignState& tds, cons TrackDesignPreviewDrawOutlines(tds, *this, RideGetTemporaryForPreview(), { 4096, 4096, 0, _currentTrackPieceDirection }); tds.origin = { startLoc.x, startLoc.y, startZ }; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; - gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN; + gMapSelectFlags.unset(MapSelectFlag::enableConstruct); + gMapSelectFlags.unset(MapSelectFlag::enableArrow); + gMapSelectFlags.unset(MapSelectFlag::green); statistics.spaceRequired = TileCoordsXY(tds.previewMax - tds.previewMin) + TileCoordsXY{ 1, 1 }; @@ -1806,9 +1806,9 @@ static GameActions::Result TrackDesignPlaceVirtual( // 0x6D0FE6 if (tds.placeOperation == TrackPlaceOperation::drawOutlines) { - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_CONSTRUCT; - gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW; - gMapSelectFlags &= ~MAP_SELECT_FLAG_GREEN; + gMapSelectFlags.set(MapSelectFlag::enableConstruct); + gMapSelectFlags.set(MapSelectFlag::enableArrow); + gMapSelectFlags.unset(MapSelectFlag::green); MapInvalidateMapSelectionTiles(); } diff --git a/src/openrct2/world/MapSelection.cpp b/src/openrct2/world/MapSelection.cpp index 6966570bc4..596b3b2ccd 100644 --- a/src/openrct2/world/MapSelection.cpp +++ b/src/openrct2/world/MapSelection.cpp @@ -12,7 +12,7 @@ #include "../interface/Viewport.h" #include "Map.h" -uint16_t gMapSelectFlags; +MapSelectFlags gMapSelectFlags; uint16_t gMapSelectType; CoordsXY gMapSelectPositionA; CoordsXY gMapSelectPositionB; @@ -27,7 +27,7 @@ std::vector gMapSelectionTiles; */ void MapInvalidateMapSelectionTiles() { - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE_CONSTRUCT)) + if (!(gMapSelectFlags.has(MapSelectFlag::enableConstruct))) return; for (const auto& position : gMapSelectionTiles) @@ -42,7 +42,7 @@ void MapInvalidateSelectionRect() { int32_t x0, y0, x1, y1, left, right, top, bottom; - if (!(gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) + if (!(gMapSelectFlags.has(MapSelectFlag::enable))) return; x0 = gMapSelectPositionA.x + 16; diff --git a/src/openrct2/world/MapSelection.h b/src/openrct2/world/MapSelection.h index f5a22a18a1..4ac9216ba9 100644 --- a/src/openrct2/world/MapSelection.h +++ b/src/openrct2/world/MapSelection.h @@ -9,17 +9,19 @@ #pragma once +#include "../core/FlagHolder.hpp" #include "Location.hpp" #include -enum +enum class MapSelectFlag : uint8_t { - MAP_SELECT_FLAG_ENABLE = 1 << 0, - MAP_SELECT_FLAG_ENABLE_CONSTRUCT = 1 << 1, - MAP_SELECT_FLAG_ENABLE_ARROW = 1 << 2, - MAP_SELECT_FLAG_GREEN = 1 << 3, + enable, + enableConstruct, + enableArrow, + green, }; +using MapSelectFlags = FlagHolder; enum { @@ -40,7 +42,7 @@ enum MAP_SELECT_TYPE_EDGE_3, }; -extern uint16_t gMapSelectFlags; +extern MapSelectFlags gMapSelectFlags; extern uint16_t gMapSelectType; extern CoordsXY gMapSelectPositionA; extern CoordsXY gMapSelectPositionB;