Move clearance flags to strong enum and FlagHolder

This commit is contained in:
Gymnasiast committed 2026-03-10 18:32:36 +01:00
1 parent 3df9fe1244
commit 733fdec9ba
5 files changed
+1329 -1329

No files matched your search

+1 -1
View File
@@ -2713,7 +2713,7 @@ namespace OpenRCT2::Ui::Windows
const auto& ted = GetTrackElementDescriptor(trackType);
const auto trackBlock = ted.sequenceData.sequences[ted.sequenceData.numSequences - 1].clearance;
CoordsXYZ mapCoords{ trackBlock.x, trackBlock.y, trackBlock.z };
if (trackBlock.flags & RCT_PREVIEW_TRACK_FLAG_1)
if (trackBlock.flags.has(ClearanceFlag::flag1))
{
mapCoords.x = 0;
mapCoords.y = 0;
@@ -247,7 +247,7 @@ namespace OpenRCT2::GameActions
int32_t baseZ = floor2(mapLoc.z, kCoordsZStep);
int32_t clearanceZ = trackBlock.clearanceZ;
if (trackBlock.flags & RCT_PREVIEW_TRACK_FLAG_IS_VERTICAL && clearanceHeight > 24)
if (trackBlock.flags.has(ClearanceFlag::isVertical) && clearanceHeight > 24)
{
clearanceZ += 24;
}
@@ -457,7 +457,7 @@ namespace OpenRCT2::GameActions
int32_t baseZ = floor2(mapLoc.z, kCoordsZStep);
int32_t clearanceZ = trackBlock.clearanceZ;
if (trackBlock.flags & RCT_PREVIEW_TRACK_FLAG_IS_VERTICAL && clearanceHeight > 24)
if (trackBlock.flags.has(ClearanceFlag::isVertical) && clearanceHeight > 24)
{
clearanceZ += 24;
}
-7
View File
@@ -43,13 +43,6 @@ namespace OpenRCT2
struct ResultWithMessage;
enum
{
RCT_PREVIEW_TRACK_FLAG_0 = (1 << 0),
RCT_PREVIEW_TRACK_FLAG_1 = (1 << 1),
RCT_PREVIEW_TRACK_FLAG_IS_VERTICAL = (1 << 2),
};
int32_t TrackIsConnectedByShape(OpenRCT2::TileElement* a, OpenRCT2::TileElement* b);
bool TrackElementIsCovered(OpenRCT2::TrackElemType trackElementType);
File diff suppressed because it is too large. Load diff
@@ -184,6 +184,14 @@ namespace OpenRCT2::TrackMetadata
TypeOrCurve previous;
};
enum class ClearanceFlag : uint8_t
{
flag0,
flag1,
isVertical,
};
using ClearanceFlags = FlagHolder<uint8_t, ClearanceFlag>;
struct SequenceClearance
{
int16_t x{};
@@ -191,7 +199,7 @@ namespace OpenRCT2::TrackMetadata
int16_t z{};
uint8_t clearanceZ{};
QuarterTile quarterTile = { 0, 0 };
uint8_t flags{};
ClearanceFlags flags{};
};
struct SequenceWoodenSupport