1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Create enum class for MazeBuildMode

This commit is contained in:
Gymnasiast
2025-12-23 19:49:03 +01:00
parent a48e7d5018
commit c645ec2a12
6 changed files with 27 additions and 24 deletions

View File

@@ -34,6 +34,7 @@
using OpenRCT2::GameActions::CommandFlag;
using OpenRCT2::GameActions::CommandFlags;
using OpenRCT2::GameActions::MazeBuildMode;
namespace OpenRCT2::Ui::Windows
{
@@ -399,7 +400,8 @@ namespace OpenRCT2::Ui::Windows
void WindowMazeConstructionConstruct(int32_t direction)
{
int32_t x, y, z, mode;
int32_t x, y, z;
MazeBuildMode mode;
CommandFlags actionFlags = {};
_currentTrackSelectionFlags.clearAll();
@@ -413,15 +415,15 @@ namespace OpenRCT2::Ui::Windows
switch (_rideConstructionState)
{
case RideConstructionState::MazeBuild:
mode = GC_SET_MAZE_TRACK_BUILD;
mode = MazeBuildMode::build;
break;
case RideConstructionState::MazeMove:
mode = GC_SET_MAZE_TRACK_MOVE;
mode = MazeBuildMode::move;
actionFlags = { CommandFlag::allowDuringPaused };
break;
default:
case RideConstructionState::MazeFill:
mode = GC_SET_MAZE_TRACK_FILL;
mode = MazeBuildMode::fill;
break;
}

View File

@@ -67,6 +67,7 @@ using namespace OpenRCT2::Numerics;
using namespace OpenRCT2::TrackMetaData;
using OpenRCT2::GameActions::CommandFlag;
using OpenRCT2::GameActions::CommandFlags;
using OpenRCT2::GameActions::MazeBuildMode;
namespace OpenRCT2::Ui::Windows
{
@@ -3698,7 +3699,7 @@ namespace OpenRCT2::Ui::Windows
gDisableErrorWindowSound = true;
auto gameAction = GameActions::MazeSetTrackAction(
CoordsXYZD{ _currentTrackBegin, 0 }, true, _currentRideIndex, GC_SET_MAZE_TRACK_BUILD);
CoordsXYZD{ _currentTrackBegin, 0 }, true, _currentRideIndex, MazeBuildMode::build);
auto mazeSetTrackResult = GameActions::Execute(&gameAction, getGameState());
if (mazeSetTrackResult.error == GameActions::Status::ok)
{
@@ -4757,8 +4758,7 @@ namespace OpenRCT2::Ui::Windows
if (rtd.specialType == RtdSpecialType::maze)
{
CommandFlags flags = { CommandFlag::allowDuringPaused, CommandFlag::noSpend, CommandFlag::ghost };
auto gameAction = GameActions::MazeSetTrackAction(
CoordsXYZD{ trackPos, 0 }, true, rideIndex, GC_SET_MAZE_TRACK_BUILD);
auto gameAction = GameActions::MazeSetTrackAction(CoordsXYZD{ trackPos, 0 }, true, rideIndex, MazeBuildMode::build);
gameAction.SetFlags(flags);
auto result = GameActions::Execute(&gameAction, getGameState());
@@ -5146,7 +5146,7 @@ namespace OpenRCT2::Ui::Windows
};
for (const auto& quadrant : quadrants)
{
auto gameAction = GameActions::MazeSetTrackAction(quadrant, false, rideIndex, GC_SET_MAZE_TRACK_FILL);
auto gameAction = GameActions::MazeSetTrackAction(quadrant, false, rideIndex, MazeBuildMode::fill);
gameAction.SetFlags(flags);
auto res = GameActions::Execute(&gameAction, getGameState());
}

View File

@@ -58,7 +58,8 @@ namespace OpenRCT2::GameActions
};
// clang-format on
MazeSetTrackAction::MazeSetTrackAction(const CoordsXYZD& location, bool initialPlacement, RideId rideIndex, uint8_t mode)
MazeSetTrackAction::MazeSetTrackAction(
const CoordsXYZD& location, bool initialPlacement, RideId rideIndex, MazeBuildMode mode)
: _loc(location)
, _initialPlacement(initialPlacement)
, _rideIndex(rideIndex)
@@ -87,7 +88,7 @@ namespace OpenRCT2::GameActions
res.position = _loc + CoordsXYZ{ 8, 8, 0 };
res.expenditure = ExpenditureType::rideConstruction;
res.errorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
if ((_loc.z & 0xF) != 0 && _mode == GC_SET_MAZE_TRACK_BUILD)
if ((_loc.z & 0xF) != 0 && _mode == MazeBuildMode::build)
{
res.error = Status::unknown;
res.errorMessage = STR_INVALID_HEIGHT;
@@ -143,7 +144,7 @@ namespace OpenRCT2::GameActions
TileElement* tileElement = MapGetTrackElementAtOfTypeFromRide(_loc, TrackElemType::maze, _rideIndex);
if (tileElement == nullptr)
{
if (_mode != GC_SET_MAZE_TRACK_BUILD)
if (_mode != MazeBuildMode::build)
{
res.error = Status::unknown;
res.errorMessage = STR_INVALID_SELECTION_OF_OBJECTS;
@@ -245,7 +246,7 @@ namespace OpenRCT2::GameActions
switch (_mode)
{
case GC_SET_MAZE_TRACK_BUILD:
case MazeBuildMode::build:
{
uint8_t segmentOffset = MazeGetSegmentBit(_loc);
@@ -278,10 +279,10 @@ namespace OpenRCT2::GameActions
break;
}
case GC_SET_MAZE_TRACK_MOVE:
case MazeBuildMode::move:
break;
case GC_SET_MAZE_TRACK_FILL:
case MazeBuildMode::fill:
if (!_initialPlacement)
{
auto previousSegment = CoordsXY{ _loc.x - CoordsDirectionDelta[_loc.direction].x / 2,

View File

@@ -13,17 +13,24 @@
namespace OpenRCT2::GameActions
{
enum class MazeBuildMode : uint8_t
{
build,
move,
fill,
};
class MazeSetTrackAction final : public GameActionBase<GameCommand::SetMazeTrack>
{
private:
CoordsXYZD _loc;
bool _initialPlacement{};
RideId _rideIndex{ RideId::GetNull() };
uint8_t _mode{};
MazeBuildMode _mode{};
public:
MazeSetTrackAction() = default;
MazeSetTrackAction(const CoordsXYZD& location, bool initialPlacement, RideId rideIndex, uint8_t mode);
MazeSetTrackAction(const CoordsXYZD& location, bool initialPlacement, RideId rideIndex, MazeBuildMode mode);
void AcceptParameters(GameActionParameterVisitor&) final;
void Serialise(DataSerialiser& stream) override;

View File

@@ -179,7 +179,7 @@ namespace OpenRCT2::GameActions
money64 RideDemolishAction::MazeRemoveTrack(GameState_t& gameState, const CoordsXYZD& coords) const
{
auto setMazeTrack = MazeSetTrackAction(coords, false, _rideIndex, GC_SET_MAZE_TRACK_FILL);
auto setMazeTrack = MazeSetTrackAction(coords, false, _rideIndex, MazeBuildMode::fill);
setMazeTrack.SetFlags(GetFlags());
auto execRes = ExecuteNested(&setMazeTrack, gameState);

View File

@@ -651,13 +651,6 @@ enum class SequenceFlag : uint8_t
hasHeightMarker, // Displays a height marker on this sequence block
};
enum
{
GC_SET_MAZE_TRACK_BUILD = 0,
GC_SET_MAZE_TRACK_MOVE = 1,
GC_SET_MAZE_TRACK_FILL = 2,
};
struct TrackCircuitIterator
{
CoordsXYE last;