diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index c27a9a8425..205e4344d2 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -864,8 +864,8 @@ static void window_footpath_place_path_at_point(const ScreenCoordsXY& screenCoor // Try and place path gGameCommandErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE; auto footpathPlaceAction = FootpathPlaceAction({ info.Loc, z }, slope, selectedType); - footpathPlaceAction.SetCallback([](const GameAction* ga, const GameActionResult* result) { - if (result->Error == GA_ERROR::OK) + footpathPlaceAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { + if (result->Error == GameActions::Status::Ok) { // Don't play sound if it is no cost to prevent multiple sounds. TODO: make this work in no money scenarios if (result->Cost != 0) @@ -954,8 +954,8 @@ static void window_footpath_construct() gGameCommandErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE; auto footpathPlaceAction = FootpathPlaceAction(footpathLoc, slope, type, gFootpathConstructDirection); - footpathPlaceAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) { - if (result->Error == GA_ERROR::OK) + footpathPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + if (result->Error == GameActions::Status::Ok) { OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 9746ab7275..3be46436d1 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -587,8 +587,8 @@ void window_guest_overview_mouse_up(rct_window* w, rct_widgetindex widgetIndex) CoordsXYZ nullLoc{}; nullLoc.setNull(); PeepPickupAction pickupAction{ PeepPickupType::Pickup, w->number, nullLoc, network_get_current_player_id() }; - pickupAction.SetCallback([peepnum = w->number](const GameAction* ga, const GameActionResult* result) { - if (result->Error != GA_ERROR::OK) + pickupAction.SetCallback([peepnum = w->number](const GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) return; rct_window* wind = window_find_by_number(WC_PEEP, peepnum); if (wind) @@ -1188,8 +1188,8 @@ void window_guest_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex, PeepPickupAction pickupAction{ PeepPickupType::Place, w->number, { destCoords, tileElement->GetBaseZ() }, network_get_current_player_id() }; - pickupAction.SetCallback([](const GameAction* ga, const GameActionResult* result) { - if (result->Error != GA_ERROR::OK) + pickupAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) return; tool_cancel(); gPickupPeepImage = UINT32_MAX; diff --git a/src/openrct2-ui/windows/LandRights.cpp b/src/openrct2-ui/windows/LandRights.cpp index 0e123d2026..63153dd78c 100644 --- a/src/openrct2-ui/windows/LandRights.cpp +++ b/src/openrct2-ui/windows/LandRights.cpp @@ -354,7 +354,7 @@ static void window_land_rights_tool_update_land_rights(const ScreenCoordsXY& scr : LandBuyRightSetting::BuyConstructionRights); auto res = GameActions::Query(&landBuyRightsAction); - _landRightsCost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + _landRightsCost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; } /** diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 348f379d7d..6c88454f95 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -1291,7 +1291,7 @@ static void window_map_place_park_entrance_tool_down(const ScreenCoordsXY& scree { auto gameAction = PlaceParkEntranceAction(parkEntrancePosition); auto result = GameActions::Execute(&gameAction); - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); } @@ -1316,7 +1316,7 @@ static void window_map_set_peep_spawn_tool_down(const ScreenCoordsXY& screenCoor auto gameAction = PlacePeepSpawnAction({ mapCoords, mapZ, static_cast(direction) }); auto result = GameActions::Execute(&gameAction); - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); } diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index 398c13de00..b3e411d39b 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -373,8 +373,8 @@ static void window_maze_construction_entrance_tooldown(const ScreenCoordsXY& scr entranceOrExitCoords, direction_reverse(entranceOrExitCoords.direction), rideIndex, gRideEntranceExitPlaceStationIndex, gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT); - rideEntranceExitPlaceAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) { - if (result->Error != GA_ERROR::OK) + rideEntranceExitPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) return; OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); diff --git a/src/openrct2-ui/windows/NewCampaign.cpp b/src/openrct2-ui/windows/NewCampaign.cpp index e6e127455e..9e61b412c1 100644 --- a/src/openrct2-ui/windows/NewCampaign.cpp +++ b/src/openrct2-ui/windows/NewCampaign.cpp @@ -186,8 +186,8 @@ static void window_new_campaign_mouseup(rct_window* w, rct_widgetindex widgetInd case WIDX_START_BUTTON: { auto gameAction = ParkMarketingAction(w->campaign.campaign_type, w->campaign.RideId, w->campaign.no_weeks); - gameAction.SetCallback([](const GameAction* ga, const GameActionResult* result) { - if (result->Error == GA_ERROR::OK) + gameAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { + if (result->Error == GameActions::Status::Ok) { window_close_by_class(WC_NEW_CAMPAIGN); } diff --git a/src/openrct2-ui/windows/ObjectLoadError.cpp b/src/openrct2-ui/windows/ObjectLoadError.cpp index e8a7972b13..08411ebe19 100644 --- a/src/openrct2-ui/windows/ObjectLoadError.cpp +++ b/src/openrct2-ui/windows/ObjectLoadError.cpp @@ -158,7 +158,7 @@ private: req.method = Http::Method::GET; req.url = url; Http::DoAsync(req, [this, entry, name](Http::Response response) { - if (response.status == Http::Status::OK) + if (response.status == Http::Status::Ok) { // Check that download operation hasn't been cancelled if (_downloadingObjects) @@ -208,7 +208,7 @@ private: req.method = Http::Method::GET; req.url = OPENRCT2_API_LEGACY_OBJECT_URL + name; Http::DoAsync(req, [this, entry, name](Http::Response response) { - if (response.status == Http::Status::OK) + if (response.status == Http::Status::Ok) { auto jresponse = Json::FromString(response.body); if (jresponse.is_object()) diff --git a/src/openrct2-ui/windows/Player.cpp b/src/openrct2-ui/windows/Player.cpp index 7a5b4bc517..c1de30319a 100644 --- a/src/openrct2-ui/windows/Player.cpp +++ b/src/openrct2-ui/windows/Player.cpp @@ -276,8 +276,8 @@ void window_player_overview_dropdown(rct_window* w, rct_widgetindex widgetIndex, } int32_t group = network_get_group_id(dropdownIndex); auto playerSetGroupAction = PlayerSetGroupAction(w->number, group); - playerSetGroupAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) { - if (result->Error == GA_ERROR::OK) + playerSetGroupAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + if (result->Error == GameActions::Status::Ok) { w->Invalidate(); } diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index adcc7486c8..fb55ebcf8b 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -2252,7 +2252,7 @@ static void window_ride_main_dropdown(rct_window* w, rct_widgetindex widgetIndex if (rideType < RIDE_TYPE_COUNT) { auto rideSetSetting = RideSetSettingAction(w->number, RideSetSetting::RideType, rideType); - rideSetSetting.SetCallback([](const GameAction* ga, const GameActionResult* result) { + rideSetSetting.SetCallback([](const GameAction* ga, const GameActions::Result* result) { // Reset ghost track if ride construction window is open, prevents a crash // Will get set to the correct Alternative variable during set_default_next_piece. // TODO: Rework construction window to prevent the need for this. diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 54f7fafa39..d6e4fd0686 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -1684,7 +1684,7 @@ static void CloseConstructWindowOnCompletion(Ride* ride) static void RideConstructPlacedForwardGameActionCallback(const GameAction* ga, const TrackPlaceActionResult* result) { - if (result->Error != GA_ERROR::OK) + if (result->Error != GameActions::Status::Ok) { window_ride_construction_update_active_elements(); return; @@ -1728,7 +1728,7 @@ static void RideConstructPlacedForwardGameActionCallback(const GameAction* ga, c static void RideConstructPlacedBackwardGameActionCallback(const GameAction* ga, const TrackPlaceActionResult* result) { - if (result->Error != GA_ERROR::OK) + if (result->Error != GameActions::Status::Ok) { window_ride_construction_update_active_elements(); return; @@ -1801,7 +1801,7 @@ static void window_ride_construction_construct(rct_window* w) } auto res = GameActions::Execute(&trackPlaceAction); // Used by some functions - if (res->Error != GA_ERROR::OK) + if (res->Error != GameActions::Status::Ok) { if (auto error = res->ErrorMessage.AsStringId()) gGameCommandErrorText = *error; @@ -1815,7 +1815,7 @@ static void window_ride_construction_construct(rct_window* w) _trackPlaceCost = res->Cost; } - if (res->Error != GA_ERROR::OK) + if (res->Error != GameActions::Status::Ok) { return; } @@ -1929,8 +1929,8 @@ static void window_ride_construction_mouseup_demolish(rct_window* w) _currentTrackPieceType, 0, { _currentTrackBegin.x, _currentTrackBegin.y, _currentTrackBegin.z, _currentTrackPieceDirection }); - trackRemoveAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) { - if (result->Error != GA_ERROR::OK) + trackRemoveAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) { window_ride_construction_update_active_elements(); } @@ -3413,7 +3413,7 @@ static void ride_construction_set_brakes_speed(int32_t brakesSpeed) auto trackSetBrakeSpeed = TrackSetBrakeSpeedAction( _currentTrackBegin, tileElement->AsTrack()->GetTrackType(), brakesSpeed); trackSetBrakeSpeed.SetCallback( - [](const GameAction* ga, const GameActionResult* result) { window_ride_construction_update_active_elements(); }); + [](const GameAction* ga, const GameActions::Result* result) { window_ride_construction_update_active_elements(); }); GameActions::Execute(&trackSetBrakeSpeed); return; } @@ -3884,8 +3884,8 @@ static void ride_construction_tooldown_entrance_exit(const ScreenCoordsXY& scree entranceOrExitCoords, direction_reverse(gRideEntranceExitPlaceDirection), gRideEntranceExitPlaceRideIndex, gRideEntranceExitPlaceStationIndex, gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT); - rideEntranceExitPlaceAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) { - if (result->Error != GA_ERROR::OK) + rideEntranceExitPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) return; OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 372919f2a3..fb694cd9d0 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -417,8 +417,8 @@ void window_staff_overview_mouseup(rct_window* w, rct_widgetindex widgetIndex) CoordsXYZ nullLoc{}; nullLoc.setNull(); PeepPickupAction pickupAction{ PeepPickupType::Pickup, w->number, nullLoc, network_get_current_player_id() }; - pickupAction.SetCallback([peepnum = w->number](const GameAction* ga, const GameActionResult* result) { - if (result->Error != GA_ERROR::OK) + pickupAction.SetCallback([peepnum = w->number](const GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) return; rct_window* wind = window_find_by_number(WC_PEEP, peepnum); if (wind) @@ -1212,8 +1212,8 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex, PeepPickupAction pickupAction{ PeepPickupType::Place, w->number, { destCoords, tileElement->GetBaseZ() }, network_get_current_player_id() }; - pickupAction.SetCallback([](const GameAction* ga, const GameActionResult* result) { - if (result->Error != GA_ERROR::OK) + pickupAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) return; tool_cancel(); gPickupPeepImage = UINT32_MAX; diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index e807732cf8..8e0a6a90f2 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -1807,7 +1807,7 @@ static void window_top_toolbar_scenery_tool_down(const ScreenCoordsXY& windowPos zAttemptRange = 20; } - auto success = GA_ERROR::UNKNOWN; + auto success = GameActions::Status::Unknown; // Try find a valid z coordinate for (; zAttemptRange != 0; zAttemptRange--) { @@ -1816,12 +1816,12 @@ static void window_top_toolbar_scenery_tool_down(const ScreenCoordsXY& windowPos primaryColour, secondaryColour); auto res = GameActions::Query(&smallSceneryPlaceAction); success = res->Error; - if (res->Error == GA_ERROR::OK) + if (res->Error == GameActions::Status::Ok) { break; } - if (res->Error == GA_ERROR::INSUFFICIENT_FUNDS) + if (res->Error == GameActions::Status::InsufficientFunds) { break; } @@ -1832,25 +1832,25 @@ static void window_top_toolbar_scenery_tool_down(const ScreenCoordsXY& windowPos } // Actually place - if (success == GA_ERROR::OK || ((q + 1 == quantity) && forceError)) + if (success == GameActions::Status::Ok || ((q + 1 == quantity) && forceError)) { auto smallSceneryPlaceAction = SmallSceneryPlaceAction( { cur_grid_x, cur_grid_y, gSceneryPlaceZ, gSceneryPlaceRotation }, quadrant, selectedScenery, primaryColour, secondaryColour); - smallSceneryPlaceAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) { - if (result->Error == GA_ERROR::OK) + smallSceneryPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + if (result->Error == GameActions::Status::Ok) { OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); } }); auto res = GameActions::Execute(&smallSceneryPlaceAction); - if (res->Error == GA_ERROR::OK) + if (res->Error == GameActions::Status::Ok) { forceError = false; } - if (res->Error == GA_ERROR::INSUFFICIENT_FUNDS) + if (res->Error == GameActions::Status::InsufficientFunds) { break; } @@ -1868,8 +1868,8 @@ static void window_top_toolbar_scenery_tool_down(const ScreenCoordsXY& windowPos auto footpathSceneryPlaceAction = FootpathSceneryPlaceAction({ gridPos, z }, selectedScenery + 1); - footpathSceneryPlaceAction.SetCallback([](const GameAction* ga, const GameActionResult* result) { - if (result->Error != GA_ERROR::OK) + footpathSceneryPlaceAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) { return; } @@ -1898,7 +1898,7 @@ static void window_top_toolbar_scenery_tool_down(const ScreenCoordsXY& windowPos selectedScenery, { gridPos, gSceneryPlaceZ }, edges, primaryColour, _secondaryColour, _tertiaryColour); auto res = GameActions::Query(&wallPlaceAction); - if (res->Error == GA_ERROR::OK) + if (res->Error == GameActions::Status::Ok) { break; } @@ -1920,8 +1920,8 @@ static void window_top_toolbar_scenery_tool_down(const ScreenCoordsXY& windowPos auto wallPlaceAction = WallPlaceAction( selectedScenery, { gridPos, gSceneryPlaceZ }, edges, primaryColour, _secondaryColour, _tertiaryColour); - wallPlaceAction.SetCallback([](const GameAction* ga, const GameActionResult* result) { - if (result->Error == GA_ERROR::OK) + wallPlaceAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { + if (result->Error == GameActions::Status::Ok) { OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); } @@ -1951,7 +1951,7 @@ static void window_top_toolbar_scenery_tool_down(const ScreenCoordsXY& windowPos auto sceneryPlaceAction = LargeSceneryPlaceAction(loc, selectedScenery, primaryColour, secondaryColour); auto res = GameActions::Query(&sceneryPlaceAction); - if (res->Error == GA_ERROR::OK) + if (res->Error == GameActions::Status::Ok) { break; } @@ -1973,8 +1973,8 @@ static void window_top_toolbar_scenery_tool_down(const ScreenCoordsXY& windowPos CoordsXYZD loc = { gridPos, gSceneryPlaceZ, direction }; auto sceneryPlaceAction = LargeSceneryPlaceAction(loc, selectedScenery, primaryColour, secondaryColour); - sceneryPlaceAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) { - if (result->Error == GA_ERROR::OK) + sceneryPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + if (result->Error == GameActions::Status::Ok) { OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); } @@ -2003,8 +2003,8 @@ static void window_top_toolbar_scenery_tool_down(const ScreenCoordsXY& windowPos break; } auto bannerPlaceAction = BannerPlaceAction(loc, selectedScenery, bannerIndex, primaryColour); - bannerPlaceAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) { - if (result->Error == GA_ERROR::OK) + bannerPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + if (result->Error == GameActions::Status::Ok) { OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); context_open_detail_window(WD_BANNER, bannerIndex); @@ -2097,7 +2097,7 @@ static void top_toolbar_tool_update_scenery_clear(const ScreenCoordsXY& screenPo auto action = GetClearAction(); auto result = GameActions::Query(&action); - auto cost = (result->Error == GA_ERROR::OK ? result->Cost : MONEY32_UNDEFINED); + auto cost = (result->Error == GameActions::Status::Ok ? result->Cost : MONEY32_UNDEFINED); if (gClearSceneryCost != cost) { gClearSceneryCost = cost; @@ -2362,10 +2362,10 @@ static void top_toolbar_tool_update_water(const ScreenCoordsXY& screenPos) { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }); auto res = GameActions::Query(&waterLowerAction); - money32 lowerCost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + money32 lowerCost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; res = GameActions::Query(&waterRaiseAction); - money32 raiseCost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + money32 raiseCost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; if (gWaterToolRaiseCost != raiseCost || gWaterToolLowerCost != lowerCost) { @@ -2453,10 +2453,10 @@ static void top_toolbar_tool_update_water(const ScreenCoordsXY& screenPos) { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }); auto res = GameActions::Query(&waterLowerAction); - money32 lowerCost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + money32 lowerCost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; res = GameActions::Query(&waterRaiseAction); - money32 raiseCost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + money32 raiseCost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; if (gWaterToolRaiseCost != raiseCost || gWaterToolLowerCost != lowerCost) { @@ -2496,7 +2496,7 @@ static money32 try_place_ghost_scenery( smallSceneryPlaceAction.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); auto res = GameActions::Execute(&smallSceneryPlaceAction); auto sspar = dynamic_cast(res.get()); - if (sspar == nullptr || res->Error != GA_ERROR::OK) + if (sspar == nullptr || res->Error != GameActions::Status::Ok) return MONEY32_UNDEFINED; gSceneryPlaceRotation = static_cast(parameter_3 & 0xFF); @@ -2528,8 +2528,8 @@ static money32 try_place_ghost_scenery( int32_t z = (parameter_2 & 0xFF) * COORDS_Z_STEP; auto footpathSceneryPlaceAction = FootpathSceneryPlaceAction({ map_tile.x, map_tile.y, z }, entryIndex + 1); footpathSceneryPlaceAction.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); - footpathSceneryPlaceAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) { - if (result->Error != GA_ERROR::OK) + footpathSceneryPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) { return; } @@ -2537,7 +2537,7 @@ static money32 try_place_ghost_scenery( gSceneryGhostType |= SCENERY_GHOST_FLAG_1; }); auto res = GameActions::Execute(&footpathSceneryPlaceAction); - if (res->Error != GA_ERROR::OK) + if (res->Error != GameActions::Status::Ok) return MONEY32_UNDEFINED; cost = res->Cost; @@ -2555,7 +2555,7 @@ static money32 try_place_ghost_scenery( wallPlaceAction.SetFlags( GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND); wallPlaceAction.SetCallback([=](const GameAction* ga, const WallPlaceActionResult* result) { - if (result->Error != GA_ERROR::OK) + if (result->Error != GameActions::Status::Ok) return; gSceneryGhostPosition = { map_tile, result->tileElement->GetBaseZ() }; @@ -2565,7 +2565,7 @@ static money32 try_place_ghost_scenery( }); auto res = GameActions::Execute(&wallPlaceAction); - if (res->Error != GA_ERROR::OK) + if (res->Error != GameActions::Status::Ok) return MONEY32_UNDEFINED; cost = res->Cost; break; @@ -2584,7 +2584,7 @@ static money32 try_place_ghost_scenery( GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND); auto res = GameActions::Execute(&sceneryPlaceAction); auto lspar = dynamic_cast(res.get()); - if (lspar == nullptr || res->Error != GA_ERROR::OK) + if (lspar == nullptr || res->Error != GameActions::Status::Ok) return MONEY32_UNDEFINED; gSceneryPlaceRotation = loc.direction; @@ -2625,7 +2625,7 @@ static money32 try_place_ghost_scenery( bannerPlaceAction.SetFlags( GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND); auto res = GameActions::Execute(&bannerPlaceAction); - if (res->Error != GA_ERROR::OK) + if (res->Error != GameActions::Status::Ok) return MONEY32_UNDEFINED; gSceneryGhostPosition = loc; @@ -3005,7 +3005,7 @@ static money32 selection_raise_land(uint8_t flags) false); auto res = (flags & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landSmoothAction) : GameActions::Query(&landSmoothAction); - return res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + return res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; } else { @@ -3015,7 +3015,7 @@ static money32 selection_raise_land(uint8_t flags) auto res = (flags & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landRaiseAction) : GameActions::Query(&landRaiseAction); - return res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + return res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; } } @@ -3038,7 +3038,7 @@ static money32 selection_lower_land(uint8_t flags) true); auto res = (flags & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landSmoothAction) : GameActions::Query(&landSmoothAction); - return res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + return res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; } else { @@ -3048,7 +3048,7 @@ static money32 selection_lower_land(uint8_t flags) auto res = (flags & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landLowerAction) : GameActions::Query(&landLowerAction); - return res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + return res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; } } diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 8c8277b92c..5bd8ae6529 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -224,9 +224,9 @@ static void window_track_place_update(rct_window* w) window_close(w); } -static GameActionResult::Ptr FindValidTrackDesignPlaceHeight(CoordsXYZ& loc, uint32_t flags) +static GameActions::Result::Ptr FindValidTrackDesignPlaceHeight(CoordsXYZ& loc, uint32_t flags) { - GameActionResult::Ptr res; + GameActions::Result::Ptr res; for (int32_t i = 0; i < 7; i++, loc.z += 8) { auto tdAction = TrackDesignAction(CoordsXYZD{ loc.x, loc.y, loc.z, _currentTrackPieceDirection }, *_trackDesign); @@ -235,7 +235,7 @@ static GameActionResult::Ptr FindValidTrackDesignPlaceHeight(CoordsXYZ& loc, uin // If successful dont keep trying. // If failure due to no money then increasing height only makes problem worse - if (res->Error == GA_ERROR::OK || res->Error == GA_ERROR::INSUFFICIENT_FUNDS) + if (res->Error == GameActions::Status::Ok || res->Error == GameActions::Status::InsufficientFunds) { return res; } @@ -282,13 +282,13 @@ static void window_track_place_toolupdate(rct_window* w, rct_widgetindex widgetI window_track_place_clear_provisional(); auto res = FindValidTrackDesignPlaceHeight(trackLoc, GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); - if (res->Error == GA_ERROR::OK) + if (res->Error == GameActions::Status::Ok) { // Valid location found. Place the ghost at the location. auto tdAction = TrackDesignAction({ trackLoc, _currentTrackPieceDirection }, *_trackDesign); tdAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); tdAction.SetCallback([trackLoc](const GameAction*, const TrackDesignActionResult* result) { - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { _window_track_place_ride_index = result->rideIndex; _windowTrackPlaceLastValid = trackLoc; @@ -296,7 +296,7 @@ static void window_track_place_toolupdate(rct_window* w, rct_widgetindex widgetI } }); res = GameActions::Execute(&tdAction); - cost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + cost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; } } @@ -331,11 +331,11 @@ static void window_track_place_tooldown(rct_window* w, rct_widgetindex widgetInd CoordsXYZ trackLoc = { mapCoords, mapZ }; auto res = FindValidTrackDesignPlaceHeight(trackLoc, 0); - if (res->Error == GA_ERROR::OK) + if (res->Error == GameActions::Status::Ok) { auto tdAction = TrackDesignAction({ trackLoc, _currentTrackPieceDirection }, *_trackDesign); tdAction.SetCallback([trackLoc](const GameAction*, const TrackDesignActionResult* result) { - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { auto ride = get_ride(result->rideIndex); if (ride != nullptr) @@ -435,7 +435,7 @@ void TrackPlaceRestoreProvisional() auto tdAction = TrackDesignAction({ _windowTrackPlaceLastValid, _currentTrackPieceDirection }, *_trackDesign); tdAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); auto res = GameActions::Execute(&tdAction); - if (res->Error != GA_ERROR::OK) + if (res->Error != GameActions::Status::Ok) { _window_track_place_last_was_valid = false; } diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 21dd103253..ac6759e95e 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -1159,7 +1159,7 @@ namespace OpenRCT2 try { res = Do(request); - if (res.status != Http::Status::OK) + if (res.status != Http::Status::Ok) throw std::runtime_error("bad http status"); } catch (std::exception& e) diff --git a/src/openrct2/ReplayManager.cpp b/src/openrct2/ReplayManager.cpp index cd451b32cf..2b010cca33 100644 --- a/src/openrct2/ReplayManager.cpp +++ b/src/openrct2/ReplayManager.cpp @@ -851,8 +851,8 @@ namespace OpenRCT2 GameAction* action = command.action.get(); action->SetFlags(action->GetFlags() | GAME_COMMAND_FLAG_REPLAY); - GameActionResult::Ptr result = GameActions::Execute(action); - if (result->Error == GA_ERROR::OK) + GameActions::Result::Ptr result = GameActions::Execute(action); + if (result->Error == GameActions::Status::Ok) { isPositionValid = true; } diff --git a/src/openrct2/Version.cpp b/src/openrct2/Version.cpp index 94e07095f5..e9ec6c84c2 100644 --- a/src/openrct2/Version.cpp +++ b/src/openrct2/Version.cpp @@ -72,7 +72,7 @@ NewVersionInfo get_latest_version() try { res = Do(request); - if (res.status != Http::Status::OK) + if (res.status != Http::Status::Ok) throw std::runtime_error("bad http status"); } catch (std::exception& e) diff --git a/src/openrct2/actions/BalloonPressAction.hpp b/src/openrct2/actions/BalloonPressAction.hpp index b6f78595a5..1494b4e035 100644 --- a/src/openrct2/actions/BalloonPressAction.hpp +++ b/src/openrct2/actions/BalloonPressAction.hpp @@ -12,7 +12,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(BalloonPressAction, GAME_COMMAND_BALLOON_PRESS, GameActionResult) +DEFINE_GAME_ACTION(BalloonPressAction, GAME_COMMAND_BALLOON_PRESS, GameActions::Result) { uint16_t _spriteIndex{ SPRITE_INDEX_NULL }; @@ -34,24 +34,24 @@ public: stream << DS_TAG(_spriteIndex); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto balloon = TryGetEntity(_spriteIndex); if (balloon == nullptr) { log_error("Tried getting invalid sprite for balloon: %u", _spriteIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto balloon = TryGetEntity(_spriteIndex); if (balloon == nullptr) { log_error("Tried getting invalid sprite for balloon: %u", _spriteIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } balloon->Press(); diff --git a/src/openrct2/actions/BannerPlaceAction.hpp b/src/openrct2/actions/BannerPlaceAction.hpp index ec8846b159..4e3ee579fc 100644 --- a/src/openrct2/actions/BannerPlaceAction.hpp +++ b/src/openrct2/actions/BannerPlaceAction.hpp @@ -15,7 +15,7 @@ #include "../world/Scenery.h" #include "GameAction.h" -DEFINE_GAME_ACTION(BannerPlaceAction, GAME_COMMAND_PLACE_BANNER, GameActionResult) +DEFINE_GAME_ACTION(BannerPlaceAction, GAME_COMMAND_PLACE_BANNER, GameActions::Result) { private: CoordsXYZD _loc; @@ -53,7 +53,7 @@ public: stream << DS_TAG(_loc) << DS_TAG(_bannerType) << DS_TAG(_bannerIndex) << DS_TAG(_primaryColour); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto res = MakeResult(); res->Position.x = _loc.x + 16; @@ -65,57 +65,58 @@ public: if (!map_check_free_elements_and_reorganise(1)) { log_error("No free map elements."); - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::NoFreeElements, STR_CANT_POSITION_THIS_HERE); } if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE); } auto pathElement = GetValidPathElement(); if (pathElement == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS); + return MakeResult( + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS); } if (!map_can_build_at(_loc)) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NotOwned, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK); } auto baseHeight = _loc.z + PATH_HEIGHT_STEP; BannerElement* existingBannerElement = map_get_banner_element_at({ _loc.x, _loc.y, baseHeight }, _loc.direction); if (existingBannerElement != nullptr) { - return MakeResult(GA_ERROR::ITEM_ALREADY_PLACED, STR_CANT_POSITION_THIS_HERE, STR_BANNER_SIGN_IN_THE_WAY); + return MakeResult(GameActions::Status::ItemAlreadyPlaced, STR_CANT_POSITION_THIS_HERE, STR_BANNER_SIGN_IN_THE_WAY); } if (_bannerIndex == BANNER_INDEX_NULL || _bannerIndex >= MAX_BANNERS) { log_error("Invalid banner index, bannerIndex = %u", _bannerIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE); } auto banner = GetBanner(_bannerIndex); if (!banner->IsNull()) { log_error("Banner index in use, bannerIndex = %u", _bannerIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE); } rct_scenery_entry* bannerEntry = get_banner_entry(_bannerType); if (bannerEntry == nullptr) { log_error("Invalid banner object type. bannerType = ", _bannerType); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE); } res->Cost = bannerEntry->banner.price; return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto res = MakeResult(); res->Position.x = _loc.x + 16; @@ -127,27 +128,27 @@ public: if (!map_check_free_elements_and_reorganise(1)) { log_error("No free map elements."); - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::NoFreeElements, STR_CANT_POSITION_THIS_HERE); } if (_bannerIndex == BANNER_INDEX_NULL || _bannerIndex >= MAX_BANNERS) { log_error("Invalid banner index, bannerIndex = %u", _bannerIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE); } rct_scenery_entry* bannerEntry = get_banner_entry(_bannerType); if (bannerEntry == nullptr) { log_error("Invalid banner object type. bannerType = ", _bannerType); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE); } auto banner = GetBanner(_bannerIndex); if (!banner->IsNull()) { log_error("Banner index in use, bannerIndex = %u", _bannerIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE); } TileElement* newTileElement = tile_element_insert({ _loc, _loc.z + (2 * COORDS_Z_STEP) }, 0b0000); diff --git a/src/openrct2/actions/BannerRemoveAction.hpp b/src/openrct2/actions/BannerRemoveAction.hpp index 91ffd9987b..9edd6b5a49 100644 --- a/src/openrct2/actions/BannerRemoveAction.hpp +++ b/src/openrct2/actions/BannerRemoveAction.hpp @@ -15,7 +15,7 @@ #include "../world/Scenery.h" #include "GameAction.h" -DEFINE_GAME_ACTION(BannerRemoveAction, GAME_COMMAND_REMOVE_BANNER, GameActionResult) +DEFINE_GAME_ACTION(BannerRemoveAction, GAME_COMMAND_REMOVE_BANNER, GameActions::Result) { private: CoordsXYZD _loc; @@ -44,7 +44,7 @@ public: stream << DS_TAG(_loc); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto res = MakeResult(); res->Expenditure = ExpenditureType::Landscaping; @@ -55,7 +55,7 @@ public: if (!LocationValid(_loc) || !map_can_build_at({ _loc.x, _loc.y, _loc.z - 16 })) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NotOwned, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } BannerElement* bannerElement = GetBannerElementAt(); @@ -63,20 +63,20 @@ public: { log_error( "Invalid banner location, x = %d, y = %d, z = %d, direction = %d", _loc.x, _loc.y, _loc.z, _loc.direction); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS); } if (bannerElement->GetIndex() >= MAX_BANNERS || bannerElement->GetIndex() == BANNER_INDEX_NULL) { log_error("Invalid banner index. index = ", bannerElement->GetIndex()); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS); } auto banner = bannerElement->GetBanner(); if (banner == nullptr) { log_error("Invalid banner index. index = ", bannerElement->GetIndex()); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS); } rct_scenery_entry* bannerEntry = get_banner_entry(banner->type); @@ -88,7 +88,7 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto res = MakeResult(); res->Expenditure = ExpenditureType::Landscaping; @@ -102,20 +102,20 @@ public: { log_error( "Invalid banner location, x = %d, y = %d, z = %d, direction = %d", _loc.x, _loc.y, _loc.z, _loc.direction); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS); } if (bannerElement->GetIndex() >= MAX_BANNERS || bannerElement->GetIndex() == BANNER_INDEX_NULL) { log_error("Invalid banner index. index = ", bannerElement->GetIndex()); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS); } auto banner = bannerElement->GetBanner(); if (banner == nullptr) { log_error("Invalid banner index. index = ", bannerElement->GetIndex()); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS); } rct_scenery_entry* bannerEntry = get_banner_entry(banner->type); diff --git a/src/openrct2/actions/BannerSetColourAction.hpp b/src/openrct2/actions/BannerSetColourAction.hpp index 56fd04bc44..5bd27c9927 100644 --- a/src/openrct2/actions/BannerSetColourAction.hpp +++ b/src/openrct2/actions/BannerSetColourAction.hpp @@ -15,7 +15,7 @@ #include "../world/Banner.h" #include "GameAction.h" -DEFINE_GAME_ACTION(BannerSetColourAction, GAME_COMMAND_SET_BANNER_COLOUR, GameActionResult) +DEFINE_GAME_ACTION(BannerSetColourAction, GAME_COMMAND_SET_BANNER_COLOUR, GameActions::Result) { private: CoordsXYZD _loc; @@ -32,7 +32,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -42,18 +42,18 @@ public: stream << DS_TAG(_loc) << DS_TAG(_primaryColour); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr QueryExecute(bool isExecuting) const + GameActions::Result::Ptr QueryExecute(bool isExecuting) const { auto res = MakeResult(); res->Expenditure = ExpenditureType::Landscaping; @@ -65,18 +65,18 @@ private: if (!LocationValid(_loc)) { log_error("Invalid x / y coordinates: x = %d, y = %d", _loc.x, _loc.y); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } if (_primaryColour > 31) { log_error("Invalid primary colour: colour = %u", _primaryColour); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } if (!map_can_build_at({ _loc.x, _loc.y, _loc.z - 16 })) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NotOwned, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); } auto bannerElement = map_get_banner_element_at(_loc, _loc.direction); @@ -85,14 +85,14 @@ private: { log_error( "Could not find banner at: x = %d, y = %d, z = %d, direction = %u", _loc.x, _loc.y, _loc.z, _loc.direction); - return MakeResult(GA_ERROR::UNKNOWN, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::Unknown, STR_CANT_REPAINT_THIS); } auto index = bannerElement->GetIndex(); if (index >= MAX_BANNERS || index == BANNER_INDEX_NULL) { log_error("Invalid banner index: index = %u", index); - return MakeResult(GA_ERROR::UNKNOWN, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::Unknown, STR_CANT_REPAINT_THIS); } if (isExecuting) diff --git a/src/openrct2/actions/BannerSetNameAction.hpp b/src/openrct2/actions/BannerSetNameAction.hpp index 61eded35a9..d49c38d9a9 100644 --- a/src/openrct2/actions/BannerSetNameAction.hpp +++ b/src/openrct2/actions/BannerSetNameAction.hpp @@ -20,7 +20,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(BannerSetNameAction, GAME_COMMAND_SET_BANNER_NAME, GameActionResult) +DEFINE_GAME_ACTION(BannerSetNameAction, GAME_COMMAND_SET_BANNER_NAME, GameActions::Result) { private: BannerIndex _bannerIndex{ BANNER_INDEX_NULL }; @@ -36,7 +36,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -45,17 +45,17 @@ public: stream << DS_TAG(_bannerIndex) << DS_TAG(_name); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_bannerIndex >= MAX_BANNERS) { log_warning("Invalid game command for setting banner name, banner id = %d", _bannerIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto banner = GetBanner(_bannerIndex); banner->text = _name; diff --git a/src/openrct2/actions/BannerSetStyleAction.hpp b/src/openrct2/actions/BannerSetStyleAction.hpp index 509c2a0a89..b34dabbd8d 100644 --- a/src/openrct2/actions/BannerSetStyleAction.hpp +++ b/src/openrct2/actions/BannerSetStyleAction.hpp @@ -26,7 +26,7 @@ enum class BannerSetStyleType : uint8_t Count }; -DEFINE_GAME_ACTION(BannerSetStyleAction, GAME_COMMAND_SET_BANNER_STYLE, GameActionResult) +DEFINE_GAME_ACTION(BannerSetStyleAction, GAME_COMMAND_SET_BANNER_STYLE, GameActions::Result) { private: BannerSetStyleType _type{ BannerSetStyleType::Count }; @@ -45,7 +45,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -55,13 +55,13 @@ public: stream << DS_TAG(_type) << DS_TAG(_bannerIndex) << DS_TAG(_parameter); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto res = MakeResult(); if (_bannerIndex >= MAX_BANNERS || _bannerIndex == BANNER_INDEX_NULL) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_SELECTION_OF_OBJECTS); + return MakeResult(GameActions::Status::InvalidParameters, STR_INVALID_SELECTION_OF_OBJECTS); } auto banner = GetBanner(_bannerIndex); @@ -75,7 +75,7 @@ public: if (tileElement == nullptr) { log_error("Could not find banner index = %u", _bannerIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } switch (_type) @@ -84,7 +84,7 @@ public: if (_parameter > 31) { log_error("Invalid primary colour: colour = %u", _parameter); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } break; @@ -92,24 +92,24 @@ public: if (_parameter > 13) { log_error("Invalid text colour: colour = %u", _parameter); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } break; case BannerSetStyleType::NoEntry: if (tileElement->AsBanner() == nullptr) { log_error("Tile element was not a banner."); - return MakeResult(GA_ERROR::UNKNOWN, STR_NONE); + return MakeResult(GameActions::Status::Unknown, STR_NONE); } break; default: log_error("Invalid type: %u", _type); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto res = MakeResult(); @@ -124,7 +124,7 @@ public: if (tileElement == nullptr) { log_error("Could not find banner index = %u", _bannerIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } switch (_type) @@ -141,7 +141,7 @@ public: if (bannerElement == nullptr) { log_error("Tile element was not a banner."); - return MakeResult(GA_ERROR::UNKNOWN, STR_NONE); + return MakeResult(GameActions::Status::Unknown, STR_NONE); } banner->flags &= ~BANNER_FLAG_NO_ENTRY; @@ -156,7 +156,7 @@ public: } default: log_error("Invalid type: %u", _type); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } auto intent = Intent(INTENT_ACTION_UPDATE_BANNER); diff --git a/src/openrct2/actions/ClearAction.hpp b/src/openrct2/actions/ClearAction.hpp index 784a19cd9e..4e91fe58d4 100644 --- a/src/openrct2/actions/ClearAction.hpp +++ b/src/openrct2/actions/ClearAction.hpp @@ -36,7 +36,7 @@ namespace CLEARABLE_ITEMS constexpr ClearableItems SCENERY_FOOTPATH = 1 << 2; } // namespace CLEARABLE_ITEMS -DEFINE_GAME_ACTION(ClearAction, GAME_COMMAND_CLEAR_SCENERY, GameActionResult) +DEFINE_GAME_ACTION(ClearAction, GAME_COMMAND_CLEAR_SCENERY, GameActions::Result) { private: MapRange _range; @@ -57,18 +57,18 @@ public: stream << DS_TAG(_range) << DS_TAG(_itemsToClear); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr CreateResult() const + GameActions::Result::Ptr CreateResult() const { auto result = MakeResult(); result->ErrorTitle = STR_UNABLE_TO_REMOVE_ALL_SCENERY_FROM_HERE; @@ -82,12 +82,12 @@ private: return result; } - GameActionResult::Ptr QueryExecute(bool executing) const + GameActions::Result::Ptr QueryExecute(bool executing) const { auto result = CreateResult(); auto noValidTiles = true; - auto error = GA_ERROR::OK; + auto error = GameActions::Status::Ok; rct_string_id errorMessage = STR_NONE; money32 totalCost = 0; @@ -111,7 +111,7 @@ private: } else { - error = GA_ERROR::NOT_OWNED; + error = GameActions::Status::NotOwned; errorMessage = STR_LAND_NOT_OWNED_BY_PARK; } } @@ -161,7 +161,7 @@ private: auto res = executing ? GameActions::ExecuteNested(&footpathRemoveAction) : GameActions::QueryNested(&footpathRemoveAction); - if (res->Error == GA_ERROR::OK) + if (res->Error == GameActions::Status::Ok) { totalCost += res->Cost; tileEdited = executing; @@ -179,7 +179,7 @@ private: auto res = executing ? GameActions::ExecuteNested(&removeSceneryAction) : GameActions::QueryNested(&removeSceneryAction); - if (res->Error == GA_ERROR::OK) + if (res->Error == GameActions::Status::Ok) { totalCost += res->Cost; tileEdited = executing; @@ -196,7 +196,7 @@ private: auto res = executing ? GameActions::ExecuteNested(&wallRemoveAction) : GameActions::QueryNested(&wallRemoveAction); - if (res->Error == GA_ERROR::OK) + if (res->Error == GameActions::Status::Ok) { totalCost += res->Cost; tileEdited = executing; @@ -214,7 +214,7 @@ private: auto res = executing ? GameActions::ExecuteNested(&removeSceneryAction) : GameActions::QueryNested(&removeSceneryAction); - if (res->Error == GA_ERROR::OK) + if (res->Error == GameActions::Status::Ok) { totalCost += res->Cost; tileEdited = executing; diff --git a/src/openrct2/actions/ClimateSetAction.hpp b/src/openrct2/actions/ClimateSetAction.hpp index d2ba4298cc..40fbf8dca4 100644 --- a/src/openrct2/actions/ClimateSetAction.hpp +++ b/src/openrct2/actions/ClimateSetAction.hpp @@ -12,7 +12,7 @@ #include "../world/Climate.h" #include "GameAction.h" -DEFINE_GAME_ACTION(ClimateSetAction, GAME_COMMAND_SET_CLIMATE, GameActionResult) +DEFINE_GAME_ACTION(ClimateSetAction, GAME_COMMAND_SET_CLIMATE, GameActions::Result) { private: ClimateType _climate{}; @@ -26,7 +26,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -36,22 +36,23 @@ public: stream << DS_TAG(_climate); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_climate >= ClimateType::Count) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_CLIMATE_ID, STR_NONE); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_INVALID_CLIMATE_ID, STR_NONE); } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { gClimate = ClimateType{ _climate }; gfx_invalidate_screen(); - return std::make_unique(); + return std::make_unique(); } }; diff --git a/src/openrct2/actions/CustomAction.hpp b/src/openrct2/actions/CustomAction.hpp index 0d4b975944..0ae306b047 100644 --- a/src/openrct2/actions/CustomAction.hpp +++ b/src/openrct2/actions/CustomAction.hpp @@ -15,7 +15,7 @@ # include "../scripting/ScriptEngine.h" # include "GameAction.h" -DEFINE_GAME_ACTION(CustomAction, GAME_COMMAND_CUSTOM, GameActionResult) +DEFINE_GAME_ACTION(CustomAction, GAME_COMMAND_CUSTOM, GameActions::Result) { private: std::string _id; @@ -41,7 +41,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -50,13 +50,13 @@ public: stream << DS_TAG(_id) << DS_TAG(_json); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto& scriptingEngine = OpenRCT2::GetContext()->GetScriptEngine(); return scriptingEngine.QueryOrExecuteCustomGameAction(_id, _json, false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto& scriptingEngine = OpenRCT2::GetContext()->GetScriptEngine(); return scriptingEngine.QueryOrExecuteCustomGameAction(_id, _json, true); diff --git a/src/openrct2/actions/FootpathPlaceAction.hpp b/src/openrct2/actions/FootpathPlaceAction.hpp index d6eec39a60..203bbdb341 100644 --- a/src/openrct2/actions/FootpathPlaceAction.hpp +++ b/src/openrct2/actions/FootpathPlaceAction.hpp @@ -23,7 +23,7 @@ #include "../world/Wall.h" #include "GameAction.h" -DEFINE_GAME_ACTION(FootpathPlaceAction, GAME_COMMAND_PLACE_PATH, GameActionResult) +DEFINE_GAME_ACTION(FootpathPlaceAction, GAME_COMMAND_PLACE_PATH, GameActions::Result) { private: CoordsXYZ _loc; @@ -61,9 +61,9 @@ public: stream << DS_TAG(_loc) << DS_TAG(_slope) << DS_TAG(_type) << DS_TAG(_direction); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); res->Cost = 0; res->Expenditure = ExpenditureType::Landscaping; res->Position = _loc.ToTileCentre(); @@ -72,33 +72,33 @@ public: if (!LocationValid(_loc) || map_is_edge(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_FOOTPATH_HERE, STR_OFF_EDGE_OF_MAP); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_BUILD_FOOTPATH_HERE, STR_OFF_EDGE_OF_MAP); } if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) && !map_is_location_owned(_loc)) { - return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BUILD_FOOTPATH_HERE, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_LAND_NOT_OWNED_BY_PARK); } if (_slope & SLOPE_IS_IRREGULAR_FLAG) { - return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BUILD_FOOTPATH_HERE, STR_LAND_SLOPE_UNSUITABLE); + return MakeResult(GameActions::Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_LAND_SLOPE_UNSUITABLE); } if (_loc.z < FootpathMinHeight) { - return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BUILD_FOOTPATH_HERE, STR_TOO_LOW); + return MakeResult(GameActions::Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_TOO_LOW); } if (_loc.z > FootpathMaxHeight) { - return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BUILD_FOOTPATH_HERE, STR_TOO_HIGH); + return MakeResult(GameActions::Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_TOO_HIGH); } if (_direction != INVALID_DIRECTION && !direction_valid(_direction)) { log_error("Direction invalid. direction = %u", _direction); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_FOOTPATH_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_BUILD_FOOTPATH_HERE); } footpath_provisional_remove(); @@ -113,9 +113,9 @@ public: } } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); res->Cost = 0; res->Expenditure = ExpenditureType::Landscaping; res->Position = _loc.ToTileCentre(); @@ -158,7 +158,7 @@ public: } private: - GameActionResult::Ptr ElementUpdateQuery(PathElement * pathElement, GameActionResult::Ptr res) const + GameActions::Result::Ptr ElementUpdateQuery(PathElement * pathElement, GameActions::Result::Ptr res) const { const int32_t newFootpathType = (_type & (FOOTPATH_PROPERTIES_TYPE_MASK >> 4)); const bool newPathIsQueue = ((_type >> 7) == 1); @@ -169,12 +169,12 @@ private: if (GetFlags() & GAME_COMMAND_FLAG_GHOST && !pathElement->IsGhost()) { - return MakeResult(GA_ERROR::UNKNOWN, STR_CANT_BUILD_FOOTPATH_HERE); + return MakeResult(GameActions::Status::Unknown, STR_CANT_BUILD_FOOTPATH_HERE); } return res; } - GameActionResult::Ptr ElementUpdateExecute(PathElement * pathElement, GameActionResult::Ptr res) const + GameActions::Result::Ptr ElementUpdateExecute(PathElement * pathElement, GameActions::Result::Ptr res) const { const int32_t newFootpathType = (_type & (FOOTPATH_PROPERTIES_TYPE_MASK >> 4)); const bool newPathIsQueue = ((_type >> 7) == 1); @@ -222,13 +222,13 @@ private: return res; } - GameActionResult::Ptr ElementInsertQuery(GameActionResult::Ptr res) const + GameActions::Result::Ptr ElementInsertQuery(GameActions::Result::Ptr res) const { bool entrancePath = false, entranceIsSamePath = false; if (!map_check_free_elements_and_reorganise(1)) { - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_CANT_BUILD_FOOTPATH_HERE); + return MakeResult(GameActions::Status::NoFreeElements, STR_CANT_BUILD_FOOTPATH_HERE); } res->Cost = MONEY(12, 00); @@ -262,19 +262,20 @@ private: && !map_can_construct_with_clear_at( { _loc, zLow, zHigh }, &map_place_non_scenery_clear_func, quarterTile, GetFlags(), &res->Cost, crossingMode)) { - return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_BUILD_FOOTPATH_HERE, gGameCommandErrorText, gCommonFormatArgs); + return MakeResult( + GameActions::Status::NoClearance, STR_CANT_BUILD_FOOTPATH_HERE, gGameCommandErrorText, gCommonFormatArgs); } gFootpathGroundFlags = gMapGroundFlags; if (!gCheatsDisableClearanceChecks && (gMapGroundFlags & ELEMENT_IS_UNDERWATER)) { - return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BUILD_FOOTPATH_HERE, STR_CANT_BUILD_THIS_UNDERWATER); + return MakeResult(GameActions::Status::Disallowed, STR_CANT_BUILD_FOOTPATH_HERE, STR_CANT_BUILD_THIS_UNDERWATER); } auto surfaceElement = map_get_surface_element_at(_loc); if (surfaceElement == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_FOOTPATH_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_BUILD_FOOTPATH_HERE); } int32_t supportHeight = zLow - surfaceElement->GetBaseZ(); res->Cost += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / PATH_HEIGHT_STEP) * MONEY(5, 00); @@ -286,7 +287,7 @@ private: return res; } - GameActionResult::Ptr ElementInsertExecute(GameActionResult::Ptr res) const + GameActions::Result::Ptr ElementInsertExecute(GameActions::Result::Ptr res) const { bool entrancePath = false, entranceIsSamePath = false; @@ -327,7 +328,8 @@ private: { _loc, zLow, zHigh }, &map_place_non_scenery_clear_func, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(), &res->Cost, crossingMode)) { - return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_BUILD_FOOTPATH_HERE, gGameCommandErrorText, gCommonFormatArgs); + return MakeResult( + GameActions::Status::NoClearance, STR_CANT_BUILD_FOOTPATH_HERE, gGameCommandErrorText, gCommonFormatArgs); } gFootpathGroundFlags = gMapGroundFlags; @@ -335,7 +337,7 @@ private: auto surfaceElement = map_get_surface_element_at(_loc); if (surfaceElement == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_FOOTPATH_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_BUILD_FOOTPATH_HERE); } int32_t supportHeight = zLow - surfaceElement->GetBaseZ(); res->Cost += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / PATH_HEIGHT_STEP) * MONEY(5, 00); diff --git a/src/openrct2/actions/FootpathPlaceFromTrackAction.hpp b/src/openrct2/actions/FootpathPlaceFromTrackAction.hpp index 45ed9b7351..6afeb828c5 100644 --- a/src/openrct2/actions/FootpathPlaceFromTrackAction.hpp +++ b/src/openrct2/actions/FootpathPlaceFromTrackAction.hpp @@ -22,7 +22,7 @@ #include "../world/Wall.h" #include "GameAction.h" -DEFINE_GAME_ACTION(FootpathPlaceFromTrackAction, GAME_COMMAND_PLACE_PATH_FROM_TRACK, GameActionResult) +DEFINE_GAME_ACTION(FootpathPlaceFromTrackAction, GAME_COMMAND_PLACE_PATH_FROM_TRACK, GameActions::Result) { private: CoordsXYZ _loc; @@ -52,9 +52,9 @@ public: stream << DS_TAG(_loc) << DS_TAG(_slope) << DS_TAG(_type) << DS_TAG(_edges); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); res->Cost = 0; res->Expenditure = ExpenditureType::Landscaping; res->Position = _loc.ToTileCentre(); @@ -64,30 +64,31 @@ public: if (!LocationValid(_loc) || map_is_edge(_loc)) { return MakeResult( - GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_OFF_EDGE_OF_MAP); + GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_OFF_EDGE_OF_MAP); } if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) && !map_is_location_owned(_loc)) { - return MakeResult(GA_ERROR::DISALLOWED, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult( + GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK); } if (_loc.z < FootpathMinHeight) { - return MakeResult(GA_ERROR::DISALLOWED, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_LOW); + return MakeResult(GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_LOW); } if (_loc.z > FootpathMaxHeight) { - return MakeResult(GA_ERROR::DISALLOWED, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_HIGH); + return MakeResult(GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_HIGH); } return ElementInsertQuery(std::move(res)); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); res->Cost = 0; res->Expenditure = ExpenditureType::Landscaping; res->Position = _loc.ToTileCentre(); @@ -106,13 +107,13 @@ public: } private: - GameActionResult::Ptr ElementInsertQuery(GameActionResult::Ptr res) const + GameActions::Result::Ptr ElementInsertQuery(GameActions::Result::Ptr res) const { bool entrancePath = false, entranceIsSamePath = false; if (!map_check_free_elements_and_reorganise(1)) { - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE); + return MakeResult(GameActions::Status::NoFreeElements, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE); } res->Cost = MONEY(12, 00); @@ -147,7 +148,7 @@ private: { _loc, zLow, zHigh }, &map_place_non_scenery_clear_func, quarterTile, GetFlags(), &res->Cost, crossingMode)) { return MakeResult( - GA_ERROR::NO_CLEARANCE, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, gGameCommandErrorText, + GameActions::Status::NoClearance, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, gGameCommandErrorText, gCommonFormatArgs); } @@ -155,13 +156,14 @@ private: if (!gCheatsDisableClearanceChecks && (gMapGroundFlags & ELEMENT_IS_UNDERWATER)) { return MakeResult( - GA_ERROR::DISALLOWED, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_CANT_BUILD_THIS_UNDERWATER); + GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, + STR_CANT_BUILD_THIS_UNDERWATER); } auto surfaceElement = map_get_surface_element_at(_loc); if (surfaceElement == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE); } int32_t supportHeight = zLow - surfaceElement->GetBaseZ(); res->Cost += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / PATH_HEIGHT_STEP) * MONEY(5, 00); @@ -173,7 +175,7 @@ private: return res; } - GameActionResult::Ptr ElementInsertExecute(GameActionResult::Ptr res) const + GameActions::Result::Ptr ElementInsertExecute(GameActions::Result::Ptr res) const { bool entrancePath = false, entranceIsSamePath = false; @@ -215,7 +217,7 @@ private: &res->Cost, crossingMode)) { return MakeResult( - GA_ERROR::NO_CLEARANCE, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, gGameCommandErrorText, + GameActions::Status::NoClearance, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, gGameCommandErrorText, gCommonFormatArgs); } @@ -224,7 +226,7 @@ private: auto surfaceElement = map_get_surface_element_at(_loc); if (surfaceElement == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE); } int32_t supportHeight = zLow - surfaceElement->GetBaseZ(); res->Cost += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / PATH_HEIGHT_STEP) * MONEY(5, 00); diff --git a/src/openrct2/actions/FootpathRemoveAction.hpp b/src/openrct2/actions/FootpathRemoveAction.hpp index ab94731b63..71504c2ea0 100644 --- a/src/openrct2/actions/FootpathRemoveAction.hpp +++ b/src/openrct2/actions/FootpathRemoveAction.hpp @@ -22,7 +22,7 @@ #include "BannerRemoveAction.hpp" #include "GameAction.h" -DEFINE_GAME_ACTION(FootpathRemoveAction, GAME_COMMAND_REMOVE_PATH, GameActionResult) +DEFINE_GAME_ACTION(FootpathRemoveAction, GAME_COMMAND_REMOVE_PATH, GameActions::Result) { private: CoordsXYZ _loc; @@ -51,27 +51,27 @@ public: stream << DS_TAG(_loc); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); res->Cost = 0; res->Expenditure = ExpenditureType::Landscaping; res->Position = { _loc.x + 16, _loc.y + 16, _loc.z }; if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NotOwned, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_LAND_NOT_OWNED_BY_PARK); } if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) && !map_is_location_owned(_loc)) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NotOwned, STR_CANT_REMOVE_FOOTPATH_FROM_HERE, STR_LAND_NOT_OWNED_BY_PARK); } TileElement* footpathElement = GetFootpathElement(); if (footpathElement == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_FOOTPATH_FROM_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_FOOTPATH_FROM_HERE); } res->Cost = GetRefundPrice(footpathElement); @@ -79,9 +79,9 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); res->Cost = 0; res->Expenditure = ExpenditureType::Landscaping; res->Position = { _loc.x + 16, _loc.y + 16, _loc.z }; @@ -97,7 +97,7 @@ public: { footpath_queue_chain_reset(); auto bannerRes = RemoveBannersAtElement(_loc, footpathElement); - if (bannerRes->Error == GA_ERROR::OK) + if (bannerRes->Error == GameActions::Status::Ok) { res->Cost += bannerRes->Cost; } @@ -119,7 +119,7 @@ public: } else { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_FOOTPATH_FROM_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_FOOTPATH_FROM_HERE); } res->Cost += GetRefundPrice(footpathElement); @@ -167,7 +167,7 @@ private: * * rct2: 0x006BA23E */ - GameActionResult::Ptr RemoveBannersAtElement(const CoordsXY& loc, TileElement* tileElement) const + GameActions::Result::Ptr RemoveBannersAtElement(const CoordsXY& loc, TileElement* tileElement) const { auto result = MakeResult(); while (!(tileElement++)->IsLastForTile()) @@ -184,7 +184,7 @@ private: bannerRemoveAction.SetFlags(bannerFlags); auto res = GameActions::ExecuteNested(&bannerRemoveAction); // Ghost removal is free - if (res->Error == GA_ERROR::OK && !isGhost) + if (res->Error == GameActions::Status::Ok && !isGhost) { result->Cost += res->Cost; } diff --git a/src/openrct2/actions/FootpathSceneryPlaceAction.hpp b/src/openrct2/actions/FootpathSceneryPlaceAction.hpp index 4daf63adf5..3138a5cee3 100644 --- a/src/openrct2/actions/FootpathSceneryPlaceAction.hpp +++ b/src/openrct2/actions/FootpathSceneryPlaceAction.hpp @@ -22,7 +22,7 @@ #include "../world/Wall.h" #include "GameAction.h" -DEFINE_GAME_ACTION(FootpathSceneryPlaceAction, GAME_COMMAND_PLACE_FOOTPATH_SCENERY, GameActionResult) +DEFINE_GAME_ACTION(FootpathSceneryPlaceAction, GAME_COMMAND_PLACE_FOOTPATH_SCENERY, GameActions::Result) { private: CoordsXYZ _loc; @@ -54,43 +54,44 @@ public: stream << DS_TAG(_loc) << DS_TAG(_pathItemType); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto res = MakeResult(); res->Expenditure = ExpenditureType::Landscaping; res->Position = _loc; if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_OFF_EDGE_OF_MAP); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_OFF_EDGE_OF_MAP); } if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) && !map_is_location_owned(_loc)) { - return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::Disallowed, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK); } if (_loc.z < FootpathMinHeight) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_TOO_LOW); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_LOW); } if (_loc.z > FootpathMaxHeight) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_TOO_HIGH); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_TOO_HIGH); } auto tileElement = map_get_footpath_element(_loc); if (tileElement == nullptr) { log_error("Could not find path element."); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE); } auto pathElement = tileElement->AsPath(); if (pathElement->IsLevelCrossing(_loc)) { return MakeResult( - GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_CANNOT_BUILD_PATH_ADDITIONS_ON_LEVEL_CROSSINGS); + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, + STR_CANNOT_BUILD_PATH_ADDITIONS_ON_LEVEL_CROSSINGS); } // No change @@ -105,32 +106,35 @@ public: rct_scenery_entry* sceneryEntry = get_footpath_item_entry(_pathItemType - 1); if (sceneryEntry == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE); } uint16_t sceneryFlags = sceneryEntry->path_bit.flags; if ((sceneryFlags & PATH_BIT_FLAG_DONT_ALLOW_ON_SLOPE) && pathElement->IsSloped()) { return MakeResult( - GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_CANT_BUILD_THIS_ON_SLOPED_FOOTPATH); + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, + STR_CANT_BUILD_THIS_ON_SLOPED_FOOTPATH); } if ((sceneryFlags & PATH_BIT_FLAG_DONT_ALLOW_ON_QUEUE) && pathElement->IsQueue()) { return MakeResult( - GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_CANNOT_PLACE_THESE_ON_QUEUE_LINE_AREA); + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, + STR_CANNOT_PLACE_THESE_ON_QUEUE_LINE_AREA); } if (!(sceneryFlags & (PATH_BIT_FLAG_JUMPING_FOUNTAIN_WATER | PATH_BIT_FLAG_JUMPING_FOUNTAIN_SNOW)) && (pathElement->GetEdges()) == 0x0F) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE); } if ((sceneryFlags & PATH_BIT_FLAG_IS_QUEUE_SCREEN) && !pathElement->IsQueue()) { return MakeResult( - GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE, STR_CAN_ONLY_PLACE_THESE_ON_QUEUE_AREA); + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, + STR_CAN_ONLY_PLACE_THESE_ON_QUEUE_AREA); } res->Cost = sceneryEntry->path_bit.price; @@ -142,13 +146,13 @@ public: // Check if there is something on the path already if (pathElement->HasAddition()) { - return MakeResult(GA_ERROR::ITEM_ALREADY_PLACED, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::ItemAlreadyPlaced, STR_CANT_POSITION_THIS_HERE); } } return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto res = MakeResult(); res->Position = _loc; @@ -160,7 +164,7 @@ public: if (pathElement == nullptr) { log_error("Could not find path element."); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE); } // No change @@ -175,7 +179,7 @@ public: rct_scenery_entry* sceneryEntry = get_footpath_item_entry(_pathItemType - 1); if (sceneryEntry == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE); } res->Cost = sceneryEntry->path_bit.price; diff --git a/src/openrct2/actions/FootpathSceneryRemoveAction.hpp b/src/openrct2/actions/FootpathSceneryRemoveAction.hpp index b9b473ec7e..134122caed 100644 --- a/src/openrct2/actions/FootpathSceneryRemoveAction.hpp +++ b/src/openrct2/actions/FootpathSceneryRemoveAction.hpp @@ -21,7 +21,7 @@ #include "../world/Wall.h" #include "GameAction.h" -DEFINE_GAME_ACTION(FootpathSceneryRemoveAction, GAME_COMMAND_REMOVE_FOOTPATH_SCENERY, GameActionResult) +DEFINE_GAME_ACTION(FootpathSceneryRemoveAction, GAME_COMMAND_REMOVE_FOOTPATH_SCENERY, GameActions::Result) { private: CoordsXYZ _loc; @@ -51,46 +51,46 @@ public: stream << DS_TAG(_loc); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_OFF_EDGE_OF_MAP); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_OFF_EDGE_OF_MAP); } if (!((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode) && !map_is_location_owned(_loc)) { - return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::Disallowed, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } if (_loc.z < FootpathMinHeight) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_TOO_LOW); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_TOO_LOW); } if (_loc.z > FootpathMaxHeight) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_TOO_HIGH); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_TOO_HIGH); } auto tileElement = map_get_footpath_element(_loc); if (tileElement == nullptr) { log_warning("Could not find path element."); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS); } auto pathElement = tileElement->AsPath(); if (pathElement == nullptr) { log_warning("Could not find path element."); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS); } if (!pathElement->AdditionIsGhost() && (GetFlags() & GAME_COMMAND_FLAG_GHOST)) { log_warning("Tried to remove non ghost during ghost removal."); - return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::Disallowed, STR_CANT_REMOVE_THIS); } auto res = MakeResult(); res->Position = _loc; @@ -98,7 +98,7 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto tileElement = map_get_footpath_element(_loc); auto pathElement = tileElement->AsPath(); @@ -111,7 +111,7 @@ public: if (pathElement == nullptr) { log_error("Could not find path element."); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS); } pathElement->SetAddition(0); diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index 3945c64091..cb15fb7cb8 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -31,57 +31,57 @@ using namespace OpenRCT2; -GameActionResult::GameActionResult(GA_ERROR error, rct_string_id message) -{ - Error = error; - ErrorMessage = message; -} - -GameActionResult::GameActionResult(GA_ERROR error, rct_string_id title, rct_string_id message) -{ - Error = error; - ErrorTitle = title; - ErrorMessage = message; -} - -GameActionResult::GameActionResult(GA_ERROR error, rct_string_id title, rct_string_id message, uint8_t* args) -{ - Error = error; - ErrorTitle = title; - ErrorMessage = message; - std::copy_n(args, ErrorMessageArgs.size(), ErrorMessageArgs.begin()); -} - -std::string GameActionResult::GetErrorTitle() const -{ - std::string title; - if (auto error = ErrorTitle.AsString()) - { - title = *error; - } - else - { - title = format_string(ErrorTitle.GetStringId(), ErrorMessageArgs.data()); - } - return title; -} - -std::string GameActionResult::GetErrorMessage() const -{ - std::string message; - if (auto error = ErrorMessage.AsString()) - { - message = *error; - } - else - { - message = format_string(ErrorMessage.GetStringId(), ErrorMessageArgs.data()); - } - return message; -} - namespace GameActions { + Result::Result(GameActions::Status error, rct_string_id message) + { + Error = error; + ErrorMessage = message; + } + + Result::Result(GameActions::Status error, rct_string_id title, rct_string_id message) + { + Error = error; + ErrorTitle = title; + ErrorMessage = message; + } + + Result::Result(GameActions::Status error, rct_string_id title, rct_string_id message, uint8_t* args) + { + Error = error; + ErrorTitle = title; + ErrorMessage = message; + std::copy_n(args, ErrorMessageArgs.size(), ErrorMessageArgs.begin()); + } + + std::string GameActions::Result::GetErrorTitle() const + { + std::string title; + if (auto error = ErrorTitle.AsString()) + { + title = *error; + } + else + { + title = format_string(ErrorTitle.GetStringId(), ErrorMessageArgs.data()); + } + return title; + } + + std::string GameActions::Result::GetErrorMessage() const + { + std::string message; + if (auto error = ErrorMessage.AsString()) + { + message = *error; + } + else + { + message = format_string(ErrorMessage.GetStringId(), ErrorMessageArgs.data()); + } + return message; + } + struct QueuedGameAction { uint32_t tick; @@ -207,8 +207,8 @@ namespace GameActions Guard::Assert(action != nullptr); - GameActionResult::Ptr result = Execute(action); - if (result->Error == GA_ERROR::OK && network_get_mode() == NETWORK_MODE_SERVER) + GameActions::Result::Ptr result = Execute(action); + if (result->Error == GameActions::Status::Ok && network_get_mode() == NETWORK_MODE_SERVER) { // Relay this action to all other clients. network_send_game_action(action); @@ -278,21 +278,21 @@ namespace GameActions return true; if (gCheatsBuildInPauseMode) return true; - if (actionFlags & GA_FLAGS::ALLOW_WHILE_PAUSED) + if (actionFlags & GameActions::Flags::AllowWhilePaused) return true; return false; } - static GameActionResult::Ptr QueryInternal(const GameAction* action, bool topLevel) + static GameActions::Result::Ptr QueryInternal(const GameAction* action, bool topLevel) { Guard::ArgumentNotNull(action); uint16_t actionFlags = action->GetActionFlags(); if (topLevel && !CheckActionInPausedMode(actionFlags)) { - GameActionResult::Ptr result = std::make_unique(); + GameActions::Result::Ptr result = std::make_unique(); - result->Error = GA_ERROR::GAME_PAUSED; + result->Error = GameActions::Status::GamePaused; result->ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; result->ErrorMessage = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; @@ -301,11 +301,11 @@ namespace GameActions auto result = action->Query(); - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { if (!finance_check_affordability(result->Cost, action->GetFlags())) { - result->Error = GA_ERROR::INSUFFICIENT_FUNDS; + result->Error = GameActions::Status::InsufficientFunds; result->ErrorTitle = STR_CANT_DO_THIS; result->ErrorMessage = STR_NOT_ENOUGH_CASH_REQUIRES; Formatter(result->ErrorMessageArgs.data()).Add(result->Cost); @@ -314,12 +314,12 @@ namespace GameActions return result; } - GameActionResult::Ptr Query(const GameAction* action) + GameActions::Result::Ptr Query(const GameAction* action) { return QueryInternal(action, true); } - GameActionResult::Ptr QueryNested(const GameAction* action) + GameActions::Result::Ptr QueryNested(const GameAction* action) { return QueryInternal(action, false); } @@ -355,13 +355,13 @@ namespace GameActions action->Serialise(ds); } - static void LogActionFinish(ActionLogContext_t& ctx, const GameAction* action, const GameActionResult::Ptr& result) + static void LogActionFinish(ActionLogContext_t& ctx, const GameAction* action, const GameActions::Result::Ptr& result) { MemoryStream& output = ctx.output; char temp[128] = {}; - if (result->Error != GA_ERROR::OK) + if (result->Error != GameActions::Status::Ok) { snprintf(temp, sizeof(temp), ") Failed, %u", static_cast(result->Error)); } @@ -378,7 +378,7 @@ namespace GameActions network_append_server_log(text); } - static GameActionResult::Ptr ExecuteInternal(const GameAction* action, bool topLevel) + static GameActions::Result::Ptr ExecuteInternal(const GameAction* action, bool topLevel) { Guard::ArgumentNotNull(action); @@ -392,9 +392,9 @@ namespace GameActions if ((flags & GAME_COMMAND_FLAG_REPLAY) == 0) { // TODO: Introduce proper error. - GameActionResult::Ptr result = std::make_unique(); + GameActions::Result::Ptr result = std::make_unique(); - result->Error = GA_ERROR::GAME_PAUSED; + result->Error = GameActions::Status::GamePaused; result->ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; result->ErrorMessage = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; @@ -402,9 +402,9 @@ namespace GameActions } } - GameActionResult::Ptr result = QueryInternal(action, topLevel); + GameActions::Result::Ptr result = QueryInternal(action, topLevel); #ifdef ENABLE_SCRIPTING - if (result->Error == GA_ERROR::OK + if (result->Error == GameActions::Status::Ok && ((network_get_mode() == NETWORK_MODE_NONE) || (flags & GAME_COMMAND_FLAG_NETWORKED))) { auto& scriptEngine = GetContext()->GetScriptEngine(); @@ -412,7 +412,7 @@ namespace GameActions // Script hooks may now have changed the game action result... } #endif - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { if (topLevel) { @@ -420,7 +420,7 @@ namespace GameActions if (network_get_mode() == NETWORK_MODE_CLIENT) { // As a client we have to wait or send it first. - if (!(actionFlags & GA_FLAGS::CLIENT_ONLY) && !(flags & GAME_COMMAND_FLAG_NETWORKED)) + if (!(actionFlags & GameActions::Flags::ClientOnly) && !(flags & GAME_COMMAND_FLAG_NETWORKED)) { log_verbose("[%s] GameAction::Execute %s (Out)", GetRealm(), action->GetName()); network_send_game_action(action); @@ -432,7 +432,7 @@ namespace GameActions { // If player is the server it would execute right away as where clients execute the commands // at the beginning of the frame, so we have to put them into the queue. - if (!(actionFlags & GA_FLAGS::CLIENT_ONLY) && !(flags & GAME_COMMAND_FLAG_NETWORKED)) + if (!(actionFlags & GameActions::Flags::ClientOnly) && !(flags & GAME_COMMAND_FLAG_NETWORKED)) { log_verbose("[%s] GameAction::Execute %s (Queue)", GetRealm(), action->GetName()); Enqueue(action, gCurrentTicks); @@ -448,7 +448,7 @@ namespace GameActions // Execute the action, changing the game state result = action->Execute(); #ifdef ENABLE_SCRIPTING - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { auto& scriptEngine = GetContext()->GetScriptEngine(); scriptEngine.RunGameActionHooks(*action, result, true); @@ -463,13 +463,13 @@ namespace GameActions return result; // Update money balance - if (result->Error == GA_ERROR::OK && finance_check_money_required(flags) && result->Cost != 0) + if (result->Error == GameActions::Status::Ok && finance_check_money_required(flags) && result->Cost != 0) { finance_payment(result->Cost, result->Expenditure); MoneyEffect::Create(result->Cost, result->Position); } - if (!(actionFlags & GA_FLAGS::CLIENT_ONLY) && result->Error == GA_ERROR::OK) + if (!(actionFlags & GameActions::Flags::ClientOnly) && result->Error == GameActions::Status::Ok) { if (network_get_mode() != NETWORK_MODE_NONE) { @@ -538,7 +538,7 @@ namespace GameActions } } - if (result->Error != GA_ERROR::OK && shouldShowError) + if (result->Error != GameActions::Status::Ok && shouldShowError) { auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); windowManager->ShowError(result->GetErrorTitle(), result->GetErrorMessage()); @@ -547,12 +547,12 @@ namespace GameActions return result; } - GameActionResult::Ptr Execute(const GameAction* action) + GameActions::Result::Ptr Execute(const GameAction* action) { return ExecuteInternal(action, true); } - GameActionResult::Ptr ExecuteNested(const GameAction* action) + GameActions::Result::Ptr ExecuteNested(const GameAction* action) { return ExecuteInternal(action, false); } @@ -577,7 +577,7 @@ bool GameAction::LocationValid(const CoordsXY& coords) const obj.Set("type", _type); auto flags = GetActionFlags(); - obj.Set("isClientOnly", (flags & GA_FLAGS::CLIENT_ONLY) != 0); + obj.Set("isClientOnly", (flags & GameActions::Flags::ClientOnly) != 0); obj.Set("result", true); // Call the subscriptions diff --git a/src/openrct2/actions/GameAction.h b/src/openrct2/actions/GameAction.h index b97a204249..a8064c5b96 100644 --- a/src/openrct2/actions/GameAction.h +++ b/src/openrct2/actions/GameAction.h @@ -21,45 +21,6 @@ #include #include -/** - * Common error codes for game actions. - */ -enum class GA_ERROR : uint16_t -{ - OK, - INVALID_PARAMETERS, - DISALLOWED, - GAME_PAUSED, - INSUFFICIENT_FUNDS, - NOT_IN_EDITOR_MODE, - - NOT_OWNED, - TOO_LOW, - TOO_HIGH, - NO_CLEARANCE, - ITEM_ALREADY_PLACED, - - NOT_CLOSED, - BROKEN, - - NO_FREE_ELEMENTS, - - UNKNOWN = UINT16_MAX, -}; - -namespace GA_FLAGS -{ - constexpr uint16_t ALLOW_WHILE_PAUSED = 1 << 0; - constexpr uint16_t CLIENT_ONLY = 1 << 1; - constexpr uint16_t EDITOR_ONLY = 1 << 2; -} // namespace GA_FLAGS - -#ifdef __WARN_SUGGEST_FINAL_METHODS__ -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wsuggest-final-methods" -# pragma GCC diagnostic ignored "-Wsuggest-final-types" -#endif - class StringVariant { private: @@ -113,38 +74,81 @@ public: } }; -/** - * Represents the result of a game action query or execution. - */ -class GameActionResult +#ifdef __WARN_SUGGEST_FINAL_METHODS__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wsuggest-final-methods" +# pragma GCC diagnostic ignored "-Wsuggest-final-types" +#endif + +namespace GameActions { -public: - using Ptr = std::unique_ptr; + /** + * Common error codes for game actions. + */ + enum class Status : uint16_t + { + Ok, + InvalidParameters, + Disallowed, + GamePaused, + InsufficientFunds, + NotInEditorMode, - GA_ERROR Error = GA_ERROR::OK; - StringVariant ErrorTitle; - StringVariant ErrorMessage; - std::array ErrorMessageArgs; - CoordsXYZ Position = { LOCATION_NULL, LOCATION_NULL, LOCATION_NULL }; - money32 Cost = 0; - ExpenditureType Expenditure = ExpenditureType::Count; + NotOwned, + TooLow, + TooHigh, + NoClearance, + ItemAlreadyPlaced, - GameActionResult() = default; - GameActionResult(GA_ERROR error, rct_string_id message); - GameActionResult(GA_ERROR error, rct_string_id title, rct_string_id message); - GameActionResult(GA_ERROR error, rct_string_id title, rct_string_id message, uint8_t* args); - GameActionResult(const GameActionResult&) = delete; - virtual ~GameActionResult(){}; + NotClosed, + Broken, - std::string GetErrorTitle() const; - std::string GetErrorMessage() const; -}; + NoFreeElements, -class ConstructClearResult final : public GameActionResult -{ -public: - uint8_t GroundFlags{ 0 }; -}; + Unknown = UINT16_MAX, + }; + + namespace Flags + { + constexpr uint16_t AllowWhilePaused = 1 << 0; + constexpr uint16_t ClientOnly = 1 << 1; + constexpr uint16_t EditorOnly = 1 << 2; + } // namespace Flags + + /** + * Represents the result of a game action query or execution. + */ + class Result + { + public: + using Ptr = std::unique_ptr; + + GameActions::Status Error = GameActions::Status::Ok; + StringVariant ErrorTitle; + StringVariant ErrorMessage; + std::array ErrorMessageArgs; + CoordsXYZ Position = { LOCATION_NULL, LOCATION_NULL, LOCATION_NULL }; + money32 Cost = 0; + ExpenditureType Expenditure = ExpenditureType::Count; + + Result() = default; + Result(GameActions::Status error, rct_string_id message); + Result(GameActions::Status error, rct_string_id title, rct_string_id message); + Result(GameActions::Status error, rct_string_id title, rct_string_id message, uint8_t* args); + Result(const GameActions::Result&) = delete; + virtual ~Result(){}; + + std::string GetErrorTitle() const; + std::string GetErrorMessage() const; + }; + + class ConstructClearResult final : public Result + { + public: + uint8_t GroundFlags{ 0 }; + }; + +} // namespace GameActions /** * @@ -205,7 +209,7 @@ struct GameAction { public: using Ptr = std::unique_ptr; - using Callback_t = std::function; + using Callback_t = std::function; private: uint32_t const _type; @@ -240,7 +244,7 @@ public: } /** - * Gets the GA_FLAGS flags that are enabled for this game action. + * Gets the GameActions::Flags flags that are enabled for this game action. */ virtual uint16_t GetActionFlags() const { @@ -249,12 +253,12 @@ public: if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) != 0 || (GetFlags() & GAME_COMMAND_FLAG_NO_SPEND) != 0) { - flags |= GA_FLAGS::CLIENT_ONLY; + flags |= GameActions::Flags::ClientOnly; } if (GetFlags() & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) { - flags |= GA_FLAGS::ALLOW_WHILE_PAUSED; + flags |= GameActions::Flags::AllowWhilePaused; } return flags; @@ -321,12 +325,12 @@ public: /** * Query the result of the game action without changing the game state. */ - virtual GameActionResult::Ptr Query() const abstract; + virtual GameActions::Result::Ptr Query() const abstract; /** * Apply the game action and change the game state. */ - virtual GameActionResult::Ptr Execute() const abstract; + virtual GameActions::Result::Ptr Execute() const abstract; bool LocationValid(const CoordsXY& coords) const; }; @@ -358,7 +362,7 @@ public: void SetCallback(std::function typedCallback) { - GameAction::SetCallback([typedCallback](const GameAction* ga, const GameActionResult* result) { + GameAction::SetCallback([typedCallback](const GameAction* ga, const GameActions::Result* result) { typedCallback(ga, static_cast(result)); }); } @@ -370,10 +374,10 @@ protected: } }; -using GameActionFactory = GameAction* (*)(); - namespace GameActions { + using GameActionFactory = GameAction* (*)(); + void Initialize(); void Register(); bool IsValidId(uint32_t id); @@ -395,12 +399,12 @@ namespace GameActions GameAction::Ptr Clone(const GameAction* action); // This should be used if a round trip is to be expected. - GameActionResult::Ptr Query(const GameAction* action); - GameActionResult::Ptr Execute(const GameAction* action); + GameActions::Result::Ptr Query(const GameAction* action); + GameActions::Result::Ptr Execute(const GameAction* action); // This should be used from within game actions. - GameActionResult::Ptr QueryNested(const GameAction* action); - GameActionResult::Ptr ExecuteNested(const GameAction* action); + GameActions::Result::Ptr QueryNested(const GameAction* action); + GameActions::Result::Ptr ExecuteNested(const GameAction* action); GameActionFactory Register(uint32_t id, GameActionFactory action); diff --git a/src/openrct2/actions/GameActionCompat.cpp b/src/openrct2/actions/GameActionCompat.cpp index 16128c390c..576778a671 100644 --- a/src/openrct2/actions/GameActionCompat.cpp +++ b/src/openrct2/actions/GameActionCompat.cpp @@ -33,7 +33,7 @@ money32 park_entrance_place_ghost(const CoordsXYZD& entranceLoc) gameAction.SetFlags(GAME_COMMAND_FLAG_GHOST); auto result = GameActions::Execute(&gameAction); - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { gParkEntranceGhostPosition = entranceLoc; gParkEntranceGhostExists = true; @@ -64,7 +64,7 @@ void ride_construct_new(RideSelection listItem) auto gameAction = RideCreateAction(listItem.Type, listItem.EntryIndex, colour1, colour2); gameAction.SetCallback([](const GameAction* ga, const RideCreateGameActionResult* result) { - if (result->Error != GA_ERROR::OK) + if (result->Error != GameActions::Status::Ok) return; auto ride = get_ride(result->rideIndex); @@ -131,7 +131,7 @@ money32 maze_set_track( auto gameAction = MazeSetTrackAction({ x, y, z, direction }, initialPlacement, rideIndex, mode); gameAction.SetFlags(flags); - GameActionResult::Ptr res; + GameActions::Result::Ptr res; if (!(flags & GAME_COMMAND_FLAG_APPLY)) res = GameActions::Query(&gameAction); @@ -149,7 +149,7 @@ money32 maze_set_track( else gGameCommandErrorText = STR_NONE; - if (res->Error != GA_ERROR::OK) + if (res->Error != GameActions::Status::Ok) { return MONEY32_UNDEFINED; } diff --git a/src/openrct2/actions/GuestSetFlagsAction.hpp b/src/openrct2/actions/GuestSetFlagsAction.hpp index 30b7332f4a..54b169bc4b 100644 --- a/src/openrct2/actions/GuestSetFlagsAction.hpp +++ b/src/openrct2/actions/GuestSetFlagsAction.hpp @@ -14,7 +14,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(GuestSetFlagsAction, GAME_COMMAND_GUEST_SET_FLAGS, GameActionResult) +DEFINE_GAME_ACTION(GuestSetFlagsAction, GAME_COMMAND_GUEST_SET_FLAGS, GameActions::Result) { private: uint16_t _peepId{ SPRITE_INDEX_NULL }; @@ -30,7 +30,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -40,28 +40,28 @@ public: stream << DS_TAG(_peepId) << DS_TAG(_newFlags); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { Peep* peep = TryGetEntity(_peepId); if (peep == nullptr) { log_error("Used invalid sprite index for peep: %u", static_cast(_peepId)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_THIS); } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { Peep* peep = TryGetEntity(_peepId); if (peep == nullptr) { log_error("Used invalid sprite index for peep: %u", static_cast(_peepId)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_THIS); } peep->PeepFlags = _newFlags; - return std::make_unique(); + return std::make_unique(); } }; diff --git a/src/openrct2/actions/GuestSetNameAction.hpp b/src/openrct2/actions/GuestSetNameAction.hpp index 71086cb357..9403bcc731 100644 --- a/src/openrct2/actions/GuestSetNameAction.hpp +++ b/src/openrct2/actions/GuestSetNameAction.hpp @@ -21,7 +21,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(GuestSetNameAction, GAME_COMMAND_SET_GUEST_NAME, GameActionResult) +DEFINE_GAME_ACTION(GuestSetNameAction, GAME_COMMAND_SET_GUEST_NAME, GameActions::Result) { private: uint16_t _spriteIndex{ SPRITE_INDEX_NULL }; @@ -53,7 +53,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -63,41 +63,41 @@ public: stream << DS_TAG(_spriteIndex) << DS_TAG(_name); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_spriteIndex >= MAX_SPRITES) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_CANT_NAME_GUEST, STR_NONE); } auto guest = TryGetEntity(_spriteIndex); if (guest == nullptr) { log_warning("Invalid game command for sprite %u", _spriteIndex); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_CANT_NAME_GUEST, STR_NONE); } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto guest = TryGetEntity(_spriteIndex); if (guest == nullptr) { log_warning("Invalid game command for sprite %u", _spriteIndex); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_CANT_NAME_GUEST, STR_NONE); } auto curName = guest->GetName(); if (curName == _name) { - return std::make_unique(GA_ERROR::OK, STR_NONE); + return std::make_unique(GameActions::Status::Ok, STR_NONE); } if (!guest->SetName(_name)) { - return std::make_unique(GA_ERROR::UNKNOWN, STR_CANT_NAME_GUEST, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_CANT_NAME_GUEST, STR_NONE); } // Easter egg functions are for guests only @@ -108,7 +108,7 @@ public: auto intent = Intent(INTENT_ACTION_REFRESH_GUEST_LIST); context_broadcast_intent(&intent); - auto res = std::make_unique(); + auto res = std::make_unique(); res->Position.x = guest->x; res->Position.y = guest->y; res->Position.z = guest->z; diff --git a/src/openrct2/actions/LandBuyRightsAction.hpp b/src/openrct2/actions/LandBuyRightsAction.hpp index 3516d4fc4e..d6afbe25c6 100644 --- a/src/openrct2/actions/LandBuyRightsAction.hpp +++ b/src/openrct2/actions/LandBuyRightsAction.hpp @@ -33,7 +33,7 @@ enum class LandBuyRightSetting : uint8_t Count }; -DEFINE_GAME_ACTION(LandBuyRightsAction, GAME_COMMAND_BUY_LAND_RIGHTS, GameActionResult) +DEFINE_GAME_ACTION(LandBuyRightsAction, GAME_COMMAND_BUY_LAND_RIGHTS, GameActions::Result) { private: MapRange _range; @@ -68,18 +68,18 @@ public: stream << DS_TAG(_range) << DS_TAG(_setting); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr QueryExecute(bool isExecuting) const + GameActions::Result::Ptr QueryExecute(bool isExecuting) const { auto res = MakeResult(); @@ -107,7 +107,7 @@ private: if (!LocationValid({ x, y })) continue; auto result = map_buy_land_rights_for_tile({ x, y }, isExecuting); - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { res->Cost += result->Cost; } @@ -120,19 +120,19 @@ private: return res; } - GameActionResult::Ptr map_buy_land_rights_for_tile(const CoordsXY& loc, bool isExecuting) const + GameActions::Result::Ptr map_buy_land_rights_for_tile(const CoordsXY& loc, bool isExecuting) const { if (_setting >= LandBuyRightSetting::Count) { log_warning("Tried calling buy land rights with an incorrect setting. setting = %u", _setting); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, _ErrorTitles[0], STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, _ErrorTitles[0], STR_NONE); } SurfaceElement* surfaceElement = map_get_surface_element_at(loc); if (surfaceElement == nullptr) { log_error("Could not find surface. x = %d, y = %d", loc.x, loc.y); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, _ErrorTitles[EnumValue(_setting)], STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, _ErrorTitles[EnumValue(_setting)], STR_NONE); } auto res = MakeResult(); @@ -147,7 +147,7 @@ private: if ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) != 0 || (surfaceElement->GetOwnership() & OWNERSHIP_AVAILABLE) == 0) { - return MakeResult(GA_ERROR::NOT_OWNED, _ErrorTitles[EnumValue(_setting)], STR_LAND_NOT_FOR_SALE); + return MakeResult(GameActions::Status::NotOwned, _ErrorTitles[EnumValue(_setting)], STR_LAND_NOT_FOR_SALE); } if (isExecuting) { @@ -167,7 +167,7 @@ private: || (surfaceElement->GetOwnership() & OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE) == 0) { return MakeResult( - GA_ERROR::NOT_OWNED, _ErrorTitles[EnumValue(_setting)], STR_CONSTRUCTION_RIGHTS_NOT_FOR_SALE); + GameActions::Status::NotOwned, _ErrorTitles[EnumValue(_setting)], STR_CONSTRUCTION_RIGHTS_NOT_FOR_SALE); } if (isExecuting) @@ -181,7 +181,7 @@ private: default: log_warning("Tried calling buy land rights with an incorrect setting. setting = %u", _setting); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, _ErrorTitles[0], STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, _ErrorTitles[0], STR_NONE); } } }; diff --git a/src/openrct2/actions/LandLowerAction.hpp b/src/openrct2/actions/LandLowerAction.hpp index b94e109c97..fbe53edbad 100644 --- a/src/openrct2/actions/LandLowerAction.hpp +++ b/src/openrct2/actions/LandLowerAction.hpp @@ -25,7 +25,7 @@ #include "../world/Surface.h" #include "GameAction.h" -DEFINE_GAME_ACTION(LandLowerAction, GAME_COMMAND_LOWER_LAND, GameActionResult) +DEFINE_GAME_ACTION(LandLowerAction, GAME_COMMAND_LOWER_LAND, GameActions::Result) { private: CoordsXY _coords; @@ -53,18 +53,18 @@ public: stream << DS_TAG(_coords) << DS_TAG(_range) << DS_TAG(_selectionType); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr QueryExecute(bool isExecuting) const + GameActions::Result::Ptr QueryExecute(bool isExecuting) const { auto res = MakeResult(); size_t tableRow = _selectionType; @@ -133,7 +133,7 @@ private: landSetHeightAction.SetFlags(GetFlags()); auto result = isExecuting ? GameActions::ExecuteNested(&landSetHeightAction) : GameActions::QueryNested(&landSetHeightAction); - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { res->Cost += result->Cost; } @@ -147,8 +147,8 @@ private: if (!withinOwnership) { - GameActionResult::Ptr ownerShipResult = std::make_unique( - GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK); + GameActions::Result::Ptr ownerShipResult = std::make_unique( + GameActions::Status::Disallowed, STR_LAND_NOT_OWNED_BY_PARK); ownerShipResult->ErrorTitle = STR_CANT_LOWER_LAND_HERE; return ownerShipResult; } diff --git a/src/openrct2/actions/LandRaiseAction.hpp b/src/openrct2/actions/LandRaiseAction.hpp index f7dec665c8..ebf293cd17 100644 --- a/src/openrct2/actions/LandRaiseAction.hpp +++ b/src/openrct2/actions/LandRaiseAction.hpp @@ -26,7 +26,7 @@ #include "../world/Surface.h" #include "GameAction.h" -DEFINE_GAME_ACTION(LandRaiseAction, GAME_COMMAND_RAISE_LAND, GameActionResult) +DEFINE_GAME_ACTION(LandRaiseAction, GAME_COMMAND_RAISE_LAND, GameActions::Result) { private: CoordsXY _coords; @@ -54,18 +54,18 @@ public: stream << DS_TAG(_coords) << DS_TAG(_range) << DS_TAG(_selectionType); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr QueryExecute(bool isExecuting) const + GameActions::Result::Ptr QueryExecute(bool isExecuting) const { auto res = MakeResult(); size_t tableRow = _selectionType; @@ -129,7 +129,7 @@ private: landSetHeightAction.SetFlags(GetFlags()); auto result = isExecuting ? GameActions::ExecuteNested(&landSetHeightAction) : GameActions::QueryNested(&landSetHeightAction); - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { res->Cost += result->Cost; } @@ -143,8 +143,8 @@ private: if (!withinOwnership) { - GameActionResult::Ptr ownerShipResult = std::make_unique( - GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK); + GameActions::Result::Ptr ownerShipResult = std::make_unique( + GameActions::Status::Disallowed, STR_LAND_NOT_OWNED_BY_PARK); ownerShipResult->ErrorTitle = STR_CANT_RAISE_LAND_HERE; return ownerShipResult; } diff --git a/src/openrct2/actions/LandSetHeightAction.hpp b/src/openrct2/actions/LandSetHeightAction.hpp index 6d2c1eb711..bee949649e 100644 --- a/src/openrct2/actions/LandSetHeightAction.hpp +++ b/src/openrct2/actions/LandSetHeightAction.hpp @@ -24,7 +24,7 @@ #include "../world/Surface.h" #include "GameAction.h" -DEFINE_GAME_ACTION(LandSetHeightAction, GAME_COMMAND_SET_LAND_HEIGHT, GameActionResult) +DEFINE_GAME_ACTION(LandSetHeightAction, GAME_COMMAND_SET_LAND_HEIGHT, GameActions::Result) { private: CoordsXY _coords; @@ -42,7 +42,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::EDITOR_ONLY; + return GameAction::GetActionFlags() | GameActions::Flags::EditorOnly; } void Serialise(DataSerialiser & stream) override @@ -52,24 +52,24 @@ public: stream << DS_TAG(_coords) << DS_TAG(_height) << DS_TAG(_style); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (gParkFlags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY); + return std::make_unique(GameActions::Status::Disallowed, STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY); } rct_string_id errorTitle = CheckParameters(); if (errorTitle != STR_NONE) { - return std::make_unique(GA_ERROR::DISALLOWED, errorTitle); + return std::make_unique(GameActions::Status::Disallowed, errorTitle); } if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) { if (!map_is_location_in_park(_coords)) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK); + return std::make_unique(GameActions::Status::Disallowed, STR_LAND_NOT_OWNED_BY_PARK); } } @@ -82,7 +82,7 @@ public: TileElement* tileElement = CheckTreeObstructions(); if (tileElement != nullptr) { - auto res = MakeResult(GA_ERROR::DISALLOWED, STR_NONE); + auto res = MakeResult(GameActions::Status::Disallowed, STR_NONE); map_obstruction_set_error_text(tileElement, *res); return res; } @@ -96,13 +96,13 @@ public: errorTitle = CheckRideSupports(); if (errorTitle != STR_NONE) { - return std::make_unique(GA_ERROR::DISALLOWED, errorTitle); + return std::make_unique(GameActions::Status::Disallowed, errorTitle); } } auto* surfaceElement = map_get_surface_element_at(_coords); if (surfaceElement == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); // We need to check if there is _currently_ a level crossing on the tile. // For that, we need the old height, so we can't use the _height variable. @@ -110,13 +110,13 @@ public: auto* pathElement = map_get_footpath_element(oldCoords); if (pathElement != nullptr && pathElement->AsPath()->IsLevelCrossing(oldCoords)) { - return MakeResult(GA_ERROR::DISALLOWED, STR_REMOVE_LEVEL_CROSSING_FIRST); + return MakeResult(GameActions::Status::Disallowed, STR_REMOVE_LEVEL_CROSSING_FIRST); } TileElement* tileElement = CheckFloatingStructures(reinterpret_cast(surfaceElement), _height); if (tileElement != nullptr) { - auto res = MakeResult(GA_ERROR::DISALLOWED, STR_NONE); + auto res = MakeResult(GameActions::Status::Disallowed, STR_NONE); map_obstruction_set_error_text(tileElement, *res); return res; } @@ -136,28 +136,28 @@ public: auto clearResult = MapCanConstructWithClearAt( { _coords, _height * COORDS_Z_STEP, zCorner * COORDS_Z_STEP }, &map_set_land_height_clear_func, { 0b1111, 0 }, 0, CREATE_CROSSING_MODE_NONE); - if (clearResult->Error != GA_ERROR::OK) + if (clearResult->Error != GameActions::Status::Ok) { - return std::make_unique( - GA_ERROR::DISALLOWED, STR_NONE, clearResult->ErrorMessage.GetStringId(), + return std::make_unique( + GameActions::Status::Disallowed, STR_NONE, clearResult->ErrorMessage.GetStringId(), clearResult->ErrorMessageArgs.data()); } tileElement = CheckUnremovableObstructions(reinterpret_cast(surfaceElement), zCorner); if (tileElement != nullptr) { - auto res = MakeResult(GA_ERROR::DISALLOWED, STR_NONE); + auto res = MakeResult(GameActions::Status::Disallowed, STR_NONE); map_obstruction_set_error_text(tileElement, *res); return res; } } - auto res = std::make_unique(); + auto res = std::make_unique(); res->Cost = sceneryRemovalCost + GetSurfaceHeightChangeCost(surfaceElement); res->Expenditure = ExpenditureType::Landscaping; return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { money32 cost = MONEY(0, 0); auto surfaceHeight = tile_element_height(_coords); @@ -172,12 +172,12 @@ public: auto* surfaceElement = map_get_surface_element_at(_coords); if (surfaceElement == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); cost += GetSurfaceHeightChangeCost(surfaceElement); SetSurfaceHeight(reinterpret_cast(surfaceElement)); - auto res = std::make_unique(); + auto res = std::make_unique(); res->Position = { _coords.x + 16, _coords.y + 16, surfaceHeight }; res->Cost = cost; res->Expenditure = ExpenditureType::Landscaping; diff --git a/src/openrct2/actions/LandSetRightsAction.hpp b/src/openrct2/actions/LandSetRightsAction.hpp index ae0639b978..1ffc5dfe40 100644 --- a/src/openrct2/actions/LandSetRightsAction.hpp +++ b/src/openrct2/actions/LandSetRightsAction.hpp @@ -36,7 +36,7 @@ enum class LandSetRightSetting : uint8_t Count }; -DEFINE_GAME_ACTION(LandSetRightsAction, GAME_COMMAND_SET_LAND_OWNERSHIP, GameActionResult) +DEFINE_GAME_ACTION(LandSetRightsAction, GAME_COMMAND_SET_LAND_OWNERSHIP, GameActions::Result) { private: MapRange _range; @@ -62,7 +62,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::EDITOR_ONLY; + return GameAction::GetActionFlags() | GameActions::Flags::EditorOnly; } void Serialise(DataSerialiser & stream) override @@ -72,18 +72,18 @@ public: stream << DS_TAG(_range) << DS_TAG(_setting) << DS_TAG(_ownership); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr QueryExecute(bool isExecuting) const + GameActions::Result::Ptr QueryExecute(bool isExecuting) const { auto res = MakeResult(); @@ -105,7 +105,7 @@ private: if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !gCheatsSandboxMode) { - return MakeResult(GA_ERROR::NOT_IN_EDITOR_MODE, STR_NONE, STR_LAND_NOT_FOR_SALE); + return MakeResult(GameActions::Status::NotInEditorMode, STR_NONE, STR_LAND_NOT_FOR_SALE); } // Game command modified to accept selection size @@ -116,7 +116,7 @@ private: if (!LocationValid({ x, y })) continue; auto result = map_buy_land_rights_for_tile({ x, y }, isExecuting); - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { res->Cost += result->Cost; } @@ -131,13 +131,13 @@ private: return res; } - GameActionResult::Ptr map_buy_land_rights_for_tile(const CoordsXY& loc, bool isExecuting) const + GameActions::Result::Ptr map_buy_land_rights_for_tile(const CoordsXY& loc, bool isExecuting) const { SurfaceElement* surfaceElement = map_get_surface_element_at(loc); if (surfaceElement == nullptr) { log_error("Could not find surface. x = %d, y = %d", loc.x, loc.y); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } auto res = MakeResult(); @@ -230,7 +230,7 @@ private: } default: log_warning("Tried calling set land rights with an incorrect setting. setting = %u", _setting); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE); } } }; diff --git a/src/openrct2/actions/LandSmoothAction.hpp b/src/openrct2/actions/LandSmoothAction.hpp index 17d3185d87..3a66ba046c 100644 --- a/src/openrct2/actions/LandSmoothAction.hpp +++ b/src/openrct2/actions/LandSmoothAction.hpp @@ -27,7 +27,7 @@ #include "../world/Surface.h" #include "GameAction.h" -DEFINE_GAME_ACTION(LandSmoothAction, GAME_COMMAND_EDIT_LAND_SMOOTH, GameActionResult) +DEFINE_GAME_ACTION(LandSmoothAction, GAME_COMMAND_EDIT_LAND_SMOOTH, GameActions::Result) { private: CoordsXY _coords; @@ -59,18 +59,18 @@ public: stream << DS_TAG(_coords) << DS_TAG(_range) << DS_TAG(_selectionType) << DS_TAG(_isLowering); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return SmoothLand(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return SmoothLand(true); } private: - GameActionResult::Ptr SmoothLandTile( + GameActions::Result::Ptr SmoothLandTile( int32_t direction, bool isExecuting, const CoordsXY& loc, SurfaceElement* surfaceElement) const { int32_t targetBaseZ = surfaceElement->base_height; @@ -238,7 +238,7 @@ private: landSetHeightAction.SetFlags(GetFlags()); auto res = isExecuting ? GameActions::ExecuteNested(&landSetHeightAction) : GameActions::QueryNested(&landSetHeightAction); - if (res->Error == GA_ERROR::OK) + if (res->Error == GameActions::Status::Ok) { totalCost += res->Cost; } @@ -326,7 +326,7 @@ private: expectedLandHeight += landChangePerTile; // change land of current tile auto result = SmoothLandTile(direction, isExecuting, nextLoc, surfaceElement); - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { totalCost += result->Cost; } @@ -334,7 +334,7 @@ private: return totalCost; } - GameActionResult::Ptr SmoothLand(bool isExecuting) const + GameActions::Result::Ptr SmoothLand(bool isExecuting) const { const bool raiseLand = !_isLowering; const int32_t selectionType = _selectionType; @@ -640,11 +640,11 @@ private: } default: log_error("Invalid map selection %u", _selectionType); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, res->ErrorTitle.GetStringId()); + return MakeResult(GameActions::Status::InvalidParameters, res->ErrorTitle.GetStringId()); } // switch selectionType // Raise / lower the land tool selection area - GameActionResult::Ptr result; + GameActions::Result::Ptr result; if (raiseLand) { auto raiseLandAction = LandRaiseAction({ _coords.x, _coords.y }, validRange, selectionType); @@ -657,7 +657,7 @@ private: lowerLandAction.SetFlags(GetFlags()); result = isExecuting ? GameActions::ExecuteNested(&lowerLandAction) : GameActions::QueryNested(&lowerLandAction); } - if (result->Error != GA_ERROR::OK) + if (result->Error != GameActions::Status::Ok) { return result; } diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.hpp b/src/openrct2/actions/LargeSceneryPlaceAction.hpp index 13b1391282..cb6b6f48cf 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.hpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.hpp @@ -20,23 +20,23 @@ #include "../world/Surface.h" #include "GameAction.h" -class LargeSceneryPlaceActionResult final : public GameActionResult +class LargeSceneryPlaceActionResult final : public GameActions::Result { public: LargeSceneryPlaceActionResult() - : GameActionResult(GA_ERROR::OK, STR_CANT_POSITION_THIS_HERE) + : GameActions::Result(GameActions::Status::Ok, STR_CANT_POSITION_THIS_HERE) { } - LargeSceneryPlaceActionResult(GA_ERROR error) - : GameActionResult(error, STR_CANT_POSITION_THIS_HERE) + LargeSceneryPlaceActionResult(GameActions::Status error) + : GameActions::Result(error, STR_CANT_POSITION_THIS_HERE) { } - LargeSceneryPlaceActionResult(GA_ERROR error, rct_string_id message) - : GameActionResult(error, STR_CANT_POSITION_THIS_HERE, message) + LargeSceneryPlaceActionResult(GameActions::Status error, rct_string_id message) + : GameActions::Result(error, STR_CANT_POSITION_THIS_HERE, message) { } - LargeSceneryPlaceActionResult(GA_ERROR error, rct_string_id message, uint8_t* args) - : GameActionResult(error, STR_CANT_POSITION_THIS_HERE, message, args) + LargeSceneryPlaceActionResult(GameActions::Status error, rct_string_id message, uint8_t* args) + : GameActions::Result(error, STR_CANT_POSITION_THIS_HERE, message, args) { } @@ -101,7 +101,7 @@ public: << DS_TAG(_bannerId); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto res = std::make_unique(); res->ErrorTitle = STR_CANT_POSITION_THIS_HERE; @@ -119,20 +119,20 @@ public: log_error( "Invalid game command for scenery placement, primaryColour = %u, secondaryColour = %u", _primaryColour, _secondaryColour); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } if (_sceneryType >= MAX_LARGE_SCENERY_OBJECTS) { log_error("Invalid game command for scenery placement, sceneryType = %u", _sceneryType); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } rct_scenery_entry* sceneryEntry = get_large_scenery_entry(_sceneryType); if (sceneryEntry == nullptr) { log_error("Invalid game command for scenery placement, sceneryType = %u", _sceneryType); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } uint32_t totalNumTiles = GetTotalNumTiles(sceneryEntry->large_scenery.tiles); @@ -150,21 +150,21 @@ public: if (_bannerId == BANNER_INDEX_NULL) { log_error("Banner Index not specified."); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_TOO_MANY_BANNERS_IN_GAME); + return MakeResult(GameActions::Status::InvalidParameters, STR_TOO_MANY_BANNERS_IN_GAME); } auto banner = GetBanner(_bannerId); if (!banner->IsNull()) { log_error("No free banners available"); - return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS); + return std::make_unique(GameActions::Status::NoFreeElements); } } if (!map_check_free_elements_and_reorganise(totalNumTiles)) { log_error("No free map elements available"); - return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS); + return std::make_unique(GameActions::Status::NoFreeElements); } uint8_t tileNum = 0; @@ -184,7 +184,7 @@ public: CREATE_CROSSING_MODE_NONE)) { return std::make_unique( - GA_ERROR::NO_CLEARANCE, gGameCommandErrorText, gCommonFormatArgs); + GameActions::Status::NoClearance, gGameCommandErrorText, gCommonFormatArgs); } int32_t tempSceneryGroundFlags = gMapGroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); @@ -193,12 +193,12 @@ public: if ((gMapGroundFlags & ELEMENT_IS_UNDERWATER) || (gMapGroundFlags & ELEMENT_IS_UNDERGROUND)) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_CANT_BUILD_THIS_UNDERWATER); + GameActions::Status::Disallowed, STR_CANT_BUILD_THIS_UNDERWATER); } if (res->GroundFlags && !(res->GroundFlags & tempSceneryGroundFlags)) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND); + GameActions::Status::Disallowed, STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND); } } @@ -206,13 +206,14 @@ public: if (!LocationValid(curTile) || curTile.x >= gMapSizeUnits || curTile.y >= gMapSizeUnits) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_OFF_EDGE_OF_MAP); + return std::make_unique(GameActions::Status::Disallowed, STR_OFF_EDGE_OF_MAP); } if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_owned({ curTile, zLow }) && !gCheatsSandboxMode) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK); + return std::make_unique( + GameActions::Status::Disallowed, STR_LAND_NOT_OWNED_BY_PARK); } } @@ -223,7 +224,7 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto res = std::make_unique(); res->ErrorTitle = STR_CANT_POSITION_THIS_HERE; @@ -241,13 +242,13 @@ public: if (sceneryEntry == nullptr) { log_error("Invalid game command for scenery placement, sceneryType = %u", _sceneryType); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } if (sceneryEntry->large_scenery.tiles == nullptr) { log_error("Invalid large scenery object, sceneryType = %u", _sceneryType); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } uint32_t totalNumTiles = GetTotalNumTiles(sceneryEntry->large_scenery.tiles); @@ -263,7 +264,7 @@ public: if (!map_check_free_elements_and_reorganise(totalNumTiles)) { log_error("No free map elements available"); - return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS); + return std::make_unique(GameActions::Status::NoFreeElements); } uint8_t tileNum = 0; @@ -283,7 +284,7 @@ public: CREATE_CROSSING_MODE_NONE)) { return std::make_unique( - GA_ERROR::NO_CLEARANCE, gGameCommandErrorText, gCommonFormatArgs); + GameActions::Status::NoClearance, gGameCommandErrorText, gCommonFormatArgs); } res->GroundFlags = gMapGroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); @@ -320,14 +321,14 @@ public: if (_bannerId == BANNER_INDEX_NULL) { log_error("No free banners available"); - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_TOO_MANY_BANNERS_IN_GAME); + return MakeResult(GameActions::Status::NoFreeElements, STR_TOO_MANY_BANNERS_IN_GAME); } auto banner = GetBanner(_bannerId); if (!banner->IsNull()) { log_error("No free banners available"); - return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS); + return std::make_unique(GameActions::Status::NoFreeElements); } banner->text = {}; diff --git a/src/openrct2/actions/LargeSceneryRemoveAction.hpp b/src/openrct2/actions/LargeSceneryRemoveAction.hpp index a3daa0b930..d29e81b479 100644 --- a/src/openrct2/actions/LargeSceneryRemoveAction.hpp +++ b/src/openrct2/actions/LargeSceneryRemoveAction.hpp @@ -23,7 +23,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(LargeSceneryRemoveAction, GAME_COMMAND_REMOVE_LARGE_SCENERY, GameActionResult) +DEFINE_GAME_ACTION(LargeSceneryRemoveAction, GAME_COMMAND_REMOVE_LARGE_SCENERY, GameActions::Result) { private: CoordsXYZD _loc; @@ -56,9 +56,9 @@ public: stream << DS_TAG(_loc) << DS_TAG(_tileIndex); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); const uint32_t flags = GetFlags(); @@ -73,7 +73,7 @@ public: if (tileElement == nullptr) { log_warning("Invalid game command for scenery removal, x = %d, y = %d", _loc.x, _loc.y); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_SELECTION_OF_OBJECTS); + return MakeResult(GameActions::Status::InvalidParameters, STR_INVALID_SELECTION_OF_OBJECTS); } rct_scenery_entry* scenery_entry = tileElement->AsLargeScenery()->GetEntry(); @@ -99,13 +99,13 @@ public: { if (!map_is_location_owned({ currentTile.x, currentTile.y, currentTile.z })) { - return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NoClearance, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } } if (!LocationValid(currentTile)) { - return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NoClearance, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } // Prevent duplicate costs when using the clear scenery tool that overlaps multiple large // scenery tile elements. @@ -125,9 +125,9 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); const uint32_t flags = GetFlags(); @@ -142,7 +142,7 @@ public: if (tileElement == nullptr) { log_warning("Invalid game command for scenery removal, x = %d, y = %d", _loc.x, _loc.y); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_SELECTION_OF_OBJECTS); + return MakeResult(GameActions::Status::InvalidParameters, STR_INVALID_SELECTION_OF_OBJECTS); } tile_element_remove_banner_entry(tileElement); @@ -169,7 +169,7 @@ public: { if (!map_is_location_owned({ currentTile.x, currentTile.y, currentTile.z })) { - return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NoClearance, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } } diff --git a/src/openrct2/actions/LargeScenerySetColourAction.hpp b/src/openrct2/actions/LargeScenerySetColourAction.hpp index 1fc800228c..1bfdb9c472 100644 --- a/src/openrct2/actions/LargeScenerySetColourAction.hpp +++ b/src/openrct2/actions/LargeScenerySetColourAction.hpp @@ -14,7 +14,7 @@ #include "../world/Scenery.h" #include "GameAction.h" -DEFINE_GAME_ACTION(LargeScenerySetColourAction, GAME_COMMAND_SET_LARGE_SCENERY_COLOUR, GameActionResult) +DEFINE_GAME_ACTION(LargeScenerySetColourAction, GAME_COMMAND_SET_LARGE_SCENERY_COLOUR, GameActions::Result) { private: CoordsXYZD _loc; @@ -35,7 +35,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -45,18 +45,18 @@ public: stream << DS_TAG(_loc) << DS_TAG(_tileIndex) << DS_TAG(_primaryColour) << DS_TAG(_secondaryColour); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr QueryExecute(bool isExecuting) const + GameActions::Result::Ptr QueryExecute(bool isExecuting) const { auto res = MakeResult(); res->Expenditure = ExpenditureType::Landscaping; @@ -68,19 +68,19 @@ private: if (_loc.x < 0 || _loc.y < 0 || _loc.x > gMapSizeMaxXY || _loc.y > gMapSizeMaxXY) { log_error("Invalid x / y coordinates: x = %d, y = %d", _loc.x, _loc.y); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } if (_primaryColour > 31) { log_error("Invalid primary colour: colour = %u", _primaryColour); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } if (_secondaryColour > 31) { log_error("Invalid primary colour: colour = %u", _secondaryColour); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } auto largeElement = map_get_large_scenery_segment(_loc, _tileIndex); @@ -90,7 +90,7 @@ private: log_error( "Could not find large scenery at: x = %d, y = %d, z = %d, direction = %d, tileIndex = %u", _loc.x, _loc.y, _loc.z, _loc.direction, _tileIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && !(largeElement->IsGhost())) @@ -103,7 +103,7 @@ private: if (sceneryEntry == nullptr) { log_error("Could not find scenery object. type = %u", largeElement->GetEntryIndex()); - return MakeResult(GA_ERROR::UNKNOWN, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::Unknown, STR_CANT_REPAINT_THIS); } // Work out the base tile coordinates (Tile with index 0) auto rotatedBaseCoordsOffset = CoordsXYZ{ CoordsXY{ sceneryEntry->large_scenery.tiles[_tileIndex].x_offset, @@ -125,13 +125,13 @@ private: { if (!map_is_location_owned(currentTile)) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NotOwned, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); } } if (!LocationValid(currentTile)) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NotOwned, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); } auto tileElement = map_get_large_scenery_segment({ currentTile.x, currentTile.y, _loc.z, _loc.direction }, i); @@ -141,7 +141,7 @@ private: log_error( "Large scenery element not found at: x = %d, y = %d, z = %d, direction = %d", _loc.x, _loc.y, _loc.z, _loc.direction); - return MakeResult(GA_ERROR::UNKNOWN, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::Unknown, STR_CANT_REPAINT_THIS); } if (isExecuting) { diff --git a/src/openrct2/actions/LoadOrQuitAction.hpp b/src/openrct2/actions/LoadOrQuitAction.hpp index 28322ed9f4..effe1b8fd1 100644 --- a/src/openrct2/actions/LoadOrQuitAction.hpp +++ b/src/openrct2/actions/LoadOrQuitAction.hpp @@ -19,7 +19,7 @@ enum class LoadOrQuitModes : uint8_t CloseSavePrompt }; -DEFINE_GAME_ACTION(LoadOrQuitAction, GAME_COMMAND_LOAD_OR_QUIT, GameActionResult) +DEFINE_GAME_ACTION(LoadOrQuitAction, GAME_COMMAND_LOAD_OR_QUIT, GameActions::Result) { private: LoadOrQuitModes _mode{}; @@ -35,7 +35,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::CLIENT_ONLY | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::ClientOnly | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -45,12 +45,12 @@ public: stream << DS_TAG(_mode) << DS_TAG(_savePromptMode); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto mode = static_cast(_mode); switch (mode) @@ -66,6 +66,6 @@ public: game_load_or_quit_no_save_prompt(); break; } - return std::make_unique(); + return std::make_unique(); } }; diff --git a/src/openrct2/actions/MazePlaceTrackAction.hpp b/src/openrct2/actions/MazePlaceTrackAction.hpp index 6fd7095299..ade7d3761c 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.hpp +++ b/src/openrct2/actions/MazePlaceTrackAction.hpp @@ -13,7 +13,7 @@ #include "../ride/TrackData.h" #include "GameAction.h" -DEFINE_GAME_ACTION(MazePlaceTrackAction, GAME_COMMAND_PLACE_MAZE_DESIGN, GameActionResult) +DEFINE_GAME_ACTION(MazePlaceTrackAction, GAME_COMMAND_PLACE_MAZE_DESIGN, GameActions::Result) { private: CoordsXYZ _loc; @@ -43,29 +43,29 @@ public: stream << DS_TAG(_loc) << DS_TAG(_rideIndex) << DS_TAG(_mazeEntry); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { - auto res = std::make_unique(); + auto res = std::make_unique(); res->Position = _loc + CoordsXYZ{ 8, 8, 0 }; res->Expenditure = ExpenditureType::RideConstruction; res->ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; if (!map_check_free_elements_and_reorganise(1)) { - res->Error = GA_ERROR::NO_FREE_ELEMENTS; + res->Error = GameActions::Status::NoFreeElements; res->ErrorMessage = STR_TILE_ELEMENT_LIMIT_REACHED; return res; } if ((_loc.z & 0xF) != 0) { - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = STR_CONSTRUCTION_ERR_UNKNOWN; return res; } if (!LocationValid(_loc) || (!map_is_location_owned(_loc) && !gCheatsSandboxMode)) { - res->Error = GA_ERROR::NOT_OWNED; + res->Error = GameActions::Status::NotOwned; res->ErrorMessage = STR_LAND_NOT_OWNED_BY_PARK; return res; } @@ -73,7 +73,7 @@ public: auto surfaceElement = map_get_surface_element_at(_loc); if (surfaceElement == nullptr) { - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS; return res; } @@ -88,7 +88,7 @@ public: if (heightDifference > RideTypeDescriptors[RIDE_TYPE_MAZE].Heights.MaxHeight) { - res->Error = GA_ERROR::TOO_HIGH; + res->Error = GameActions::Status::TooHigh; res->ErrorMessage = STR_TOO_HIGH_FOR_SUPPORTS; return res; } @@ -100,19 +100,20 @@ public: { _loc.ToTileStart(), baseHeight, clearanceHeight }, &map_place_non_scenery_clear_func, { 0b1111, 0 }, GetFlags(), &clearCost, CREATE_CROSSING_MODE_NONE)) { - return MakeResult(GA_ERROR::NO_CLEARANCE, res->ErrorTitle.GetStringId(), gGameCommandErrorText, gCommonFormatArgs); + return MakeResult( + GameActions::Status::NoClearance, res->ErrorTitle.GetStringId(), gGameCommandErrorText, gCommonFormatArgs); } if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { - res->Error = GA_ERROR::NO_CLEARANCE; + res->Error = GameActions::Status::NoClearance; res->ErrorMessage = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; return res; } if (gMapGroundFlags & ELEMENT_IS_UNDERGROUND) { - res->Error = GA_ERROR::NO_CLEARANCE; + res->Error = GameActions::Status::NoClearance; res->ErrorMessage = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; return res; } @@ -120,7 +121,7 @@ public: auto ride = get_ride(_rideIndex); if (ride == nullptr || ride->type == RIDE_TYPE_NULL) { - res->Error = GA_ERROR::INVALID_PARAMETERS; + res->Error = GameActions::Status::InvalidParameters; res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS; return res; } @@ -131,9 +132,9 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - auto res = std::make_unique(); + auto res = std::make_unique(); res->Position = _loc + CoordsXYZ{ 8, 8, 0 }; res->Expenditure = ExpenditureType::RideConstruction; @@ -142,14 +143,14 @@ public: auto ride = get_ride(_rideIndex); if (ride == nullptr) { - res->Error = GA_ERROR::INVALID_PARAMETERS; + res->Error = GameActions::Status::InvalidParameters; res->ErrorMessage = STR_NONE; return res; } if (!map_check_free_elements_and_reorganise(1)) { - res->Error = GA_ERROR::NO_FREE_ELEMENTS; + res->Error = GameActions::Status::NoFreeElements; res->ErrorMessage = STR_NONE; return res; } @@ -169,7 +170,8 @@ public: { _loc.ToTileStart(), baseHeight, clearanceHeight }, &map_place_non_scenery_clear_func, { 0b1111, 0 }, GetFlags() | GAME_COMMAND_FLAG_APPLY, &clearCost, CREATE_CROSSING_MODE_NONE)) { - return MakeResult(GA_ERROR::NO_CLEARANCE, res->ErrorTitle.GetStringId(), gGameCommandErrorText, gCommonFormatArgs); + return MakeResult( + GameActions::Status::NoClearance, res->ErrorTitle.GetStringId(), gGameCommandErrorText, gCommonFormatArgs); } money32 price = (((RideTypeDescriptors[ride->type].BuildCosts.TrackPrice * TrackPricing[TrackElemType::Maze]) >> 16)); diff --git a/src/openrct2/actions/MazeSetTrackAction.hpp b/src/openrct2/actions/MazeSetTrackAction.hpp index cf5541240c..87076c3f0d 100644 --- a/src/openrct2/actions/MazeSetTrackAction.hpp +++ b/src/openrct2/actions/MazeSetTrackAction.hpp @@ -47,7 +47,7 @@ static constexpr const uint8_t byte_993D0C[] = { }; // clang-format on -DEFINE_GAME_ACTION(MazeSetTrackAction, GAME_COMMAND_SET_MAZE_TRACK, GameActionResult) +DEFINE_GAME_ACTION(MazeSetTrackAction, GAME_COMMAND_SET_MAZE_TRACK, GameActions::Result) { private: CoordsXYZD _loc; @@ -79,29 +79,29 @@ public: stream << DS_TAG(_loc) << DS_TAG(_loc.direction) << DS_TAG(_initialPlacement) << DS_TAG(_rideIndex) << DS_TAG(_mode); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { - auto res = std::make_unique(); + auto res = std::make_unique(); res->Position = _loc + CoordsXYZ{ 8, 8, 0 }; res->Expenditure = ExpenditureType::RideConstruction; res->ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; if (!map_check_free_elements_and_reorganise(1)) { - res->Error = GA_ERROR::NO_FREE_ELEMENTS; + res->Error = GameActions::Status::NoFreeElements; res->ErrorMessage = STR_TILE_ELEMENT_LIMIT_REACHED; return res; } if ((_loc.z & 0xF) != 0 && _mode == GC_SET_MAZE_TRACK_BUILD) { - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = STR_CONSTRUCTION_ERR_UNKNOWN; return res; } if (!LocationValid(_loc) || (!map_is_location_owned(_loc) && !gCheatsSandboxMode)) { - res->Error = GA_ERROR::NOT_OWNED; + res->Error = GameActions::Status::NotOwned; res->ErrorMessage = STR_LAND_NOT_OWNED_BY_PARK; return res; } @@ -109,7 +109,7 @@ public: auto surfaceElement = map_get_surface_element_at(_loc); if (surfaceElement == nullptr) { - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS; return res; } @@ -124,7 +124,7 @@ public: if (heightDifference > RideTypeDescriptors[RIDE_TYPE_MAZE].Heights.MaxHeight) { - res->Error = GA_ERROR::TOO_HIGH; + res->Error = GameActions::Status::TooHigh; res->ErrorMessage = STR_TOO_HIGH_FOR_SUPPORTS; return res; } @@ -135,28 +135,28 @@ public: { if (_mode != GC_SET_MAZE_TRACK_BUILD) { - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS; return res; } auto constructResult = MapCanConstructAt({ _loc.ToTileStart(), baseHeight, clearanceHeight }, { 0b1111, 0 }); - if (constructResult->Error != GA_ERROR::OK) + if (constructResult->Error != GameActions::Status::Ok) { return MakeResult( - GA_ERROR::NO_CLEARANCE, res->ErrorTitle.GetStringId(), constructResult->ErrorMessage.GetStringId(), - constructResult->ErrorMessageArgs.data()); + GameActions::Status::NoClearance, res->ErrorTitle.GetStringId(), + constructResult->ErrorMessage.GetStringId(), constructResult->ErrorMessageArgs.data()); } if (constructResult->GroundFlags & ELEMENT_IS_UNDERWATER) { - res->Error = GA_ERROR::NO_CLEARANCE; + res->Error = GameActions::Status::NoClearance; res->ErrorMessage = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; return res; } if (constructResult->GroundFlags & ELEMENT_IS_UNDERGROUND) { - res->Error = GA_ERROR::NO_CLEARANCE; + res->Error = GameActions::Status::NoClearance; res->ErrorMessage = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; return res; } @@ -164,7 +164,7 @@ public: auto ride = get_ride(_rideIndex); if (ride == nullptr || ride->type == RIDE_CRASH_TYPE_NONE) { - res->Error = GA_ERROR::NO_CLEARANCE; + res->Error = GameActions::Status::NoClearance; res->ErrorMessage = STR_INVALID_SELECTION_OF_OBJECTS; return res; } @@ -176,12 +176,12 @@ public: return res; } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - auto res = std::make_unique(); + auto res = std::make_unique(); res->Position = _loc + CoordsXYZ{ 8, 8, 0 }; res->Expenditure = ExpenditureType::RideConstruction; @@ -190,14 +190,14 @@ public: auto ride = get_ride(_rideIndex); if (ride == nullptr) { - res->Error = GA_ERROR::INVALID_PARAMETERS; + res->Error = GameActions::Status::InvalidParameters; res->ErrorMessage = STR_NONE; return res; } if (!map_check_free_elements_and_reorganise(1)) { - res->Error = GA_ERROR::NO_FREE_ELEMENTS; + res->Error = GameActions::Status::NoFreeElements; res->ErrorMessage = STR_NONE; return res; } @@ -296,7 +296,7 @@ public: if (tileElement == nullptr) { log_error("No surface found"); - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = STR_NONE; return res; } diff --git a/src/openrct2/actions/NetworkModifyGroupAction.hpp b/src/openrct2/actions/NetworkModifyGroupAction.hpp index 81e81c96dd..b11bff56de 100644 --- a/src/openrct2/actions/NetworkModifyGroupAction.hpp +++ b/src/openrct2/actions/NetworkModifyGroupAction.hpp @@ -31,7 +31,7 @@ enum class PermissionState : uint8_t Count }; -DEFINE_GAME_ACTION(NetworkModifyGroupAction, GAME_COMMAND_MODIFY_GROUPS, GameActionResult) +DEFINE_GAME_ACTION(NetworkModifyGroupAction, GAME_COMMAND_MODIFY_GROUPS, GameActions::Result) { private: ModifyGroupType _type{ ModifyGroupType::Count }; @@ -56,7 +56,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -66,12 +66,12 @@ public: stream << DS_TAG(_type) << DS_TAG(_groupId) << DS_TAG(_name) << DS_TAG(_permissionIndex) << DS_TAG(_permissionState); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return network_modify_groups(GetPlayer(), _type, _groupId, _name, _permissionIndex, _permissionState, false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return network_modify_groups(GetPlayer(), _type, _groupId, _name, _permissionIndex, _permissionState, true); } diff --git a/src/openrct2/actions/ParkEntranceRemoveAction.hpp b/src/openrct2/actions/ParkEntranceRemoveAction.hpp index 301656ae31..04e61d332a 100644 --- a/src/openrct2/actions/ParkEntranceRemoveAction.hpp +++ b/src/openrct2/actions/ParkEntranceRemoveAction.hpp @@ -15,7 +15,7 @@ #include "../world/Park.h" #include "GameAction.h" -DEFINE_GAME_ACTION(ParkEntranceRemoveAction, GAME_COMMAND_REMOVE_PARK_ENTRANCE, GameActionResult) +DEFINE_GAME_ACTION(ParkEntranceRemoveAction, GAME_COMMAND_REMOVE_PARK_ENTRANCE, GameActions::Result) { private: CoordsXYZ _loc; @@ -30,7 +30,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::EDITOR_ONLY; + return GameAction::GetActionFlags() | GameActions::Flags::EditorOnly; } void Serialise(DataSerialiser & stream) override @@ -40,11 +40,11 @@ public: stream << DS_TAG(_loc); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !gCheatsSandboxMode) { - return MakeResult(GA_ERROR::NOT_IN_EDITOR_MODE, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::NotInEditorMode, STR_CANT_REMOVE_THIS); } auto res = MakeResult(); @@ -56,12 +56,12 @@ public: if (!LocationValid(_loc) || entranceIndex == -1) { log_error("Could not find entrance at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS); } return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto res = MakeResult(); res->Expenditure = ExpenditureType::LandPurchase; @@ -72,7 +72,7 @@ public: if (entranceIndex == -1) { log_error("Could not find entrance at x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS); } auto direction = (gParkEntrances[entranceIndex].direction - 1) & 3; diff --git a/src/openrct2/actions/ParkMarketingAction.hpp b/src/openrct2/actions/ParkMarketingAction.hpp index e0e41b2e23..62715adf3b 100644 --- a/src/openrct2/actions/ParkMarketingAction.hpp +++ b/src/openrct2/actions/ParkMarketingAction.hpp @@ -22,7 +22,7 @@ #include -DEFINE_GAME_ACTION(ParkMarketingAction, GAME_COMMAND_START_MARKETING_CAMPAIGN, GameActionResult) +DEFINE_GAME_ACTION(ParkMarketingAction, GAME_COMMAND_START_MARKETING_CAMPAIGN, GameActions::Result) { private: int32_t _type{}; @@ -40,7 +40,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -49,22 +49,23 @@ public: stream << DS_TAG(_type) << DS_TAG(_item) << DS_TAG(_numWeeks); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (static_cast(_type) >= std::size(AdvertisingCampaignPricePerWeek) || _numWeeks >= 256) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_START_MARKETING_CAMPAIGN); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_START_MARKETING_CAMPAIGN); } if (gParkFlags & PARK_FLAGS_FORBID_MARKETING_CAMPAIGN) { return MakeResult( - GA_ERROR::DISALLOWED, STR_CANT_START_MARKETING_CAMPAIGN, STR_MARKETING_CAMPAIGNS_FORBIDDEN_BY_LOCAL_AUTHORITY); + GameActions::Status::Disallowed, STR_CANT_START_MARKETING_CAMPAIGN, + STR_MARKETING_CAMPAIGNS_FORBIDDEN_BY_LOCAL_AUTHORITY); } return CreateResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { MarketingCampaign campaign{}; campaign.Type = _type; @@ -88,7 +89,7 @@ public: } private: - GameActionResult::Ptr CreateResult() const + GameActions::Result::Ptr CreateResult() const { auto result = MakeResult(); result->ErrorTitle = STR_CANT_START_MARKETING_CAMPAIGN; diff --git a/src/openrct2/actions/ParkSetDateAction.hpp b/src/openrct2/actions/ParkSetDateAction.hpp index ce26bbebfe..dbb6d44b2a 100644 --- a/src/openrct2/actions/ParkSetDateAction.hpp +++ b/src/openrct2/actions/ParkSetDateAction.hpp @@ -18,7 +18,7 @@ #include "../windows/Intent.h" #include "GameAction.h" -DEFINE_GAME_ACTION(ParkSetDateAction, GAME_COMMAND_SET_DATE, GameActionResult) +DEFINE_GAME_ACTION(ParkSetDateAction, GAME_COMMAND_SET_DATE, GameActions::Result) { private: int32_t _year{}; @@ -36,7 +36,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -45,17 +45,17 @@ public: stream << DS_TAG(_year) << DS_TAG(_month) << DS_TAG(_day); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_year <= 0 || _year > MAX_YEAR || _month <= 0 || _month > MONTH_COUNT || _day <= 0 || _day > 31) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { date_set(_year, _month, _day); return MakeResult(); diff --git a/src/openrct2/actions/ParkSetLoanAction.hpp b/src/openrct2/actions/ParkSetLoanAction.hpp index 55a45c5563..61616daceb 100644 --- a/src/openrct2/actions/ParkSetLoanAction.hpp +++ b/src/openrct2/actions/ParkSetLoanAction.hpp @@ -18,7 +18,7 @@ #include "../windows/Intent.h" #include "GameAction.h" -DEFINE_GAME_ACTION(ParkSetLoanAction, GAME_COMMAND_SET_CURRENT_LOAN, GameActionResult) +DEFINE_GAME_ACTION(ParkSetLoanAction, GAME_COMMAND_SET_CURRENT_LOAN, GameActions::Result) { private: money32 _value{ MONEY32_UNDEFINED }; @@ -32,7 +32,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -41,7 +41,7 @@ public: stream << DS_TAG(_value); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto currentLoan = gBankLoan; auto loanDifference = currentLoan - _value; @@ -49,20 +49,22 @@ public: { if (_value > gMaxBankLoan) { - return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_BORROW_ANY_MORE_MONEY, STR_BANK_REFUSES_TO_INCREASE_LOAN); + return MakeResult( + GameActions::Status::Disallowed, STR_CANT_BORROW_ANY_MORE_MONEY, STR_BANK_REFUSES_TO_INCREASE_LOAN); } } else { if (loanDifference > gCash) { - return MakeResult(GA_ERROR::INSUFFICIENT_FUNDS, STR_CANT_PAY_BACK_LOAN, STR_NOT_ENOUGH_CASH_AVAILABLE); + return MakeResult( + GameActions::Status::InsufficientFunds, STR_CANT_PAY_BACK_LOAN, STR_NOT_ENOUGH_CASH_AVAILABLE); } } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { gCash -= (gBankLoan - _value); gBankLoan = _value; diff --git a/src/openrct2/actions/ParkSetNameAction.hpp b/src/openrct2/actions/ParkSetNameAction.hpp index c250794d29..a36dbff702 100644 --- a/src/openrct2/actions/ParkSetNameAction.hpp +++ b/src/openrct2/actions/ParkSetNameAction.hpp @@ -23,7 +23,7 @@ #include "../world/Park.h" #include "GameAction.h" -DEFINE_GAME_ACTION(ParkSetNameAction, GAME_COMMAND_SET_PARK_NAME, GameActionResult) +DEFINE_GAME_ACTION(ParkSetNameAction, GAME_COMMAND_SET_PARK_NAME, GameActions::Result) { private: std::string _name; @@ -42,7 +42,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -51,16 +51,16 @@ public: stream << DS_TAG(_name); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_name.empty()) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_RENAME_PARK, STR_INVALID_NAME_FOR_PARK); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_RENAME_PARK, STR_INVALID_NAME_FOR_PARK); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { // Do a no-op if new name is the same as the current name is the same auto& park = OpenRCT2::GetContext()->GetGameState()->GetPark(); diff --git a/src/openrct2/actions/ParkSetParameterAction.hpp b/src/openrct2/actions/ParkSetParameterAction.hpp index f4c0a393c8..2765668fad 100644 --- a/src/openrct2/actions/ParkSetParameterAction.hpp +++ b/src/openrct2/actions/ParkSetParameterAction.hpp @@ -23,7 +23,7 @@ enum class ParkParameter : uint8_t Count }; -DEFINE_GAME_ACTION(ParkSetParameterAction, GAME_COMMAND_SET_PARK_OPEN, GameActionResult) +DEFINE_GAME_ACTION(ParkSetParameterAction, GAME_COMMAND_SET_PARK_OPEN, GameActions::Result) { private: ParkParameter _parameter{ ParkParameter::Count }; @@ -41,7 +41,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -50,11 +50,11 @@ public: stream << DS_TAG(_parameter) << DS_TAG(_value); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_parameter >= ParkParameter::Count) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } auto res = MakeResult(); @@ -62,7 +62,7 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { switch (_parameter) { @@ -85,7 +85,7 @@ public: window_invalidate_by_class(WC_RIDE); break; default: - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); break; } diff --git a/src/openrct2/actions/ParkSetResearchFundingAction.hpp b/src/openrct2/actions/ParkSetResearchFundingAction.hpp index 0654867585..711fe3762e 100644 --- a/src/openrct2/actions/ParkSetResearchFundingAction.hpp +++ b/src/openrct2/actions/ParkSetResearchFundingAction.hpp @@ -18,7 +18,7 @@ #include "../windows/Intent.h" #include "GameAction.h" -DEFINE_GAME_ACTION(ParkSetResearchFundingAction, GAME_COMMAND_SET_RESEARCH_FUNDING, GameActionResult) +DEFINE_GAME_ACTION(ParkSetResearchFundingAction, GAME_COMMAND_SET_RESEARCH_FUNDING, GameActions::Result) { private: // TODO change to std::optional when C++17 @@ -35,7 +35,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -44,16 +44,16 @@ public: stream << DS_TAG(_priorities) << DS_TAG(_fundingAmount); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_fundingAmount >= RESEARCH_FUNDING_COUNT) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { gResearchPriorities = _priorities; gResearchFundingLevel = _fundingAmount; diff --git a/src/openrct2/actions/PauseToggleAction.hpp b/src/openrct2/actions/PauseToggleAction.hpp index 45bfdaa6f8..b25daa5705 100644 --- a/src/openrct2/actions/PauseToggleAction.hpp +++ b/src/openrct2/actions/PauseToggleAction.hpp @@ -13,25 +13,25 @@ // Clang format is broken for small game actions // clang-format off -DEFINE_GAME_ACTION(PauseToggleAction, GAME_COMMAND_TOGGLE_PAUSE, GameActionResult) +DEFINE_GAME_ACTION(PauseToggleAction, GAME_COMMAND_TOGGLE_PAUSE, GameActions::Result) { public: PauseToggleAction() = default; uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { pause_toggle(); - return std::make_unique(); + return std::make_unique(); } }; // clang-format on diff --git a/src/openrct2/actions/PeepPickupAction.hpp b/src/openrct2/actions/PeepPickupAction.hpp index caf3796348..b35a4eb7cc 100644 --- a/src/openrct2/actions/PeepPickupAction.hpp +++ b/src/openrct2/actions/PeepPickupAction.hpp @@ -23,7 +23,7 @@ enum class PeepPickupType : uint8_t Count }; -DEFINE_GAME_ACTION(PeepPickupAction, GAME_COMMAND_PICKUP_GUEST, GameActionResult) +DEFINE_GAME_ACTION(PeepPickupAction, GAME_COMMAND_PICKUP_GUEST, GameActions::Result) { private: PeepPickupType _type{ PeepPickupType::Count }; @@ -43,7 +43,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -53,24 +53,24 @@ public: stream << DS_TAG(_type) << DS_TAG(_spriteId) << DS_TAG(_loc) << DS_TAG(_owner); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_spriteId >= MAX_SPRITES || _spriteId == SPRITE_INDEX_NULL) { log_error("Failed to pick up peep for sprite %d", _spriteId); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PERSON_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PERSON_HERE); } if (!_loc.isNull() && !LocationValid(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PERSON_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PERSON_HERE); } auto* const peep = TryGetEntity(_spriteId); if (!peep || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP) { log_error("Failed to pick up peep for sprite %d", _spriteId); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PERSON_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PERSON_HERE); } auto res = MakeResult(); @@ -82,7 +82,7 @@ public: res->Position = { peep->x, peep->y, peep->z }; if (!peep_can_be_picked_up(peep)) { - return MakeResult(GA_ERROR::DISALLOWED, STR_ERR_CANT_PLACE_PERSON_HERE); + return MakeResult(GameActions::Status::Disallowed, STR_ERR_CANT_PLACE_PERSON_HERE); } Peep* existing = network_get_pickup_peep(_owner); if (existing) @@ -107,29 +107,29 @@ public: res->Position = _loc; if (network_get_pickup_peep(_owner) != peep) { - return MakeResult(GA_ERROR::UNKNOWN, STR_ERR_CANT_PLACE_PERSON_HERE); + return MakeResult(GameActions::Status::Unknown, STR_ERR_CANT_PLACE_PERSON_HERE); } - if (auto res2 = peep->Place(TileCoordsXYZ(_loc), false); res2->Error != GA_ERROR::OK) + if (auto res2 = peep->Place(TileCoordsXYZ(_loc), false); res2->Error != GameActions::Status::Ok) { return res2; } break; default: log_error("Invalid pickup type: %u", _type); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PERSON_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PERSON_HERE); break; } return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { Peep* const peep = TryGetEntity(_spriteId); if (!peep || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP) { log_error("Failed to pick up peep for sprite %d", _spriteId); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PERSON_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PERSON_HERE); } auto res = MakeResult(); @@ -180,7 +180,7 @@ public: break; case PeepPickupType::Place: res->Position = _loc; - if (auto res2 = peep->Place(TileCoordsXYZ(_loc), true); res2->Error != GA_ERROR::OK) + if (auto res2 = peep->Place(TileCoordsXYZ(_loc), true); res2->Error != GameActions::Status::Ok) { return res2; } @@ -188,7 +188,7 @@ public: break; default: log_error("Invalid pickup type: %u", _type); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PERSON_HERE); + return MakeResult(GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PERSON_HERE); break; } return res; diff --git a/src/openrct2/actions/PlaceParkEntranceAction.hpp b/src/openrct2/actions/PlaceParkEntranceAction.hpp index 36c3dd1f94..1960a50fc2 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.hpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.hpp @@ -22,7 +22,7 @@ #include "../world/Surface.h" #include "GameAction.h" -DEFINE_GAME_ACTION(PlaceParkEntranceAction, GAME_COMMAND_PLACE_PARK_ENTRANCE, GameActionResult) +DEFINE_GAME_ACTION(PlaceParkEntranceAction, GAME_COMMAND_PLACE_PARK_ENTRANCE, GameActions::Result) { private: CoordsXYZD _loc; @@ -36,7 +36,7 @@ public: uint16_t GetActionFlags() const override { - return GameActionBase::GetActionFlags() | GA_FLAGS::EDITOR_ONLY; + return GameActionBase::GetActionFlags() | GameActions::Flags::EditorOnly; } void Serialise(DataSerialiser & stream) override @@ -46,34 +46,35 @@ public: stream << DS_TAG(_loc); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !gCheatsSandboxMode) { - return std::make_unique( - GA_ERROR::NOT_IN_EDITOR_MODE, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE); + return std::make_unique( + GameActions::Status::NotInEditorMode, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE); } - auto res = std::make_unique(); + auto res = std::make_unique(); res->Expenditure = ExpenditureType::LandPurchase; res->Position = { _loc.x, _loc.y, _loc.z }; if (!map_check_free_elements_and_reorganise(3)) { - return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE); + return std::make_unique( + GameActions::Status::NoFreeElements, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE); } if (!LocationValid(_loc) || _loc.x <= 32 || _loc.y <= 32 || _loc.x >= (gMapSizeUnits - 32) || _loc.y >= (gMapSizeUnits - 32)) { - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_TOO_CLOSE_TO_EDGE_OF_MAP); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_TOO_CLOSE_TO_EDGE_OF_MAP); } if (gParkEntrances.size() >= MAX_PARK_ENTRANCES) { - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_ERR_TOO_MANY_PARK_ENTRANCES); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_ERR_TOO_MANY_PARK_ENTRANCES); } auto zLow = _loc.z; @@ -91,10 +92,11 @@ public: entranceLoc.y += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].y * 2; } - if (auto res2 = MapCanConstructAt({ entranceLoc, zLow, zHigh }, { 0b1111, 0 }); res2->Error != GA_ERROR::OK) + if (auto res2 = MapCanConstructAt({ entranceLoc, zLow, zHigh }, { 0b1111, 0 }); + res2->Error != GameActions::Status::Ok) { - return std::make_unique( - GA_ERROR::NO_CLEARANCE, STR_CANT_BUILD_PARK_ENTRANCE_HERE, res2->ErrorMessage.GetStringId(), + return std::make_unique( + GameActions::Status::NoClearance, STR_CANT_BUILD_PARK_ENTRANCE_HERE, res2->ErrorMessage.GetStringId(), res2->ErrorMessageArgs.data()); } @@ -102,17 +104,17 @@ public: EntranceElement* entranceElement = map_get_park_entrance_element_at(entranceLoc, false); if (entranceElement != nullptr) { - return std::make_unique( - GA_ERROR::ITEM_ALREADY_PLACED, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE); + return std::make_unique( + GameActions::Status::ItemAlreadyPlaced, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE); } } return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - auto res = std::make_unique(); + auto res = std::make_unique(); res->Expenditure = ExpenditureType::LandPurchase; res->Position = CoordsXYZ{ _loc.x, _loc.y, _loc.z }; diff --git a/src/openrct2/actions/PlacePeepSpawnAction.hpp b/src/openrct2/actions/PlacePeepSpawnAction.hpp index 5111b66440..ba4e3327b7 100644 --- a/src/openrct2/actions/PlacePeepSpawnAction.hpp +++ b/src/openrct2/actions/PlacePeepSpawnAction.hpp @@ -19,7 +19,7 @@ #include "../world/Surface.h" #include "GameAction.h" -DEFINE_GAME_ACTION(PlacePeepSpawnAction, GAME_COMMAND_PLACE_PEEP_SPAWN, GameActionResult) +DEFINE_GAME_ACTION(PlacePeepSpawnAction, GAME_COMMAND_PLACE_PEEP_SPAWN, GameActions::Result) { private: CoordsXYZD _location; @@ -33,7 +33,7 @@ public: uint16_t GetActionFlags() const override { - return GameActionBase::GetActionFlags() | GA_FLAGS::EDITOR_ONLY | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameActionBase::GetActionFlags() | GameActions::Flags::EditorOnly | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -43,56 +43,59 @@ public: stream << DS_TAG(_location.x) << DS_TAG(_location.y) << DS_TAG(_location.z) << DS_TAG(_location.direction); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (!(gScreenFlags & SCREEN_FLAGS_EDITOR) && !gCheatsSandboxMode) { - return std::make_unique( - GA_ERROR::NOT_IN_EDITOR_MODE, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE); + return std::make_unique( + GameActions::Status::NotInEditorMode, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE); } - auto res = std::make_unique(); + auto res = std::make_unique(); res->Expenditure = ExpenditureType::LandPurchase; res->Position = _location; if (!map_check_free_elements_and_reorganise(3)) { - return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE); + return std::make_unique( + GameActions::Status::NoFreeElements, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE); } if (!LocationValid(_location) || _location.x <= 16 || _location.y <= 16 || _location.x >= (gMapSizeUnits - 16) || _location.y >= (gMapSizeUnits - 16)) { - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_OFF_EDGE_OF_MAP); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_OFF_EDGE_OF_MAP); } // Verify footpath exists at location, and retrieve coordinates auto pathElement = map_get_path_element_at(TileCoordsXYZ{ _location }); if (pathElement == nullptr) { - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_CAN_ONLY_BE_BUILT_ACROSS_PATHS); } // Verify location is unowned auto surfaceMapElement = map_get_surface_element_at(_location); if (surfaceMapElement == nullptr) { - return std::make_unique(GA_ERROR::UNKNOWN, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE); + return std::make_unique( + GameActions::Status::Unknown, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE); } if (surfaceMapElement->GetOwnership() != OWNERSHIP_UNOWNED) { - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_ERR_MUST_BE_OUTSIDE_PARK_BOUNDARIES); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, + STR_ERR_MUST_BE_OUTSIDE_PARK_BOUNDARIES); } return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - auto res = std::make_unique(); + auto res = std::make_unique(); res->Expenditure = ExpenditureType::LandPurchase; res->Position = _location; diff --git a/src/openrct2/actions/PlayerKickAction.hpp b/src/openrct2/actions/PlayerKickAction.hpp index e0afd95713..a76f881eb1 100644 --- a/src/openrct2/actions/PlayerKickAction.hpp +++ b/src/openrct2/actions/PlayerKickAction.hpp @@ -12,7 +12,7 @@ #include "../network/network.h" #include "GameAction.h" -DEFINE_GAME_ACTION(PlayerKickAction, GAME_COMMAND_KICK_PLAYER, GameActionResult) +DEFINE_GAME_ACTION(PlayerKickAction, GAME_COMMAND_KICK_PLAYER, GameActions::Result) { private: NetworkPlayerId_t _playerId{ -1 }; @@ -27,7 +27,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -36,12 +36,12 @@ public: stream << DS_TAG(_playerId); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return network_kick_player(_playerId, false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return network_kick_player(_playerId, true); } diff --git a/src/openrct2/actions/PlayerSetGroupAction.hpp b/src/openrct2/actions/PlayerSetGroupAction.hpp index c42ca52eed..ea36d26a7b 100644 --- a/src/openrct2/actions/PlayerSetGroupAction.hpp +++ b/src/openrct2/actions/PlayerSetGroupAction.hpp @@ -12,7 +12,7 @@ #include "../network/network.h" #include "GameAction.h" -DEFINE_GAME_ACTION(PlayerSetGroupAction, GAME_COMMAND_SET_PLAYER_GROUP, GameActionResult) +DEFINE_GAME_ACTION(PlayerSetGroupAction, GAME_COMMAND_SET_PLAYER_GROUP, GameActions::Result) { private: NetworkPlayerId_t _playerId{ -1 }; @@ -29,7 +29,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -38,12 +38,12 @@ public: stream << DS_TAG(_playerId) << DS_TAG(_groupId); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return network_set_player_group(GetPlayer(), _playerId, _groupId, false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return network_set_player_group(GetPlayer(), _playerId, _groupId, true); } diff --git a/src/openrct2/actions/RideCreateAction.hpp b/src/openrct2/actions/RideCreateAction.hpp index ee9b773a4e..332718c670 100644 --- a/src/openrct2/actions/RideCreateAction.hpp +++ b/src/openrct2/actions/RideCreateAction.hpp @@ -26,15 +26,15 @@ #include -class RideCreateGameActionResult final : public GameActionResult +class RideCreateGameActionResult final : public GameActions::Result { public: RideCreateGameActionResult() - : GameActionResult(GA_ERROR::OK, STR_NONE) + : GameActions::Result(GameActions::Status::Ok, STR_NONE) { } - RideCreateGameActionResult(GA_ERROR error, rct_string_id message) - : GameActionResult(error, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, message) + RideCreateGameActionResult(GameActions::Status error, rct_string_id message) + : GameActions::Result(error, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, message) { } @@ -80,7 +80,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -90,48 +90,48 @@ public: stream << DS_TAG(_rideType) << DS_TAG(_subType) << DS_TAG(_colour1) << DS_TAG(_colour2); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto rideIndex = GetNextFreeRideId(); if (rideIndex == RIDE_ID_NULL) { // No more free slots available. - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_TOO_MANY_RIDES); + return MakeResult(GameActions::Status::NoFreeElements, STR_TOO_MANY_RIDES); } if (_rideType >= RIDE_TYPE_COUNT) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_RIDE_TYPE); + return MakeResult(GameActions::Status::InvalidParameters, STR_INVALID_RIDE_TYPE); } int32_t rideEntryIndex = ride_get_entry_index(_rideType, _subType); if (rideEntryIndex >= MAX_RIDE_OBJECTS) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_RIDE_TYPE); + return MakeResult(GameActions::Status::InvalidParameters, STR_INVALID_RIDE_TYPE); } const auto& colourPresets = RideTypeDescriptors[_rideType].ColourPresets; if (_colour1 >= colourPresets.count) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } rct_ride_entry* rideEntry = get_ride_entry(rideEntryIndex); if (rideEntry == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } vehicle_colour_preset_list* presetList = rideEntry->vehicle_preset_list; if ((presetList->count > 0 && presetList->count != 255) && _colour2 >= presetList->count) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { rct_ride_entry* rideEntry; auto res = MakeResult(); @@ -146,7 +146,7 @@ public: if (rideEntry == nullptr) { log_warning("Invalid request for ride %u", rideIndex); - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = STR_UNKNOWN_OBJECT_TYPE; return res; } diff --git a/src/openrct2/actions/RideDemolishAction.hpp b/src/openrct2/actions/RideDemolishAction.hpp index b687a81574..21aae881e6 100644 --- a/src/openrct2/actions/RideDemolishAction.hpp +++ b/src/openrct2/actions/RideDemolishAction.hpp @@ -29,7 +29,7 @@ using namespace OpenRCT2; -DEFINE_GAME_ACTION(RideDemolishAction, GAME_COMMAND_DEMOLISH_RIDE, GameActionResult) +DEFINE_GAME_ACTION(RideDemolishAction, GAME_COMMAND_DEMOLISH_RIDE, GameActions::Result) { private: NetworkRideId_t _rideIndex{ RideIdNewNull }; @@ -61,44 +61,45 @@ public: stream << DS_TAG(_rideIndex) << DS_TAG(_modifyType); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_DEMOLISH_RIDE, STR_NONE); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CANT_DEMOLISH_RIDE, STR_NONE); } if (ride->lifecycle_flags & (RIDE_LIFECYCLE_INDESTRUCTIBLE | RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) && _modifyType == RIDE_MODIFY_DEMOLISH) { - return std::make_unique( - GA_ERROR::NO_CLEARANCE, STR_CANT_DEMOLISH_RIDE, + return std::make_unique( + GameActions::Status::NoClearance, STR_CANT_DEMOLISH_RIDE, STR_LOCAL_AUTHORITY_FORBIDS_DEMOLITION_OR_MODIFICATIONS_TO_THIS_RIDE); } - GameActionResult::Ptr result = std::make_unique(); + GameActions::Result::Ptr result = std::make_unique(); if (_modifyType == RIDE_MODIFY_RENEW) { if (ride->status != RIDE_STATUS_CLOSED && ride->status != RIDE_STATUS_SIMULATING) { - return std::make_unique( - GA_ERROR::DISALLOWED, STR_CANT_REFURBISH_RIDE, STR_MUST_BE_CLOSED_FIRST); + return std::make_unique( + GameActions::Status::Disallowed, STR_CANT_REFURBISH_RIDE, STR_MUST_BE_CLOSED_FIRST); } if (ride->num_riders > 0) { - return std::make_unique( - GA_ERROR::DISALLOWED, STR_CANT_REFURBISH_RIDE, STR_RIDE_NOT_YET_EMPTY); + return std::make_unique( + GameActions::Status::Disallowed, STR_CANT_REFURBISH_RIDE, STR_RIDE_NOT_YET_EMPTY); } if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_EVER_BEEN_OPENED) || RideTypeDescriptors[ride->type].AvailableBreakdowns == 0) { - return std::make_unique( - GA_ERROR::DISALLOWED, STR_CANT_REFURBISH_RIDE, STR_CANT_REFURBISH_NOT_NEEDED); + return std::make_unique( + GameActions::Status::Disallowed, STR_CANT_REFURBISH_RIDE, STR_CANT_REFURBISH_NOT_NEEDED); } result->ErrorTitle = STR_CANT_REFURBISH_RIDE; @@ -108,13 +109,14 @@ public: return result; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_DEMOLISH_RIDE, STR_NONE); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CANT_DEMOLISH_RIDE, STR_NONE); } switch (_modifyType) @@ -125,11 +127,11 @@ public: return RefurbishRide(ride); } - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_DO_THIS); + return std::make_unique(GameActions::Status::InvalidParameters, STR_CANT_DO_THIS); } private: - GameActionResult::Ptr DemolishRide(Ride * ride) const + GameActions::Result::Ptr DemolishRide(Ride * ride) const { money32 refundPrice = DemolishTracks(); @@ -240,7 +242,7 @@ private: MarketingCancelCampaignsForRide(_rideIndex); - auto res = std::make_unique(); + auto res = std::make_unique(); res->Expenditure = ExpenditureType::RideConstruction; res->Cost = refundPrice; @@ -280,7 +282,7 @@ private: setMazeTrack.SetFlags(GetFlags()); auto execRes = GameActions::ExecuteNested(&setMazeTrack); - if (execRes->Error == GA_ERROR::OK) + if (execRes->Error == GameActions::Status::Ok) { return execRes->Cost; } @@ -317,7 +319,7 @@ private: auto removRes = GameActions::ExecuteNested(&trackRemoveAction); - if (removRes->Error != GA_ERROR::OK) + if (removRes->Error != GameActions::Status::Ok) { tile_element_remove(it.element); } @@ -354,9 +356,9 @@ private: return refundPrice; } - GameActionResult::Ptr RefurbishRide(Ride * ride) const + GameActions::Result::Ptr RefurbishRide(Ride * ride) const { - auto res = std::make_unique(); + auto res = std::make_unique(); res->Expenditure = ExpenditureType::RideConstruction; res->Cost = GetRefurbishPrice(ride); diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.hpp b/src/openrct2/actions/RideEntranceExitPlaceAction.hpp index c690729085..0036eb2dd1 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.hpp +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.hpp @@ -18,7 +18,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(RideEntranceExitPlaceAction, GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT, GameActionResult) +DEFINE_GAME_ACTION(RideEntranceExitPlaceAction, GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT, GameActions::Result) { private: CoordsXY _loc; @@ -61,36 +61,36 @@ public: stream << DS_TAG(_loc) << DS_TAG(_direction) << DS_TAG(_rideIndex) << DS_TAG(_stationNum) << DS_TAG(_isExit); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto errorTitle = _isExit ? STR_CANT_BUILD_MOVE_EXIT_FOR_THIS_RIDE_ATTRACTION : STR_CANT_BUILD_MOVE_ENTRANCE_FOR_THIS_RIDE_ATTRACTION; if (!map_check_free_elements_and_reorganise(1)) { - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, errorTitle); + return MakeResult(GameActions::Status::NoFreeElements, errorTitle); } auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid game command for ride %d", static_cast(_rideIndex)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, errorTitle); + return MakeResult(GameActions::Status::InvalidParameters, errorTitle); } if (_stationNum >= MAX_STATIONS) { log_warning("Invalid station number for ride. stationNum: %u", _stationNum); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, errorTitle); + return MakeResult(GameActions::Status::InvalidParameters, errorTitle); } if (ride->status != RIDE_STATUS_CLOSED && ride->status != RIDE_STATUS_SIMULATING) { - return MakeResult(GA_ERROR::NOT_CLOSED, errorTitle, STR_MUST_BE_CLOSED_FIRST); + return MakeResult(GameActions::Status::NotClosed, errorTitle, STR_MUST_BE_CLOSED_FIRST); } if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) { - return MakeResult(GA_ERROR::DISALLOWED, errorTitle, STR_NOT_ALLOWED_TO_MODIFY_STATION); + return MakeResult(GameActions::Status::Disallowed, errorTitle, STR_NOT_ALLOWED_TO_MODIFY_STATION); } const auto location = _isExit ? ride_get_exit_location(ride, _stationNum) @@ -102,7 +102,7 @@ public: rideEntranceExitRemove.SetFlags(GetFlags()); auto result = GameActions::QueryNested(&rideEntranceExitRemove); - if (result->Error != GA_ERROR::OK) + if (result->Error != GameActions::Status::Ok) { return result; } @@ -111,7 +111,7 @@ public: auto z = ride->stations[_stationNum].GetBaseZ(); if (!LocationValid(_loc) || (!gCheatsSandboxMode && !map_is_location_owned({ _loc, z }))) { - return MakeResult(GA_ERROR::NOT_OWNED, errorTitle); + return MakeResult(GameActions::Status::NotOwned, errorTitle); } auto clear_z = z + (_isExit ? RideExitHeight : RideEntranceHeight); @@ -120,17 +120,17 @@ public: { _loc, z, clear_z }, &map_place_non_scenery_clear_func, { 0b1111, 0 }, GetFlags(), &cost, CREATE_CROSSING_MODE_NONE)) { - return MakeResult(GA_ERROR::NO_CLEARANCE, errorTitle, gGameCommandErrorText, gCommonFormatArgs); + return MakeResult(GameActions::Status::NoClearance, errorTitle, gGameCommandErrorText, gCommonFormatArgs); } if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { - return MakeResult(GA_ERROR::DISALLOWED, errorTitle, STR_RIDE_CANT_BUILD_THIS_UNDERWATER); + return MakeResult(GameActions::Status::Disallowed, errorTitle, STR_RIDE_CANT_BUILD_THIS_UNDERWATER); } if (z > MaxRideEntranceOrExitHeight) { - return MakeResult(GA_ERROR::DISALLOWED, errorTitle, STR_TOO_HIGH); + return MakeResult(GameActions::Status::Disallowed, errorTitle, STR_TOO_HIGH); } auto res = MakeResult(); @@ -139,7 +139,7 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { // Remember when in unknown station num mode rideIndex is unknown and z is set // When in known station num mode rideIndex is known and z is unknown @@ -149,7 +149,7 @@ public: if (ride == nullptr) { log_warning("Invalid game command for ride %d", static_cast(_rideIndex)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, errorTitle); + return MakeResult(GameActions::Status::InvalidParameters, errorTitle); } if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST)) @@ -166,7 +166,7 @@ public: rideEntranceExitRemove.SetFlags(GetFlags()); auto result = GameActions::ExecuteNested(&rideEntranceExitRemove); - if (result->Error != GA_ERROR::OK) + if (result->Error != GameActions::Status::Ok) { return result; } @@ -185,7 +185,7 @@ public: { _loc, z, clear_z }, &map_place_non_scenery_clear_func, { 0b1111, 0 }, GetFlags() | GAME_COMMAND_FLAG_APPLY, &cost, CREATE_CROSSING_MODE_NONE)) { - return MakeResult(GA_ERROR::NO_CLEARANCE, errorTitle, gGameCommandErrorText, gCommonFormatArgs); + return MakeResult(GameActions::Status::NoClearance, errorTitle, gGameCommandErrorText, gCommonFormatArgs); } auto res = MakeResult(); @@ -234,18 +234,18 @@ public: return res; } - static GameActionResult::Ptr TrackPlaceQuery(const CoordsXYZ& loc, const bool isExit) + static GameActions::Result::Ptr TrackPlaceQuery(const CoordsXYZ& loc, const bool isExit) { auto errorTitle = isExit ? STR_CANT_BUILD_MOVE_EXIT_FOR_THIS_RIDE_ATTRACTION : STR_CANT_BUILD_MOVE_ENTRANCE_FOR_THIS_RIDE_ATTRACTION; if (!map_check_free_elements_and_reorganise(1)) { - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, errorTitle); + return MakeResult(GameActions::Status::NoFreeElements, errorTitle); } if (!gCheatsSandboxMode && !map_is_location_owned(loc)) { - return MakeResult(GA_ERROR::NOT_OWNED, errorTitle); + return MakeResult(GameActions::Status::NotOwned, errorTitle); } int16_t baseZ = loc.z; @@ -254,17 +254,17 @@ public: if (!map_can_construct_with_clear_at( { loc, baseZ, clearZ }, &map_place_non_scenery_clear_func, { 0b1111, 0 }, 0, &cost, CREATE_CROSSING_MODE_NONE)) { - return MakeResult(GA_ERROR::NO_CLEARANCE, errorTitle, gGameCommandErrorText, gCommonFormatArgs); + return MakeResult(GameActions::Status::NoClearance, errorTitle, gGameCommandErrorText, gCommonFormatArgs); } if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { - return MakeResult(GA_ERROR::DISALLOWED, errorTitle, STR_RIDE_CANT_BUILD_THIS_UNDERWATER); + return MakeResult(GameActions::Status::Disallowed, errorTitle, STR_RIDE_CANT_BUILD_THIS_UNDERWATER); } if (baseZ > MaxRideEntranceOrExitHeight) { - return MakeResult(GA_ERROR::DISALLOWED, errorTitle, STR_TOO_HIGH); + return MakeResult(GameActions::Status::Disallowed, errorTitle, STR_TOO_HIGH); } auto res = MakeResult(); res->Position = { loc.ToTileCentre(), tile_element_height(loc) }; diff --git a/src/openrct2/actions/RideEntranceExitRemoveAction.hpp b/src/openrct2/actions/RideEntranceExitRemoveAction.hpp index 1f52864bb0..a25aae91c8 100644 --- a/src/openrct2/actions/RideEntranceExitRemoveAction.hpp +++ b/src/openrct2/actions/RideEntranceExitRemoveAction.hpp @@ -14,7 +14,7 @@ #include "../world/Entrance.h" #include "GameAction.h" -DEFINE_GAME_ACTION(RideEntranceExitRemoveAction, GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, GameActionResult) +DEFINE_GAME_ACTION(RideEntranceExitRemoveAction, GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, GameActions::Result) { private: CoordsXY _loc; @@ -53,28 +53,28 @@ public: stream << DS_TAG(_loc) << DS_TAG(_rideIndex) << DS_TAG(_stationNum) << DS_TAG(_isExit); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid ride id %d for entrance/exit removal", static_cast(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } if (ride->status != RIDE_STATUS_CLOSED && ride->status != RIDE_STATUS_SIMULATING) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_MUST_BE_CLOSED_FIRST); + return MakeResult(GameActions::Status::InvalidParameters, STR_MUST_BE_CLOSED_FIRST); } if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NOT_ALLOWED_TO_MODIFY_STATION); + return MakeResult(GameActions::Status::InvalidParameters, STR_NOT_ALLOWED_TO_MODIFY_STATION); } if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::InvalidParameters, STR_LAND_NOT_OWNED_BY_PARK); } bool found = false; @@ -115,19 +115,19 @@ public: log_warning( "Track Element not found. x = %d, y = %d, ride = %d, station = %d", _loc.x, _loc.y, static_cast(_rideIndex), _stationNum); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid ride id %d for entrance/exit removal", static_cast(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST)) @@ -175,7 +175,7 @@ public: log_warning( "Track Element not found. x = %d, y = %d, ride = %d, station = %d", _loc.x, _loc.y, static_cast(_rideIndex), _stationNum); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } auto res = MakeResult(); diff --git a/src/openrct2/actions/RideSetAppearanceAction.hpp b/src/openrct2/actions/RideSetAppearanceAction.hpp index e11f351994..02ffedee8c 100644 --- a/src/openrct2/actions/RideSetAppearanceAction.hpp +++ b/src/openrct2/actions/RideSetAppearanceAction.hpp @@ -35,7 +35,7 @@ enum class RideSetAppearanceType : uint8_t EntranceStyle }; -DEFINE_GAME_ACTION(RideSetAppearanceAction, GAME_COMMAND_SET_RIDE_APPEARANCE, GameActionResult) +DEFINE_GAME_ACTION(RideSetAppearanceAction, GAME_COMMAND_SET_RIDE_APPEARANCE, GameActions::Result) { private: NetworkRideId_t _rideIndex{ RideIdNewNull }; @@ -63,7 +63,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -72,13 +72,13 @@ public: stream << DS_TAG(_rideIndex) << DS_TAG(_type) << DS_TAG(_value) << DS_TAG(_index); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } switch (_type) @@ -89,7 +89,7 @@ public: if (_index >= std::size(ride->track_colour)) { log_warning("Invalid game command, index %d out of bounds", _index); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } break; case RideSetAppearanceType::VehicleColourBody: @@ -98,7 +98,7 @@ public: if (_index >= std::size(ride->vehicle_colours)) { log_warning("Invalid game command, index %d out of bounds", _index); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } break; case RideSetAppearanceType::VehicleColourScheme: @@ -106,19 +106,19 @@ public: break; default: log_warning("Invalid game command, type %d not recognised", _type); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } switch (_type) @@ -164,7 +164,7 @@ public: } window_invalidate_by_number(WC_RIDE, _rideIndex); - auto res = std::make_unique(); + auto res = std::make_unique(); if (!ride->overall_view.isNull()) { auto location = ride->overall_view.ToTileCentre(); diff --git a/src/openrct2/actions/RideSetColourScheme.hpp b/src/openrct2/actions/RideSetColourScheme.hpp index 5e950d9554..470f69dff3 100644 --- a/src/openrct2/actions/RideSetColourScheme.hpp +++ b/src/openrct2/actions/RideSetColourScheme.hpp @@ -21,7 +21,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(RideSetColourSchemeAction, GAME_COMMAND_SET_COLOUR_SCHEME, GameActionResult) +DEFINE_GAME_ACTION(RideSetColourSchemeAction, GAME_COMMAND_SET_COLOUR_SCHEME, GameActions::Result) { private: CoordsXYZD _loc; @@ -46,7 +46,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -56,18 +56,18 @@ public: stream << DS_TAG(_loc) << DS_TAG(_trackType) << DS_TAG(_newColourScheme); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::InvalidParameters, STR_LAND_NOT_OWNED_BY_PARK); } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); res->Expenditure = ExpenditureType::RideConstruction; res->ErrorTitle = STR_CANT_SET_COLOUR_SCHEME; diff --git a/src/openrct2/actions/RideSetName.hpp b/src/openrct2/actions/RideSetName.hpp index 71a90a0211..aad6894eee 100644 --- a/src/openrct2/actions/RideSetName.hpp +++ b/src/openrct2/actions/RideSetName.hpp @@ -22,7 +22,7 @@ #include "../world/Park.h" #include "GameAction.h" -DEFINE_GAME_ACTION(RideSetNameAction, GAME_COMMAND_SET_RIDE_NAME, GameActionResult) +DEFINE_GAME_ACTION(RideSetNameAction, GAME_COMMAND_SET_RIDE_NAME, GameActions::Result) { private: NetworkRideId_t _rideIndex{ RideIdNewNull }; @@ -44,7 +44,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -54,31 +54,33 @@ public: stream << DS_TAG(_rideIndex) << DS_TAG(_name); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_RENAME_RIDE_ATTRACTION, STR_NONE); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CANT_RENAME_RIDE_ATTRACTION, STR_NONE); } if (!_name.empty() && Ride::NameExists(_name, ride->id)) { - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_CANT_RENAME_RIDE_ATTRACTION, STR_ERROR_EXISTING_NAME); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CANT_RENAME_RIDE_ATTRACTION, STR_ERROR_EXISTING_NAME); } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_RENAME_RIDE_ATTRACTION, STR_NONE); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CANT_RENAME_RIDE_ATTRACTION, STR_NONE); } if (_name.empty()) @@ -99,7 +101,7 @@ public: windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_RIDE_LIST)); windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_GUEST_LIST)); - auto res = std::make_unique(); + auto res = std::make_unique(); auto location = ride->overall_view.ToTileCentre(); res->Position = { location, tile_element_height(location) }; diff --git a/src/openrct2/actions/RideSetPriceAction.hpp b/src/openrct2/actions/RideSetPriceAction.hpp index 85549e721a..146e66db7f 100644 --- a/src/openrct2/actions/RideSetPriceAction.hpp +++ b/src/openrct2/actions/RideSetPriceAction.hpp @@ -23,7 +23,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(RideSetPriceAction, GAME_COMMAND_SET_RIDE_PRICE, GameActionResult) +DEFINE_GAME_ACTION(RideSetPriceAction, GAME_COMMAND_SET_RIDE_PRICE, GameActions::Result) { private: NetworkRideId_t _rideIndex{ RideIdNewNull }; @@ -48,7 +48,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -58,44 +58,44 @@ public: stream << DS_TAG(_rideIndex) << DS_TAG(_price) << DS_TAG(_primaryPrice); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); if (rideEntry == nullptr) { log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); res->Expenditure = ExpenditureType::ParkRideTickets; auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); if (rideEntry == nullptr) { log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } if (!ride->overall_view.isNull()) diff --git a/src/openrct2/actions/RideSetSetting.hpp b/src/openrct2/actions/RideSetSetting.hpp index c6dcdd7ec2..4748483aeb 100644 --- a/src/openrct2/actions/RideSetSetting.hpp +++ b/src/openrct2/actions/RideSetSetting.hpp @@ -28,7 +28,7 @@ enum class RideSetSetting : uint8_t RideType, }; -DEFINE_GAME_ACTION(RideSetSettingAction, GAME_COMMAND_SET_RIDE_SETTING, GameActionResult) +DEFINE_GAME_ACTION(RideSetSettingAction, GAME_COMMAND_SET_RIDE_SETTING, GameActions::Result) { private: NetworkRideId_t _rideIndex{ RideIdNewNull }; @@ -53,7 +53,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -63,13 +63,13 @@ public: stream << DS_TAG(_rideIndex) << DS_TAG(_setting) << DS_TAG(_value); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid ride: #%d.", static_cast(_rideIndex)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE); } switch (_setting) @@ -78,18 +78,20 @@ public: if (ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN) { return MakeResult( - GA_ERROR::DISALLOWED, STR_CANT_CHANGE_OPERATING_MODE, STR_HAS_BROKEN_DOWN_AND_REQUIRES_FIXING); + GameActions::Status::Disallowed, STR_CANT_CHANGE_OPERATING_MODE, + STR_HAS_BROKEN_DOWN_AND_REQUIRES_FIXING); } if (ride->status != RIDE_STATUS_CLOSED && ride->status != RIDE_STATUS_SIMULATING) { - return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_CHANGE_OPERATING_MODE, STR_MUST_BE_CLOSED_FIRST); + return MakeResult( + GameActions::Status::Disallowed, STR_CANT_CHANGE_OPERATING_MODE, STR_MUST_BE_CLOSED_FIRST); } if (!ride_is_mode_valid(ride) && !gCheatsShowAllOperatingModes) { log_warning("Invalid ride mode: %u", _value); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE); } break; case RideSetSetting::Departure: @@ -98,28 +100,28 @@ public: if (_value > 250) { log_warning("Invalid minimum waiting time: %u", _value); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE); } break; case RideSetSetting::MaxWaitingTime: if (_value > 250) { log_warning("Invalid maximum waiting time: %u", _value); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE); } break; case RideSetSetting::Operation: if (!ride_is_valid_operation_option(ride)) { log_warning("Invalid operation option value: %u", _value); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, GetOperationErrorMessage(ride)); + return MakeResult(GameActions::Status::InvalidParameters, GetOperationErrorMessage(ride)); } break; case RideSetSetting::InspectionInterval: if (_value > RIDE_INSPECTION_NEVER) { log_warning("Invalid inspection interval: %u", _value); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE); } break; case RideSetSetting::Music: @@ -128,53 +130,53 @@ public: if (_value >= MUSIC_STYLE_COUNT) { log_warning("Invalid music style: %u", _value); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE); } break; case RideSetSetting::LiftHillSpeed: if (!ride_is_valid_lift_hill_speed(ride)) { log_warning("Invalid lift hill speed: %u", _value); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE); } break; case RideSetSetting::NumCircuits: if (ride->lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT && _value > 1) { return MakeResult( - GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE, + GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE, STR_MULTICIRCUIT_NOT_POSSIBLE_WITH_CABLE_LIFT_HILL); } if (!ride_is_valid_num_circuits()) { log_warning("Invalid number of circuits: %u", _value); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE); } break; case RideSetSetting::RideType: if (!gCheatsAllowArbitraryRideTypeChanges) { log_warning("Arbitary ride type changes not allowed."); - return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_CHANGE_OPERATING_MODE); + return MakeResult(GameActions::Status::Disallowed, STR_CANT_CHANGE_OPERATING_MODE); } break; default: log_warning("Invalid RideSetSetting: %u", static_cast(_setting)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE); break; } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid ride: #%d.", static_cast(_rideIndex)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_OPERATING_MODE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_OPERATING_MODE); } switch (_setting) @@ -247,7 +249,7 @@ public: break; } - auto res = std::make_unique(); + auto res = std::make_unique(); if (!ride->overall_view.isNull()) { auto location = ride->overall_view.ToTileCentre(); diff --git a/src/openrct2/actions/RideSetStatus.hpp b/src/openrct2/actions/RideSetStatus.hpp index ca7298d005..86231e6817 100644 --- a/src/openrct2/actions/RideSetStatus.hpp +++ b/src/openrct2/actions/RideSetStatus.hpp @@ -30,7 +30,7 @@ static rct_string_id _StatusErrorTitles[] = { STR_CANT_SIMULATE, }; -DEFINE_GAME_ACTION(RideSetStatusAction, GAME_COMMAND_SET_RIDE_STATUS, GameActionResult) +DEFINE_GAME_ACTION(RideSetStatusAction, GAME_COMMAND_SET_RIDE_STATUS, GameActions::Result) { private: NetworkRideId_t _rideIndex{ RideIdNewNull }; @@ -52,7 +52,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -62,15 +62,15 @@ public: stream << DS_TAG(_rideIndex) << DS_TAG(_status); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); - res->Error = GA_ERROR::INVALID_PARAMETERS; + res->Error = GameActions::Status::InvalidParameters; res->ErrorTitle = STR_RIDE_DESCRIPTION_UNKNOWN; res->ErrorMessage = STR_NONE; return res; @@ -79,7 +79,7 @@ public: if (_status >= RIDE_STATUS_COUNT) { log_warning("Invalid ride status %u for ride %u", uint32_t(_status), uint32_t(_rideIndex)); - res->Error = GA_ERROR::INVALID_PARAMETERS; + res->Error = GameActions::Status::InvalidParameters; res->ErrorTitle = STR_RIDE_DESCRIPTION_UNKNOWN; res->ErrorMessage = STR_NONE; return res; @@ -95,7 +95,7 @@ public: if (_status == RIDE_STATUS_SIMULATING && (ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN)) { // Simulating will force clear the track, so make sure player can't cheat around a break down - res->Error = GA_ERROR::DISALLOWED; + res->Error = GameActions::Status::Disallowed; res->ErrorMessage = STR_HAS_BROKEN_DOWN_AND_REQUIRES_FIXING; return res; } @@ -103,7 +103,7 @@ public: { if (!ride_is_valid_for_test(ride, _status, false)) { - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = gGameCommandErrorText; return res; } @@ -112,25 +112,25 @@ public: { if (!ride_is_valid_for_open(ride, _status == RIDE_STATUS_OPEN, false)) { - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = gGameCommandErrorText; return res; } } } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); res->Expenditure = ExpenditureType::RideRunningCosts; auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid game command for ride %u", uint32_t(_rideIndex)); - res->Error = GA_ERROR::INVALID_PARAMETERS; + res->Error = GameActions::Status::InvalidParameters; res->ErrorTitle = STR_RIDE_DESCRIPTION_UNKNOWN; res->ErrorMessage = STR_NONE; return res; @@ -174,7 +174,7 @@ public: if (!ride_is_valid_for_test(ride, _status, true)) { - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = gGameCommandErrorText; return res; } @@ -215,14 +215,14 @@ public: { if (!ride_is_valid_for_test(ride, _status, true)) { - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = gGameCommandErrorText; return res; } } else if (!ride_is_valid_for_open(ride, _status == RIDE_STATUS_OPEN, true)) { - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = gGameCommandErrorText; return res; } diff --git a/src/openrct2/actions/RideSetVehiclesAction.hpp b/src/openrct2/actions/RideSetVehiclesAction.hpp index ac924aebee..7bbd53e7c6 100644 --- a/src/openrct2/actions/RideSetVehiclesAction.hpp +++ b/src/openrct2/actions/RideSetVehiclesAction.hpp @@ -34,7 +34,7 @@ enum class RideSetVehicleType : uint8_t Count, }; -DEFINE_GAME_ACTION(RideSetVehicleAction, GAME_COMMAND_SET_RIDE_VEHICLES, GameActionResult) +DEFINE_GAME_ACTION(RideSetVehicleAction, GAME_COMMAND_SET_RIDE_VEHICLES, GameActions::Result) { private: NetworkRideId_t _rideIndex{ RideIdNewNull }; @@ -66,7 +66,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -75,7 +75,7 @@ public: stream << DS_TAG(_rideIndex) << DS_TAG(_type) << DS_TAG(_value) << DS_TAG(_colour); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_type >= RideSetVehicleType::Count) { @@ -87,17 +87,18 @@ public: if (ride == nullptr) { log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, errTitle); + return std::make_unique(GameActions::Status::InvalidParameters, errTitle); } if (ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN) { - return std::make_unique(GA_ERROR::BROKEN, errTitle, STR_HAS_BROKEN_DOWN_AND_REQUIRES_FIXING); + return std::make_unique( + GameActions::Status::Broken, errTitle, STR_HAS_BROKEN_DOWN_AND_REQUIRES_FIXING); } if (ride->status != RIDE_STATUS_CLOSED && ride->status != RIDE_STATUS_SIMULATING) { - return std::make_unique(GA_ERROR::NOT_CLOSED, errTitle, STR_MUST_BE_CLOSED_FIRST); + return std::make_unique(GameActions::Status::NotClosed, errTitle, STR_MUST_BE_CLOSED_FIRST); } switch (_type) @@ -110,13 +111,13 @@ public: if (!ride_is_vehicle_type_valid(ride)) { log_error("Invalid vehicle type. type = %d", _value); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, errTitle); + return std::make_unique(GameActions::Status::InvalidParameters, errTitle); } auto rideEntry = get_ride_entry(_value); if (rideEntry == nullptr) { log_warning("Invalid ride entry, ride->subtype = %d", ride->subtype); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, errTitle); + return std::make_unique(GameActions::Status::InvalidParameters, errTitle); } // Validate preset @@ -124,27 +125,27 @@ public: if (_colour >= presetList->count && _colour != 255 && _colour != 0) { log_error("Unknown vehicle colour preset. colour = %d", _colour); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, errTitle); + return std::make_unique(GameActions::Status::InvalidParameters, errTitle); } break; } default: log_error("Unknown vehicle command. type = %d", _type); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, errTitle); + return std::make_unique(GameActions::Status::InvalidParameters, errTitle); } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto errTitle = SetVehicleTypeErrorTitle[EnumValue(_type)]; auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid game command, ride_id = %u", uint32_t(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, errTitle); + return std::make_unique(GameActions::Status::InvalidParameters, errTitle); } switch (_type) @@ -167,7 +168,7 @@ public: if (rideEntry == nullptr) { log_warning("Invalid ride entry, ride->subtype = %d", ride->subtype); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, errTitle); + return std::make_unique(GameActions::Status::InvalidParameters, errTitle); } auto clampValue = _value; if (!gCheatsDisableTrainLengthLimit) @@ -189,7 +190,7 @@ public: if (rideEntry == nullptr) { log_warning("Invalid ride entry, ride->subtype = %d", ride->subtype); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, errTitle); + return std::make_unique(GameActions::Status::InvalidParameters, errTitle); } ride_set_vehicle_colours_to_random_preset(ride, _colour); @@ -203,13 +204,13 @@ public: default: log_error("Unknown vehicle command. type = %d", _type); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, errTitle); + return std::make_unique(GameActions::Status::InvalidParameters, errTitle); } ride->num_circuits = 1; ride->UpdateMaxVehicles(); - auto res = std::make_unique(); + auto res = std::make_unique(); if (!ride->overall_view.isNull()) { auto location = ride->overall_view.ToTileCentre(); diff --git a/src/openrct2/actions/ScenarioSetSettingAction.hpp b/src/openrct2/actions/ScenarioSetSettingAction.hpp index 15a3da2272..132a74dc20 100644 --- a/src/openrct2/actions/ScenarioSetSettingAction.hpp +++ b/src/openrct2/actions/ScenarioSetSettingAction.hpp @@ -45,7 +45,7 @@ enum class ScenarioSetSetting : uint8_t Count }; -DEFINE_GAME_ACTION(ScenarioSetSettingAction, GAME_COMMAND_EDIT_SCENARIO_OPTIONS, GameActionResult) +DEFINE_GAME_ACTION(ScenarioSetSettingAction, GAME_COMMAND_EDIT_SCENARIO_OPTIONS, GameActions::Result) { private: ScenarioSetSetting _setting{ ScenarioSetSetting::Count }; @@ -61,7 +61,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -71,18 +71,18 @@ public: stream << DS_TAG(_setting) << DS_TAG(_value); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_setting >= ScenarioSetSetting::Count) { log_error("Invalid setting: %u", _setting); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { switch (_setting) { @@ -284,7 +284,7 @@ public: break; default: log_error("Invalid setting: %u", _setting); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); break; } window_invalidate_by_class(WC_EDITOR_SCENARIO_OPTIONS); diff --git a/src/openrct2/actions/SetCheatAction.hpp b/src/openrct2/actions/SetCheatAction.hpp index 562471a337..324c9d0ebc 100644 --- a/src/openrct2/actions/SetCheatAction.hpp +++ b/src/openrct2/actions/SetCheatAction.hpp @@ -36,7 +36,7 @@ #include "ParkSetLoanAction.hpp" #include "ParkSetParameterAction.hpp" -DEFINE_GAME_ACTION(SetCheatAction, GAME_COMMAND_CHEAT, GameActionResult) +DEFINE_GAME_ACTION(SetCheatAction, GAME_COMMAND_CHEAT, GameActions::Result) { using ParametersRange = std::pair, std::pair>; @@ -63,7 +63,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -72,28 +72,28 @@ public: stream << DS_TAG(_cheatType) << DS_TAG(_param1) << DS_TAG(_param2); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (static_cast(_cheatType) >= static_cast(CheatType::Count)) { - MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } ParametersRange validRange = GetParameterRange(static_cast(_cheatType.id)); if (_param1 < validRange.first.first || _param1 > validRange.first.second) { - MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } if (_param2 < validRange.second.first || _param2 > validRange.second.second) { - MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { switch (static_cast(_cheatType.id)) { @@ -252,7 +252,7 @@ public: default: { log_error("Unabled cheat: %d", _cheatType.id); - MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } break; } diff --git a/src/openrct2/actions/SetParkEntranceFeeAction.hpp b/src/openrct2/actions/SetParkEntranceFeeAction.hpp index 38768543b2..c8682e8dbd 100644 --- a/src/openrct2/actions/SetParkEntranceFeeAction.hpp +++ b/src/openrct2/actions/SetParkEntranceFeeAction.hpp @@ -16,7 +16,7 @@ #include "../world/Park.h" #include "GameAction.h" -DEFINE_GAME_ACTION(SetParkEntranceFeeAction, GAME_COMMAND_SET_PARK_ENTRANCE_FEE, GameActionResult) +DEFINE_GAME_ACTION(SetParkEntranceFeeAction, GAME_COMMAND_SET_PARK_ENTRANCE_FEE, GameActions::Result) { private: money16 _fee{ MONEY16_UNDEFINED }; @@ -30,7 +30,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -40,25 +40,25 @@ public: stream << DS_TAG(_fee); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { bool noMoney = (gParkFlags & PARK_FLAGS_NO_MONEY) != 0; bool forceFreeEntry = !park_entry_price_unlocked(); if (noMoney || forceFreeEntry) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_NONE); + return std::make_unique(GameActions::Status::Disallowed, STR_NONE); } if (_fee < MONEY_FREE || _fee > MAX_ENTRANCE_FEE) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { gParkEntranceFee = _fee; window_invalidate_by_class(WC_PARK_INFORMATION); - return std::make_unique(); + return std::make_unique(); } }; diff --git a/src/openrct2/actions/SignSetNameAction.hpp b/src/openrct2/actions/SignSetNameAction.hpp index 8f49c9011c..f1aa3c584b 100644 --- a/src/openrct2/actions/SignSetNameAction.hpp +++ b/src/openrct2/actions/SignSetNameAction.hpp @@ -21,7 +21,7 @@ #include -DEFINE_GAME_ACTION(SignSetNameAction, GAME_COMMAND_SET_SIGN_NAME, GameActionResult) +DEFINE_GAME_ACTION(SignSetNameAction, GAME_COMMAND_SET_SIGN_NAME, GameActions::Result) { private: BannerIndex _bannerIndex{ BANNER_INDEX_NULL }; @@ -37,7 +37,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -46,17 +46,17 @@ public: stream << DS_TAG(_bannerIndex) << DS_TAG(_name); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_bannerIndex >= MAX_BANNERS) { log_warning("Invalid game command for setting sign name, banner id = %d", _bannerIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto banner = GetBanner(_bannerIndex); diff --git a/src/openrct2/actions/SignSetStyleAction.hpp b/src/openrct2/actions/SignSetStyleAction.hpp index 7abb3c6e55..d500cdd201 100644 --- a/src/openrct2/actions/SignSetStyleAction.hpp +++ b/src/openrct2/actions/SignSetStyleAction.hpp @@ -20,7 +20,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(SignSetStyleAction, GAME_COMMAND_SET_SIGN_STYLE, GameActionResult) +DEFINE_GAME_ACTION(SignSetStyleAction, GAME_COMMAND_SET_SIGN_STYLE, GameActions::Result) { private: BannerIndex _bannerIndex{ BANNER_INDEX_NULL }; @@ -40,7 +40,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -49,12 +49,12 @@ public: stream << DS_TAG(_bannerIndex) << DS_TAG(_mainColour) << DS_TAG(_textColour) << DS_TAG(_isLarge); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_bannerIndex >= MAX_BANNERS) { log_warning("Invalid game command for setting sign style, banner id '%d' out of range", _bannerIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } if (_isLarge) @@ -63,12 +63,12 @@ public: if (tileElement == nullptr) { log_warning("Invalid game command for setting sign style, banner id '%d' not found", _bannerIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } if (tileElement->GetType() != TILE_ELEMENT_TYPE_LARGE_SCENERY) { log_warning("Invalid game command for setting sign style, banner id '%d' is not large", _bannerIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } } else @@ -78,14 +78,14 @@ public: if (!wallElement) { log_warning("Invalid game command for setting sign style, banner id '%d' not found", _bannerIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto banner = GetBanner(_bannerIndex); @@ -98,7 +98,7 @@ public: { coords, tileElement->GetBaseZ(), tileElement->GetDirection() }, tileElement->AsLargeScenery()->GetSequenceIndex(), _mainColour, _textColour)) { - return MakeResult(GA_ERROR::UNKNOWN, STR_NONE); + return MakeResult(GameActions::Status::Unknown, STR_NONE); } } else diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.hpp b/src/openrct2/actions/SmallSceneryPlaceAction.hpp index 5aeb7389c4..b487e6726d 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.hpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.hpp @@ -27,23 +27,23 @@ #include "../world/TileElement.h" #include "GameAction.h" -class SmallSceneryPlaceActionResult final : public GameActionResult +class SmallSceneryPlaceActionResult final : public GameActions::Result { public: SmallSceneryPlaceActionResult() - : GameActionResult(GA_ERROR::OK, STR_CANT_POSITION_THIS_HERE) + : GameActions::Result(GameActions::Status::Ok, STR_CANT_POSITION_THIS_HERE) { } - SmallSceneryPlaceActionResult(GA_ERROR error) - : GameActionResult(error, STR_CANT_POSITION_THIS_HERE) + SmallSceneryPlaceActionResult(GameActions::Status error) + : GameActions::Result(error, STR_CANT_POSITION_THIS_HERE) { } - SmallSceneryPlaceActionResult(GA_ERROR error, rct_string_id message) - : GameActionResult(error, STR_CANT_POSITION_THIS_HERE, message) + SmallSceneryPlaceActionResult(GameActions::Status error, rct_string_id message) + : GameActions::Result(error, STR_CANT_POSITION_THIS_HERE, message) { } - SmallSceneryPlaceActionResult(GA_ERROR error, rct_string_id message, uint8_t* args) - : GameActionResult(error, STR_CANT_POSITION_THIS_HERE, message, args) + SmallSceneryPlaceActionResult(GameActions::Status error, rct_string_id message, uint8_t* args) + : GameActions::Result(error, STR_CANT_POSITION_THIS_HERE, message, args) { } @@ -100,7 +100,7 @@ public: << DS_TAG(_secondaryColour); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { bool isOnWater = false; bool supportsRequired = false; @@ -129,23 +129,23 @@ public: if (!map_check_free_elements_and_reorganise(1)) { - return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS); + return std::make_unique(GameActions::Status::NoFreeElements); } if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS); + return MakeResult(GameActions::Status::InvalidParameters); } if (!byte_9D8150 && (_loc.x > gMapSizeMaxXY || _loc.y > gMapSizeMaxXY)) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } rct_scenery_entry* sceneryEntry = get_small_scenery_entry(_sceneryType); if (sceneryEntry == nullptr) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } auto quadrant = _quadrant; @@ -194,7 +194,7 @@ public: if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned({ _loc.x, _loc.y, targetHeight })) { - return std::make_unique(GA_ERROR::NOT_OWNED, STR_LAND_NOT_OWNED_BY_PARK); + return std::make_unique(GameActions::Status::NotOwned, STR_LAND_NOT_OWNED_BY_PARK); } auto* surfaceElement = map_get_surface_element_at(_loc); @@ -204,7 +204,8 @@ public: int32_t water_height = surfaceElement->GetWaterHeight() - 1; if (water_height > targetHeight) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CANT_BUILD_THIS_UNDERWATER); + return std::make_unique( + GameActions::Status::Disallowed, STR_CANT_BUILD_THIS_UNDERWATER); } } @@ -212,7 +213,8 @@ public: { if (isOnWater) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ON_LAND); + return std::make_unique( + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ON_LAND); } if (surfaceElement != nullptr && surfaceElement->GetWaterHeight() > 0) @@ -220,7 +222,7 @@ public: if (surfaceElement->GetWaterHeight() > targetHeight) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ON_LAND); + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ON_LAND); } } } @@ -229,7 +231,7 @@ public: && (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_REQUIRE_FLAT_SURFACE)) && !supportsRequired && !isOnWater && surfaceElement != nullptr && (surfaceElement->GetSlope() != TILE_ELEMENT_SLOPE_FLAT)) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_LEVEL_LAND_REQUIRED); + return std::make_unique(GameActions::Status::Disallowed, STR_LEVEL_LAND_REQUIRED); } if (!gCheatsDisableSupportLimits && !(scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_STACKABLE)) @@ -241,13 +243,15 @@ public: { if (surfaceElement->GetWaterHeight() > 0 || (surfaceElement->GetBaseZ()) != targetHeight) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_LEVEL_LAND_REQUIRED); + return std::make_unique( + GameActions::Status::Disallowed, STR_LEVEL_LAND_REQUIRED); } } } else { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ON_LAND); + return std::make_unique( + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ON_LAND); } } @@ -296,7 +300,7 @@ public: CREATE_CROSSING_MODE_NONE)) { return std::make_unique( - GA_ERROR::DISALLOWED, gGameCommandErrorText, gCommonFormatArgs); + GameActions::Status::Disallowed, gGameCommandErrorText, gCommonFormatArgs); } res->GroundFlags = gMapGroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); @@ -307,7 +311,7 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { bool supportsRequired = false; if (_loc.z != 0) @@ -336,7 +340,7 @@ public: rct_scenery_entry* sceneryEntry = get_small_scenery_entry(_sceneryType); if (sceneryEntry == nullptr) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } auto quadrant = _quadrant; @@ -434,7 +438,7 @@ public: &clearCost, CREATE_CROSSING_MODE_NONE)) { return std::make_unique( - GA_ERROR::DISALLOWED, gGameCommandErrorText, gCommonFormatArgs); + GameActions::Status::Disallowed, gGameCommandErrorText, gCommonFormatArgs); } res->GroundFlags = gMapGroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.hpp b/src/openrct2/actions/SmallSceneryRemoveAction.hpp index 6c8a213618..f3e05d44c6 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.hpp +++ b/src/openrct2/actions/SmallSceneryRemoveAction.hpp @@ -23,7 +23,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(SmallSceneryRemoveAction, GAME_COMMAND_REMOVE_SCENERY, GameActionResult) +DEFINE_GAME_ACTION(SmallSceneryRemoveAction, GAME_COMMAND_REMOVE_SCENERY, GameActions::Result) { private: CoordsXYZ _loc; @@ -59,19 +59,19 @@ public: stream << DS_TAG(_loc) << DS_TAG(_quadrant) << DS_TAG(_sceneryType); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } rct_scenery_entry* entry = get_small_scenery_entry(_sceneryType); if (entry == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); } res->Cost = entry->small_scenery.removal_price * 10; @@ -85,7 +85,7 @@ public: { if (scenery_small_entry_has_flag(entry, SMALL_SCENERY_FLAG_IS_TREE)) { - res->Error = GA_ERROR::NO_CLEARANCE; + res->Error = GameActions::Status::NoClearance; res->ErrorTitle = STR_CANT_REMOVE_THIS; res->ErrorMessage = STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY; return res; @@ -95,7 +95,7 @@ public: // Check if the land is owned if (!map_is_location_owned(_loc)) { - res->Error = GA_ERROR::NO_CLEARANCE; + res->Error = GameActions::Status::NoClearance; res->ErrorTitle = STR_CANT_REMOVE_THIS; res->ErrorMessage = STR_LAND_NOT_OWNED_BY_PARK; return res; @@ -105,20 +105,20 @@ public: TileElement* tileElement = FindSceneryElement(); if (tileElement == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); } return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); rct_scenery_entry* entry = get_small_scenery_entry(_sceneryType); if (entry == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_INVALID_SELECTION_OF_OBJECTS); + return MakeResult(GameActions::Status::InvalidParameters, STR_INVALID_SELECTION_OF_OBJECTS); } res->Cost = entry->small_scenery.removal_price * 10; @@ -128,7 +128,7 @@ public: TileElement* tileElement = FindSceneryElement(); if (tileElement == nullptr) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); } res->Position.z = tile_element_height(res->Position); diff --git a/src/openrct2/actions/SmallScenerySetColourAction.hpp b/src/openrct2/actions/SmallScenerySetColourAction.hpp index 0c371e9d72..73ece75cc7 100644 --- a/src/openrct2/actions/SmallScenerySetColourAction.hpp +++ b/src/openrct2/actions/SmallScenerySetColourAction.hpp @@ -27,7 +27,7 @@ #include "../world/TileElement.h" #include "GameAction.h" -DEFINE_GAME_ACTION(SmallScenerySetColourAction, GAME_COMMAND_SET_SCENERY_COLOUR, GameActionResult) +DEFINE_GAME_ACTION(SmallScenerySetColourAction, GAME_COMMAND_SET_SCENERY_COLOUR, GameActions::Result) { private: CoordsXYZ _loc; @@ -51,7 +51,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -62,18 +62,18 @@ public: << DS_TAG(_secondaryColour); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr QueryExecute(bool isExecuting) const + GameActions::Result::Ptr QueryExecute(bool isExecuting) const { auto res = MakeResult(); res->Expenditure = ExpenditureType::Landscaping; @@ -84,14 +84,14 @@ private: if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NotOwned, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); } if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) { if (!map_is_location_owned(_loc)) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NotOwned, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); } } @@ -100,7 +100,7 @@ private: if (sceneryElement == nullptr) { log_error("Small scenery not found at: x = %d, y = %d, z = %d", _loc.x, _loc.y, _loc.z); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && !(sceneryElement->IsGhost())) diff --git a/src/openrct2/actions/StaffFireAction.hpp b/src/openrct2/actions/StaffFireAction.hpp index 5bda0bae7b..ee29a6d6f5 100644 --- a/src/openrct2/actions/StaffFireAction.hpp +++ b/src/openrct2/actions/StaffFireAction.hpp @@ -14,7 +14,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(StaffFireAction, GAME_COMMAND_FIRE_STAFF_MEMBER, GameActionResult) +DEFINE_GAME_ACTION(StaffFireAction, GAME_COMMAND_FIRE_STAFF_MEMBER, GameActions::Result) { private: uint16_t _spriteId{ SPRITE_INDEX_NULL }; @@ -28,7 +28,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -37,31 +37,31 @@ public: stream << DS_TAG(_spriteId); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_spriteId >= MAX_SPRITES) { log_error("Invalid spriteId. spriteId = %u", _spriteId); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } auto staff = TryGetEntity(_spriteId); if (staff == nullptr) { log_error("Invalid spriteId. spriteId = %u", _spriteId); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto staff = TryGetEntity(_spriteId); if (staff == nullptr) { log_error("Invalid spriteId. spriteId = %u", _spriteId); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } window_close_by_class(WC_FIRE_PROMPT); peep_sprite_remove(staff); diff --git a/src/openrct2/actions/StaffHireNewAction.hpp b/src/openrct2/actions/StaffHireNewAction.hpp index 3193bd9398..f046d1b19a 100644 --- a/src/openrct2/actions/StaffHireNewAction.hpp +++ b/src/openrct2/actions/StaffHireNewAction.hpp @@ -35,15 +35,15 @@ static constexpr const PeepSpriteType spriteTypes[] = { PeepSpriteType::EntertainerPanda, }; -class StaffHireNewActionResult final : public GameActionResult +class StaffHireNewActionResult final : public GameActions::Result { public: StaffHireNewActionResult() - : GameActionResult(GA_ERROR::OK, STR_CANT_HIRE_NEW_STAFF) + : GameActions::Result(GameActions::Status::Ok, STR_CANT_HIRE_NEW_STAFF) { } - StaffHireNewActionResult(GA_ERROR error, rct_string_id message) - : GameActionResult(error, STR_CANT_HIRE_NEW_STAFF, message) + StaffHireNewActionResult(GameActions::Status error, rct_string_id message) + : GameActions::Result(error, STR_CANT_HIRE_NEW_STAFF, message) { } @@ -70,7 +70,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -80,18 +80,18 @@ public: stream << DS_TAG(_autoPosition) << DS_TAG(_staffType) << DS_TAG(_entertainerType) << DS_TAG(_staffOrders); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr QueryExecute(bool execute) const + GameActions::Result::Ptr QueryExecute(bool execute) const { auto res = std::make_unique(); @@ -102,12 +102,12 @@ private: // Invalid staff type. log_error("Tried to use invalid staff type: %u", static_cast(_staffType)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } if (GetEntityListCount(EntityListId::Free) < 400) { - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_TOO_MANY_PEOPLE_IN_GAME); + return MakeResult(GameActions::Status::NoFreeElements, STR_TOO_MANY_PEOPLE_IN_GAME); } if (_staffType == static_cast(StaffType::Entertainer)) @@ -117,7 +117,7 @@ private: // Invalid entertainer costume log_error("Tried to use invalid entertainer type: %u", static_cast(_entertainerType)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } uint32_t availableCostumes = staff_get_available_entertainer_costumes(); @@ -126,7 +126,7 @@ private: // Entertainer costume unavailable log_error("Tried to use unavailable entertainer type: %u", static_cast(_entertainerType)); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } } @@ -141,14 +141,14 @@ private: if (staffIndex == STAFF_MAX_COUNT) { // Too many staff members exist already. - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_TOO_MANY_STAFF_IN_GAME); + return MakeResult(GameActions::Status::NoFreeElements, STR_TOO_MANY_STAFF_IN_GAME); } Peep* newPeep = &(create_sprite(SPRITE_IDENTIFIER_PEEP)->peep); if (newPeep == nullptr) { // Too many peeps exist already. - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_TOO_MANY_PEOPLE_IN_GAME); + return MakeResult(GameActions::Status::NoFreeElements, STR_TOO_MANY_PEOPLE_IN_GAME); } if (execute == false) diff --git a/src/openrct2/actions/StaffSetColourAction.hpp b/src/openrct2/actions/StaffSetColourAction.hpp index dcb32cd821..18e050b38c 100644 --- a/src/openrct2/actions/StaffSetColourAction.hpp +++ b/src/openrct2/actions/StaffSetColourAction.hpp @@ -20,7 +20,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(StaffSetColourAction, GAME_COMMAND_SET_STAFF_COLOUR, GameActionResult) +DEFINE_GAME_ACTION(StaffSetColourAction, GAME_COMMAND_SET_STAFF_COLOUR, GameActions::Result) { private: uint8_t _staffType{}; @@ -36,7 +36,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -45,22 +45,22 @@ public: stream << DS_TAG(_staffType) << DS_TAG(_colour); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto staffType = static_cast(_staffType); if (staffType != StaffType::Handyman && staffType != StaffType::Mechanic && staffType != StaffType::Security) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { // Update global uniform colour property if (!staff_set_colour(static_cast(_staffType), _colour)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } // Update each staff member's uniform diff --git a/src/openrct2/actions/StaffSetCostumeAction.hpp b/src/openrct2/actions/StaffSetCostumeAction.hpp index 7eaacc6052..2d95f031cb 100644 --- a/src/openrct2/actions/StaffSetCostumeAction.hpp +++ b/src/openrct2/actions/StaffSetCostumeAction.hpp @@ -38,7 +38,7 @@ constexpr const bool peep_slow_walking_types[] = { true, // PeepSpriteType::Balloon }; -DEFINE_GAME_ACTION(StaffSetCostumeAction, GAME_COMMAND_SET_STAFF_COSTUME, GameActionResult) +DEFINE_GAME_ACTION(StaffSetCostumeAction, GAME_COMMAND_SET_STAFF_COSTUME, GameActions::Result) { private: uint16_t _spriteIndex{ SPRITE_INDEX_NULL }; @@ -54,7 +54,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -64,36 +64,36 @@ public: stream << DS_TAG(_spriteIndex) << DS_TAG(_costume); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_spriteIndex >= MAX_SPRITES) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } auto* staff = TryGetEntity(_spriteIndex); if (staff == nullptr) { log_warning("Invalid game command for sprite %u", _spriteIndex); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } auto spriteType = EntertainerCostumeToSprite(_costume); if (EnumValue(spriteType) > std::size(peep_slow_walking_types)) { log_warning("Invalid game command for sprite %u", _spriteIndex); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto* staff = TryGetEntity(_spriteIndex); if (staff == nullptr) { log_warning("Invalid game command for sprite %u", _spriteIndex); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } auto spriteType = EntertainerCostumeToSprite(_costume); @@ -111,7 +111,7 @@ public: auto intent = Intent(INTENT_ACTION_REFRESH_STAFF_LIST); context_broadcast_intent(&intent); - auto res = std::make_unique(); + auto res = std::make_unique(); res->Position.x = staff->x; res->Position.y = staff->y; res->Position.z = staff->z; diff --git a/src/openrct2/actions/StaffSetNameAction.hpp b/src/openrct2/actions/StaffSetNameAction.hpp index 4fc49262b2..ce02259f6d 100644 --- a/src/openrct2/actions/StaffSetNameAction.hpp +++ b/src/openrct2/actions/StaffSetNameAction.hpp @@ -22,7 +22,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(StaffSetNameAction, GAME_COMMAND_SET_STAFF_NAME, GameActionResult) +DEFINE_GAME_ACTION(StaffSetNameAction, GAME_COMMAND_SET_STAFF_NAME, GameActions::Result) { private: uint16_t _spriteIndex{ SPRITE_INDEX_NULL }; @@ -38,7 +38,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -48,44 +48,44 @@ public: stream << DS_TAG(_spriteIndex) << DS_TAG(_name); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_spriteIndex >= MAX_SPRITES) { - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE); } auto staff = TryGetEntity(_spriteIndex); if (staff == nullptr) { log_warning("Invalid game command for sprite %u", _spriteIndex); - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE); } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto staff = TryGetEntity(_spriteIndex); if (staff == nullptr) { log_warning("Invalid game command for sprite %u", _spriteIndex); - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE); } auto curName = staff->GetName(); if (curName == _name) { - return std::make_unique(GA_ERROR::OK, STR_NONE); + return std::make_unique(GameActions::Status::Ok, STR_NONE); } if (!staff->SetName(_name)) { - return std::make_unique(GA_ERROR::UNKNOWN, STR_CANT_NAME_GUEST, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_CANT_NAME_GUEST, STR_NONE); } gfx_invalidate_screen(); @@ -93,7 +93,7 @@ public: auto intent = Intent(INTENT_ACTION_REFRESH_STAFF_LIST); context_broadcast_intent(&intent); - auto res = std::make_unique(); + auto res = std::make_unique(); res->Position.x = staff->x; res->Position.y = staff->y; res->Position.z = staff->z; diff --git a/src/openrct2/actions/StaffSetOrdersAction.hpp b/src/openrct2/actions/StaffSetOrdersAction.hpp index 8868d8eead..f9048684a0 100644 --- a/src/openrct2/actions/StaffSetOrdersAction.hpp +++ b/src/openrct2/actions/StaffSetOrdersAction.hpp @@ -18,7 +18,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(StaffSetOrdersAction, GAME_COMMAND_SET_STAFF_ORDERS, GameActionResult) +DEFINE_GAME_ACTION(StaffSetOrdersAction, GAME_COMMAND_SET_STAFF_ORDERS, GameActions::Result) { private: uint16_t _spriteIndex{ SPRITE_INDEX_NULL }; @@ -34,7 +34,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -44,11 +44,11 @@ public: stream << DS_TAG(_spriteIndex) << DS_TAG(_ordersId); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_spriteIndex >= MAX_SPRITES) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } auto* staff = TryGetEntity(_spriteIndex); @@ -56,19 +56,19 @@ public: || (staff->AssignedStaffType != StaffType::Handyman && staff->AssignedStaffType != StaffType::Mechanic)) { log_warning("Invalid game command for sprite %u", _spriteIndex); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } - return std::make_unique(); + return std::make_unique(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto* staff = TryGetEntity(_spriteIndex); if (staff == nullptr) { log_warning("Invalid game command for sprite %u", _spriteIndex); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } staff->StaffOrders = _ordersId; @@ -76,7 +76,7 @@ public: auto intent = Intent(INTENT_ACTION_REFRESH_STAFF_LIST); context_broadcast_intent(&intent); - auto res = std::make_unique(); + auto res = std::make_unique(); res->Position.x = staff->x; res->Position.y = staff->y; res->Position.z = staff->z; diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp index 98dbb30b49..b1cc95110b 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp @@ -15,7 +15,7 @@ #include "../world/Sprite.h" #include "GameAction.h" -DEFINE_GAME_ACTION(StaffSetPatrolAreaAction, GAME_COMMAND_SET_STAFF_PATROL, GameActionResult) +DEFINE_GAME_ACTION(StaffSetPatrolAreaAction, GAME_COMMAND_SET_STAFF_PATROL, GameActions::Result) { private: uint16_t _spriteId{ SPRITE_INDEX_NULL }; @@ -31,7 +31,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -40,36 +40,36 @@ public: stream << DS_TAG(_spriteId) << DS_TAG(_loc); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { if (_spriteId >= MAX_SPRITES) { log_error("Invalid spriteId. spriteId = %u", _spriteId); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } auto staff = TryGetEntity(_spriteId); if (staff == nullptr) { log_error("Invalid spriteId. spriteId = %u", _spriteId); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } return MakeResult(); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto staff = TryGetEntity(_spriteId); if (staff == nullptr) { log_error("Invalid spriteId. spriteId = %u", _spriteId); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } int32_t patrolOffset = staff->StaffId * STAFF_PATROL_AREA_SIZE; diff --git a/src/openrct2/actions/SurfaceSetStyleAction.hpp b/src/openrct2/actions/SurfaceSetStyleAction.hpp index bd2bd1bad0..d4e0547a25 100644 --- a/src/openrct2/actions/SurfaceSetStyleAction.hpp +++ b/src/openrct2/actions/SurfaceSetStyleAction.hpp @@ -20,7 +20,7 @@ #include "../world/TileElement.h" #include "GameAction.h" -DEFINE_GAME_ACTION(SurfaceSetStyleAction, GAME_COMMAND_CHANGE_SURFACE_STYLE, GameActionResult) +DEFINE_GAME_ACTION(SurfaceSetStyleAction, GAME_COMMAND_CHANGE_SURFACE_STYLE, GameActions::Result) { private: MapRange _range; @@ -44,7 +44,7 @@ public: stream << DS_TAG(_range) << DS_TAG(_surfaceStyle) << DS_TAG(_edgeStyle); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto res = MakeResult(); res->ErrorTitle = STR_CANT_CHANGE_LAND_TYPE; @@ -64,7 +64,7 @@ public: if (_surfaceStyle > 0x1F) { log_error("Invalid surface style."); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_LAND_TYPE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_LAND_TYPE); } const auto surfaceObj = static_cast( @@ -73,7 +73,7 @@ public: if (surfaceObj == nullptr) { log_error("Invalid surface style."); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_LAND_TYPE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_LAND_TYPE); } } @@ -82,7 +82,7 @@ public: if (_edgeStyle > 0xF) { log_error("Invalid edge style."); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_LAND_TYPE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_LAND_TYPE); } const auto edgeObj = static_cast( @@ -91,7 +91,7 @@ public: if (edgeObj == nullptr) { log_error("Invalid edge style."); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_LAND_TYPE); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_LAND_TYPE); } } @@ -107,7 +107,7 @@ public: if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && (gParkFlags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES)) { - return MakeResult(GA_ERROR::DISALLOWED, STR_CANT_CHANGE_LAND_TYPE, STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY); + return MakeResult(GameActions::Status::Disallowed, STR_CANT_CHANGE_LAND_TYPE, STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY); } money32 surfaceCost = 0; @@ -163,7 +163,7 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto res = MakeResult(); res->ErrorTitle = STR_CANT_CHANGE_LAND_TYPE; diff --git a/src/openrct2/actions/TileModifyAction.hpp b/src/openrct2/actions/TileModifyAction.hpp index 8d98455a37..26f0e9ec07 100644 --- a/src/openrct2/actions/TileModifyAction.hpp +++ b/src/openrct2/actions/TileModifyAction.hpp @@ -42,7 +42,7 @@ enum class TileModifyType : uint8_t Count, }; -DEFINE_GAME_ACTION(TileModifyAction, GAME_COMMAND_MODIFY_TILE, GameActionResult) +DEFINE_GAME_ACTION(TileModifyAction, GAME_COMMAND_MODIFY_TILE, GameActions::Result) { private: CoordsXY _loc; @@ -65,7 +65,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -75,22 +75,22 @@ public: stream << DS_TAG(_loc) << DS_TAG(_setting) << DS_TAG(_value1) << DS_TAG(_value2) << DS_TAG(_pasteElement); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr QueryExecute(bool isExecuting) const + GameActions::Result::Ptr QueryExecute(bool isExecuting) const { if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::InvalidParameters, STR_LAND_NOT_OWNED_BY_PARK); } auto res = MakeResult(); switch (_setting) @@ -259,7 +259,7 @@ private: } default: log_error("invalid instruction"); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); break; } diff --git a/src/openrct2/actions/TrackDesignAction.cpp b/src/openrct2/actions/TrackDesignAction.cpp index 9bcfeefcdd..a55cf8681b 100644 --- a/src/openrct2/actions/TrackDesignAction.cpp +++ b/src/openrct2/actions/TrackDesignAction.cpp @@ -27,7 +27,7 @@ static int32_t place_virtual_track( return place_virtual_track(const_cast(&td6), ptdOperation, placeScenery, ride, loc); } -GameActionResult::Ptr TrackDesignAction::Query() const +GameActions::Result::Ptr TrackDesignAction::Query() const { auto res = MakeResult(); res->Position.x = _loc.x + 16; @@ -38,7 +38,7 @@ GameActionResult::Ptr TrackDesignAction::Query() const if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS); + return MakeResult(GameActions::Status::InvalidParameters); } const rct_object_entry* rideEntryObject = &_td.vehicle_object; @@ -61,16 +61,16 @@ GameActionResult::Ptr TrackDesignAction::Query() const auto r = GameActions::ExecuteNested(&rideCreateAction); auto rideIndex = static_cast(r.get())->rideIndex; - if (r->Error != GA_ERROR::OK) + if (r->Error != GameActions::Status::Ok) { - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_NONE); + return MakeResult(GameActions::Status::NoFreeElements, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_NONE); } auto ride = get_ride(rideIndex); if (ride == nullptr) { log_warning("Invalid game command for track placement, ride id = %d", rideIndex); - return MakeResult(GA_ERROR::UNKNOWN); + return MakeResult(GameActions::Status::Unknown); } money32 cost = 0; @@ -90,13 +90,13 @@ GameActionResult::Ptr TrackDesignAction::Query() const GameActions::ExecuteNested(&gameAction); if (cost == MONEY32_UNDEFINED) { - return MakeResult(GA_ERROR::DISALLOWED, error_reason); + return MakeResult(GameActions::Status::Disallowed, error_reason); } res->Cost = cost; return res; } -GameActionResult::Ptr TrackDesignAction::Execute() const +GameActions::Result::Ptr TrackDesignAction::Execute() const { auto res = MakeResult(); res->Position.x = _loc.x + 16; @@ -124,16 +124,16 @@ GameActionResult::Ptr TrackDesignAction::Execute() const auto r = GameActions::ExecuteNested(&rideCreateAction); auto rideIndex = static_cast(r.get())->rideIndex; - if (r->Error != GA_ERROR::OK) + if (r->Error != GameActions::Status::Ok) { - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_NONE); + return MakeResult(GameActions::Status::NoFreeElements, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_NONE); } auto ride = get_ride(rideIndex); if (ride == nullptr) { log_warning("Invalid game command for track placement, ride id = %d", rideIndex); - return MakeResult(GA_ERROR::UNKNOWN); + return MakeResult(GameActions::Status::Unknown); } money32 cost = 0; @@ -171,7 +171,7 @@ GameActionResult::Ptr TrackDesignAction::Execute() const gameAction.SetFlags(GetFlags()); GameActions::ExecuteNested(&gameAction); - return MakeResult(GA_ERROR::DISALLOWED, error_reason); + return MakeResult(GameActions::Status::Disallowed, error_reason); } if (entryIndex != 0xFF) @@ -221,7 +221,7 @@ GameActionResult::Ptr TrackDesignAction::Execute() const ride->vehicle_colours[i].Ternary = _td.vehicle_additional_colour[i]; } - for (int32_t count = 1; count == 1 || r->Error != GA_ERROR::OK; ++count) + for (int32_t count = 1; count == 1 || r->Error != GameActions::Status::Ok; ++count) { auto name = count == 1 ? _td.name : (_td.name + " " + std::to_string(count)); auto gameAction = RideSetNameAction(ride->id, name); diff --git a/src/openrct2/actions/TrackDesignAction.h b/src/openrct2/actions/TrackDesignAction.h index a5efc102d3..3adf06b7f4 100644 --- a/src/openrct2/actions/TrackDesignAction.h +++ b/src/openrct2/actions/TrackDesignAction.h @@ -12,23 +12,23 @@ #include "../ride/TrackDesign.h" #include "GameAction.h" -class TrackDesignActionResult final : public GameActionResult +class TrackDesignActionResult final : public GameActions::Result { public: TrackDesignActionResult() - : GameActionResult(GA_ERROR::OK, STR_NONE) + : GameActions::Result(GameActions::Status::Ok, STR_NONE) { } - TrackDesignActionResult(GA_ERROR error) - : GameActionResult(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE) + TrackDesignActionResult(GameActions::Status error) + : GameActions::Result(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE) { } - TrackDesignActionResult(GA_ERROR error, rct_string_id title, rct_string_id message) - : GameActionResult(error, title, message) + TrackDesignActionResult(GameActions::Status error, rct_string_id title, rct_string_id message) + : GameActions::Result(error, title, message) { } - TrackDesignActionResult(GA_ERROR error, rct_string_id message) - : GameActionResult(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, message) + TrackDesignActionResult(GameActions::Status error, rct_string_id message) + : GameActions::Result(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, message) { } @@ -69,6 +69,6 @@ public: _td.Serialise(stream); } - GameActionResult::Ptr Query() const override; - GameActionResult::Ptr Execute() const override; + GameActions::Result::Ptr Query() const override; + GameActions::Result::Ptr Execute() const override; }; diff --git a/src/openrct2/actions/TrackPlaceAction.hpp b/src/openrct2/actions/TrackPlaceAction.hpp index fcd2d11156..a419d83d8e 100644 --- a/src/openrct2/actions/TrackPlaceAction.hpp +++ b/src/openrct2/actions/TrackPlaceAction.hpp @@ -19,23 +19,23 @@ #include "../world/Surface.h" #include "GameAction.h" -class TrackPlaceActionResult final : public GameActionResult +class TrackPlaceActionResult final : public GameActions::Result { public: TrackPlaceActionResult() - : GameActionResult(GA_ERROR::OK, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE) + : GameActions::Result(GameActions::Status::Ok, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE) { } - TrackPlaceActionResult(GA_ERROR error) - : GameActionResult(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE) + TrackPlaceActionResult(GameActions::Status error) + : GameActions::Result(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE) { } - TrackPlaceActionResult(GA_ERROR error, rct_string_id message) - : GameActionResult(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, message) + TrackPlaceActionResult(GameActions::Status error, rct_string_id message) + : GameActions::Result(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, message) { } - TrackPlaceActionResult(GA_ERROR error, rct_string_id message, uint8_t* args) - : GameActionResult(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, message, args) + TrackPlaceActionResult(GameActions::Status error, rct_string_id message, uint8_t* args) + : GameActions::Result(error, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, message, args) { } @@ -96,25 +96,25 @@ public: << DS_TAG(_seatRotation) << DS_TAG(_trackPlaceFlags); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid ride for track placement, rideIndex = %d", static_cast(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); if (rideEntry == nullptr) { log_warning("Invalid ride subtype for track placement, rideIndex = %d", static_cast(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } if (!direction_valid(_origin.direction)) { log_warning("Invalid direction for track placement, direction = %d", _origin.direction); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } auto res = std::make_unique(); @@ -129,15 +129,15 @@ public: if ((ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) && _trackType == TrackElemType::EndStation) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_NOT_ALLOWED_TO_MODIFY_STATION); + return std::make_unique(GameActions::Status::Disallowed, STR_NOT_ALLOWED_TO_MODIFY_STATION); } - if (!(GetActionFlags() & GA_FLAGS::ALLOW_WHILE_PAUSED)) + if (!(GetActionFlags() & GameActions::Flags::AllowWhilePaused)) { if (game_is_paused() && !gCheatsBuildInPauseMode) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED); + GameActions::Status::Disallowed, STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED); } } @@ -147,7 +147,8 @@ public: { if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_ONLY_ONE_ON_RIDE_PHOTO_PER_RIDE); + return std::make_unique( + GameActions::Status::Disallowed, STR_ONLY_ONE_ON_RIDE_PHOTO_PER_RIDE); } } else if (_trackType == TrackElemType::CableLiftHill) @@ -155,7 +156,7 @@ public: if (ride->lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_ONLY_ONE_CABLE_LIFT_HILL_PER_RIDE); + GameActions::Status::Disallowed, STR_ONLY_ONE_CABLE_LIFT_HILL_PER_RIDE); } } // Backwards steep lift hills are allowed, even on roller coasters that do not support forwards steep lift hills. @@ -165,7 +166,8 @@ public: { if (TrackFlags[_trackType] & TRACK_ELEM_FLAG_IS_STEEP_UP) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_TOO_STEEP_FOR_LIFT_HILL); + return std::make_unique( + GameActions::Status::Disallowed, STR_TOO_STEEP_FOR_LIFT_HILL); } } } @@ -181,7 +183,7 @@ public: if (!LocationValid(tileCoords) || (!map_is_location_owned(tileCoords) && !gCheatsSandboxMode)) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK); + return std::make_unique(GameActions::Status::Disallowed, STR_LAND_NOT_OWNED_BY_PARK); } numElements++; } @@ -189,7 +191,8 @@ public: if (!map_check_free_elements_and_reorganise(numElements)) { log_warning("Not enough free map elments to place track."); - return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS, STR_TILE_ELEMENT_LIMIT_REACHED); + return std::make_unique( + GameActions::Status::NoFreeElements, STR_TILE_ELEMENT_LIMIT_REACHED); } const uint16_t* trackFlags = (rideTypeFlags & RIDE_TYPE_FLAG_FLAT_RIDE) ? FlatTrackFlags : TrackFlags; if (!gCheatsAllowTrackPlaceInvalidHeights) @@ -198,14 +201,16 @@ public: { if ((_origin.z & 0x0F) != 8) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CONSTRUCTION_ERR_UNKNOWN); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CONSTRUCTION_ERR_UNKNOWN); } } else { if ((_origin.z & 0x0F) != 0) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CONSTRUCTION_ERR_UNKNOWN); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CONSTRUCTION_ERR_UNKNOWN); } } } @@ -221,7 +226,7 @@ public: if (mapLoc.z < 16) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_TOO_LOW); + return std::make_unique(GameActions::Status::InvalidParameters, STR_TOO_LOW); } int32_t baseZ = floor2(mapLoc.z, COORDS_Z_STEP); @@ -241,7 +246,7 @@ public: if (clearanceZ > MAX_TRACK_HEIGHT) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_TOO_HIGH); + return std::make_unique(GameActions::Status::InvalidParameters, STR_TOO_HIGH); } uint8_t crossingMode = (RideTypeDescriptors[ride->type].HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS) @@ -253,7 +258,7 @@ public: crossingMode)) { return std::make_unique( - GA_ERROR::NO_CLEARANCE, gGameCommandErrorText, gCommonFormatArgs); + GameActions::Status::NoClearance, gGameCommandErrorText, gCommonFormatArgs); } // When building a level crossing, remove any pre-existing path furniture. @@ -270,7 +275,7 @@ public: if (res->GroundFlags != 0 && (res->GroundFlags & mapGroundFlags) == 0) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND); + GameActions::Status::Disallowed, STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND); } res->GroundFlags = mapGroundFlags; @@ -281,7 +286,7 @@ public: if (res->GroundFlags & ELEMENT_IS_UNDERGROUND) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); } } } @@ -292,7 +297,7 @@ public: if (res->GroundFlags & ELEMENT_IS_UNDERGROUND) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); } } } @@ -304,7 +309,7 @@ public: if (!(gMapGroundFlags & ELEMENT_IS_UNDERWATER)) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_UNDERWATER); + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_UNDERWATER); } } } @@ -315,31 +320,34 @@ public: if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_UNDERWATER); + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_UNDERWATER); } } } if (gMapGroundFlags & ELEMENT_IS_UNDERWATER && !gCheatsDisableClearanceChecks) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_RIDE_CANT_BUILD_THIS_UNDERWATER); + return std::make_unique( + GameActions::Status::Disallowed, STR_RIDE_CANT_BUILD_THIS_UNDERWATER); } if ((rideTypeFlags & RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER) && !byte_9D8150) { auto surfaceElement = map_get_surface_element_at(mapLoc); if (surfaceElement == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); auto waterHeight = surfaceElement->GetWaterHeight(); if (waterHeight == 0) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ON_WATER); + return std::make_unique( + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ON_WATER); } if (waterHeight != baseZ) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ON_WATER); + return std::make_unique( + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ON_WATER); } waterHeight -= LAND_HEIGHT_STEP; if (waterHeight == surfaceElement->GetBaseZ()) @@ -348,7 +356,8 @@ public: if (slope == TILE_ELEMENT_SLOPE_W_CORNER_DN || slope == TILE_ELEMENT_SLOPE_S_CORNER_DN || slope == TILE_ELEMENT_SLOPE_E_CORNER_DN || slope == TILE_ELEMENT_SLOPE_N_CORNER_DN) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ON_WATER); + return std::make_unique( + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ON_WATER); } } } @@ -366,14 +375,14 @@ public: { if (!track_add_station_element({ mapLoc, baseZ, _origin.direction }, _rideIndex, 0, _fromTrackDesign)) { - return std::make_unique(GA_ERROR::UNKNOWN, gGameCommandErrorText); + return std::make_unique(GameActions::Status::Unknown, gGameCommandErrorText); } } // 6c5648 12 push auto surfaceElement = map_get_surface_element_at(mapLoc); if (surfaceElement == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (!gCheatsDisableSupportLimits) { @@ -395,7 +404,8 @@ public: ride_height /= COORDS_Z_PER_TINY_Z; if (ride_height > maxHeight && !byte_9D8150) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_TOO_HIGH_FOR_SUPPORTS); + return std::make_unique( + GameActions::Status::Disallowed, STR_TOO_HIGH_FOR_SUPPORTS); } } } @@ -417,20 +427,20 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto ride = get_ride(_rideIndex); if (ride == nullptr) { log_warning("Invalid ride for track placement, rideIndex = %d", static_cast(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); if (rideEntry == nullptr) { log_warning("Invalid ride subtype for track placement, rideIndex = %d", static_cast(_rideIndex)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } auto res = std::make_unique(); @@ -488,7 +498,7 @@ public: &cost, crossingMode)) { return std::make_unique( - GA_ERROR::NO_CLEARANCE, gGameCommandErrorText, gCommonFormatArgs); + GameActions::Status::NoClearance, gGameCommandErrorText, gCommonFormatArgs); } if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && !gCheatsDisableClearanceChecks) @@ -518,7 +528,7 @@ public: if (res->GroundFlags != 0 && (res->GroundFlags & mapGroundFlags) == 0) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND); + GameActions::Status::Disallowed, STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND); } res->GroundFlags = mapGroundFlags; @@ -526,7 +536,7 @@ public: // 6c5648 12 push auto surfaceElement = map_get_surface_element_at(mapLoc); if (surfaceElement == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); int32_t supportHeight = baseZ - surfaceElement->GetBaseZ(); if (supportHeight < 0) diff --git a/src/openrct2/actions/TrackRemoveAction.hpp b/src/openrct2/actions/TrackRemoveAction.hpp index 054739b6c4..38e4d163a2 100644 --- a/src/openrct2/actions/TrackRemoveAction.hpp +++ b/src/openrct2/actions/TrackRemoveAction.hpp @@ -19,7 +19,7 @@ #include "../world/Surface.h" #include "GameAction.h" -DEFINE_GAME_ACTION(TrackRemoveAction, GAME_COMMAND_REMOVE_TRACK, GameActionResult) +DEFINE_GAME_ACTION(TrackRemoveAction, GAME_COMMAND_REMOVE_TRACK, GameActions::Result) { private: int32_t _trackType{}; @@ -55,7 +55,7 @@ public: stream << DS_TAG(_trackType) << DS_TAG(_sequence) << DS_TAG(_origin); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto res = MakeResult(); res->Position.x = _origin.x + 16; @@ -118,13 +118,14 @@ public: log_warning( "Track Element not found. x = %d, y = %d, z = %d, d = %d, seq = %d.", _origin.x, _origin.y, _origin.z, _origin.direction, _sequence); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); } if (tileElement->AsTrack()->IsIndestructible()) { return MakeResult( - GA_ERROR::DISALLOWED, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, STR_YOU_ARE_NOT_ALLOWED_TO_REMOVE_THIS_SECTION); + GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, + STR_YOU_ARE_NOT_ALLOWED_TO_REMOVE_THIS_SECTION); } ride_id_t rideIndex = tileElement->AsTrack()->GetRideIndex(); @@ -134,7 +135,7 @@ public: if (ride == nullptr) { log_warning("Ride not found. ride index = %d.", rideIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); } const rct_preview_track* trackBlock = get_track_def_from_ride(ride, trackType); trackBlock += tileElement->AsTrack()->GetSequenceIndex(); @@ -160,7 +161,8 @@ public: if (!LocationValid(mapLoc)) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult( + GameActions::Status::NotOwned, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } map_invalidate_tile_full(mapLoc); @@ -198,7 +200,7 @@ public: log_warning( "Track Element not found. x = %d, y = %d, z = %d, d = %d, seq = %d.", mapLoc.x, mapLoc.y, mapLoc.z, _origin.direction, trackBlock->index); - return MakeResult(GA_ERROR::UNKNOWN, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); } int32_t entranceDirections; @@ -215,7 +217,8 @@ public: { if (!track_remove_station_element({ mapLoc, _origin.direction }, rideIndex, 0)) { - return MakeResult(GA_ERROR::UNKNOWN, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, gGameCommandErrorText); + return MakeResult( + GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, gGameCommandErrorText); } } @@ -223,7 +226,7 @@ public: if (surfaceElement == nullptr) { log_warning("Surface Element not found. x = %d, y = %d", mapLoc.x, mapLoc.y); - return MakeResult(GA_ERROR::UNKNOWN, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); } int8_t _support_height = tileElement->base_height - surfaceElement->base_height; @@ -255,7 +258,7 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto res = MakeResult(); res->Position.x = _origin.x + 16; @@ -318,7 +321,7 @@ public: log_warning( "Track Element not found. x = %d, y = %d, z = %d, d = %d, seq = %d.", _origin.x, _origin.y, _origin.z, _origin.direction, _sequence); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); } ride_id_t rideIndex = tileElement->AsTrack()->GetRideIndex(); @@ -329,7 +332,7 @@ public: if (ride == nullptr) { log_warning("Ride not found. ride index = %d.", rideIndex); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); } const rct_preview_track* trackBlock = get_track_def_from_ride(ride, trackType); trackBlock += tileElement->AsTrack()->GetSequenceIndex(); @@ -388,7 +391,7 @@ public: log_warning( "Track Element not found. x = %d, y = %d, z = %d, d = %d, seq = %d.", mapLoc.x, mapLoc.y, mapLoc.z, _origin.direction, trackBlock->index); - return MakeResult(GA_ERROR::UNKNOWN, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); } int32_t entranceDirections; @@ -405,7 +408,8 @@ public: { if (!track_remove_station_element({ mapLoc, _origin.direction }, rideIndex, 0)) { - return MakeResult(GA_ERROR::UNKNOWN, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, gGameCommandErrorText); + return MakeResult( + GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, gGameCommandErrorText); } } @@ -413,7 +417,7 @@ public: if (surfaceElement == nullptr) { log_warning("Surface Element not found. x = %d, y = %d", mapLoc.x, mapLoc.y); - return MakeResult(GA_ERROR::UNKNOWN, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); + return MakeResult(GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS); } int8_t _support_height = tileElement->base_height - surfaceElement->base_height; @@ -428,7 +432,8 @@ public: { if (!track_remove_station_element({ mapLoc, _origin.direction }, rideIndex, GAME_COMMAND_FLAG_APPLY)) { - return MakeResult(GA_ERROR::UNKNOWN, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, gGameCommandErrorText); + return MakeResult( + GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, gGameCommandErrorText); } } diff --git a/src/openrct2/actions/TrackSetBrakeSpeedAction.hpp b/src/openrct2/actions/TrackSetBrakeSpeedAction.hpp index 248ebd93fa..bd7dbe7d3f 100644 --- a/src/openrct2/actions/TrackSetBrakeSpeedAction.hpp +++ b/src/openrct2/actions/TrackSetBrakeSpeedAction.hpp @@ -12,7 +12,7 @@ #include "../management/Finance.h" #include "GameAction.h" -DEFINE_GAME_ACTION(TrackSetBrakeSpeedAction, GAME_COMMAND_SET_BRAKES_SPEED, GameActionResult) +DEFINE_GAME_ACTION(TrackSetBrakeSpeedAction, GAME_COMMAND_SET_BRAKES_SPEED, GameActions::Result) { private: CoordsXYZ _loc; @@ -37,7 +37,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -46,18 +46,18 @@ public: stream << DS_TAG(_loc) << DS_TAG(_trackType) << DS_TAG(_brakeSpeed); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr QueryExecute(bool isExecuting) const + GameActions::Result::Ptr QueryExecute(bool isExecuting) const { auto res = MakeResult(); @@ -68,14 +68,14 @@ private: if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_NONE); + return MakeResult(GameActions::Status::NotOwned, STR_NONE); } TileElement* tileElement = map_get_track_element_at_of_type(_loc, _trackType); if (tileElement == nullptr) { log_warning("Invalid game command for setting brakes speed. x = %d, y = %d", _loc.x, _loc.y); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE); } if (isExecuting) diff --git a/src/openrct2/actions/WallPlaceAction.hpp b/src/openrct2/actions/WallPlaceAction.hpp index 83705cc5e2..33b01f3bd8 100644 --- a/src/openrct2/actions/WallPlaceAction.hpp +++ b/src/openrct2/actions/WallPlaceAction.hpp @@ -24,26 +24,26 @@ #include "../world/Wall.h" #include "GameAction.h" -class WallPlaceActionResult final : public GameActionResult +class WallPlaceActionResult final : public GameActions::Result { public: WallPlaceActionResult() - : GameActionResult(GA_ERROR::OK, STR_CANT_BUILD_PARK_ENTRANCE_HERE) + : GameActions::Result(GameActions::Status::Ok, STR_CANT_BUILD_PARK_ENTRANCE_HERE) { } - WallPlaceActionResult(GA_ERROR err) - : GameActionResult(err, STR_CANT_BUILD_PARK_ENTRANCE_HERE) + WallPlaceActionResult(GameActions::Status err) + : GameActions::Result(err, STR_CANT_BUILD_PARK_ENTRANCE_HERE) { } - WallPlaceActionResult(GA_ERROR err, rct_string_id msg) - : GameActionResult(err, STR_CANT_BUILD_PARK_ENTRANCE_HERE, msg) + WallPlaceActionResult(GameActions::Status err, rct_string_id msg) + : GameActions::Result(err, STR_CANT_BUILD_PARK_ENTRANCE_HERE, msg) { } - WallPlaceActionResult(GA_ERROR error, rct_string_id msg, uint8_t* args) - : GameActionResult(error, STR_CANT_BUILD_PARK_ENTRANCE_HERE, msg, args) + WallPlaceActionResult(GameActions::Status error, rct_string_id msg, uint8_t* args) + : GameActions::Result(error, STR_CANT_BUILD_PARK_ENTRANCE_HERE, msg, args) { } @@ -114,7 +114,7 @@ public: << DS_TAG(_tertiaryColour) << DS_TAG(_bannerId); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto res = std::make_unique(); res->ErrorTitle = STR_CANT_BUILD_PARK_ENTRANCE_HERE; @@ -131,7 +131,7 @@ public: if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::NOT_OWNED); + return MakeResult(GameActions::Status::NotOwned); } if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !(GetFlags() & GAME_COMMAND_FLAG_PATH_SCENERY) @@ -141,23 +141,23 @@ public: { if (!map_is_location_in_park(_loc)) { - return std::make_unique(GA_ERROR::NOT_OWNED); + return std::make_unique(GameActions::Status::NotOwned); } } else if (!map_is_location_owned(_loc)) { - return std::make_unique(GA_ERROR::NOT_OWNED); + return std::make_unique(GameActions::Status::NotOwned); } } else if (!byte_9D8150 && (_loc.x > gMapSizeMaxXY || _loc.y > gMapSizeMaxXY)) { log_error("Invalid x/y coordinates. x = %d y = %d", _loc.x, _loc.y); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } if (_edge > 3) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } uint8_t edgeSlope = 0; @@ -168,7 +168,7 @@ public: if (surfaceElement == nullptr) { log_error("Surface element not found at %d, %d.", _loc.x, _loc.y); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } targetHeight = surfaceElement->GetBaseZ(); @@ -185,7 +185,7 @@ public: if (surfaceElement == nullptr) { log_error("Surface element not found at %d, %d.", _loc.x, _loc.y); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } if (surfaceElement->GetWaterHeight() > 0) @@ -194,13 +194,14 @@ public: if (targetHeight < waterHeight && !gCheatsDisableClearanceChecks) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CANT_BUILD_THIS_UNDERWATER); + return std::make_unique(GameActions::Status::Disallowed, STR_CANT_BUILD_THIS_UNDERWATER); } } if (targetHeight < surfaceElement->GetBaseZ() && !gCheatsDisableClearanceChecks) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); + return std::make_unique( + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); } if (!(edgeSlope & (EDGE_SLOPE_UPWARDS | EDGE_SLOPE_DOWNWARDS))) @@ -212,7 +213,8 @@ public: { if (targetHeight / 8 < newBaseHeight) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); + return std::make_unique( + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); } if (surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT) @@ -228,7 +230,7 @@ public: if (targetHeight / 8 < newBaseHeight) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); } newBaseHeight -= 2; } @@ -241,7 +243,8 @@ public: { if (targetHeight / 8 < newBaseHeight) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); + return std::make_unique( + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); } if (surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT) @@ -257,7 +260,7 @@ public: if (targetHeight / 8 < newBaseHeight) { return std::make_unique( - GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); + GameActions::Status::Disallowed, STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND); } } } @@ -270,7 +273,7 @@ public: if (wallEntry == nullptr) { log_error("Wall Type not found %d", _wallType); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } if (wallEntry->wall.scrolling_mode != SCROLLING_MODE_NONE) @@ -278,14 +281,15 @@ public: if (_bannerId == BANNER_INDEX_NULL) { log_error("Banner Index not specified."); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_TOO_MANY_BANNERS_IN_GAME); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_TOO_MANY_BANNERS_IN_GAME); } auto banner = GetBanner(_bannerId); if (!banner->IsNull()) { log_error("No free banners available"); - return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS); + return std::make_unique(GameActions::Status::NoFreeElements); } } @@ -294,7 +298,8 @@ public: { if (wallEntry->wall.flags & WALL_SCENERY_CANT_BUILD_ON_SLOPE) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_ERR_UNABLE_TO_BUILD_THIS_ON_SLOPE); + return std::make_unique( + GameActions::Status::Disallowed, STR_ERR_UNABLE_TO_BUILD_THIS_ON_SLOPE); } clearanceHeight += 2; } @@ -304,7 +309,7 @@ public: if (!(GetFlags() & GAME_COMMAND_FLAG_PATH_SCENERY) && !gCheatsDisableClearanceChecks) { auto result = WallCheckObstruction(wallEntry, targetHeight / 8, clearanceHeight, &wallAcrossTrack); - if (result->Error != GA_ERROR::OK) + if (result->Error != GameActions::Status::Ok) { return result; } @@ -312,14 +317,14 @@ public: if (!map_check_free_elements_and_reorganise(1)) { - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_TILE_ELEMENT_LIMIT_REACHED); + return MakeResult(GameActions::Status::NoFreeElements, STR_TILE_ELEMENT_LIMIT_REACHED); } res->Cost = wallEntry->wall.price; return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto res = std::make_unique(); res->ErrorTitle = STR_CANT_BUILD_PARK_ENTRANCE_HERE; @@ -342,7 +347,7 @@ public: if (surfaceElement == nullptr) { log_error("Surface element not found at %d, %d.", _loc.x, _loc.y); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } targetHeight = surfaceElement->GetBaseZ(); @@ -361,7 +366,7 @@ public: if (wallEntry == nullptr) { log_error("Wall Type not found %d", _wallType); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS); + return std::make_unique(GameActions::Status::InvalidParameters); } uint8_t clearanceHeight = targetHeight / COORDS_Z_STEP; @@ -375,7 +380,7 @@ public: if (!(GetFlags() & GAME_COMMAND_FLAG_PATH_SCENERY) && !gCheatsDisableClearanceChecks) { auto result = WallCheckObstruction(wallEntry, targetHeight / COORDS_Z_STEP, clearanceHeight, &wallAcrossTrack); - if (result->Error != GA_ERROR::OK) + if (result->Error != GameActions::Status::Ok) { return result; } @@ -383,7 +388,7 @@ public: if (!map_check_free_elements_and_reorganise(1)) { - return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_TILE_ELEMENT_LIMIT_REACHED); + return MakeResult(GameActions::Status::NoFreeElements, STR_TILE_ELEMENT_LIMIT_REACHED); } if (wallEntry->wall.scrolling_mode != SCROLLING_MODE_NONE) @@ -391,14 +396,15 @@ public: if (_bannerId == BANNER_INDEX_NULL) { log_error("Banner Index not specified."); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_TOO_MANY_BANNERS_IN_GAME); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_TOO_MANY_BANNERS_IN_GAME); } auto banner = GetBanner(_bannerId); if (!banner->IsNull()) { log_error("No free banners available"); - return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS); + return std::make_unique(GameActions::Status::NoFreeElements); } banner->text = {}; @@ -556,7 +562,7 @@ private: * * rct2: 0x006E5C1A */ - GameActionResult::Ptr WallCheckObstruction(rct_scenery_entry * wall, int32_t z0, int32_t z1, bool* wallAcrossTrack) const + GameActions::Result::Ptr WallCheckObstruction(rct_scenery_entry * wall, int32_t z0, int32_t z1, bool* wallAcrossTrack) const { int32_t entryType, sequence; rct_scenery_entry* entry; @@ -566,7 +572,7 @@ private: gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND; if (map_is_location_at_edge(_loc)) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_OFF_EDGE_OF_MAP); + return MakeResult(GameActions::Status::InvalidParameters, STR_OFF_EDGE_OF_MAP); } TileElement* tileElement = map_get_first_element_at(_loc); @@ -588,7 +594,7 @@ private: int32_t direction = tileElement->GetDirection(); if (_edge == direction) { - auto res = MakeResult(GA_ERROR::NO_CLEARANCE, STR_NONE); + auto res = MakeResult(GameActions::Status::NoClearance, STR_NONE); map_obstruction_set_error_text(tileElement, *res); return res; } @@ -596,7 +602,7 @@ private: } if (tileElement->GetOccupiedQuadrants() == 0) continue; - auto res = MakeResult(GA_ERROR::NO_CLEARANCE, STR_NONE); + auto res = MakeResult(GameActions::Status::NoClearance, STR_NONE); switch (elementType) { case TILE_ELEMENT_TYPE_ENTRANCE: diff --git a/src/openrct2/actions/WallRemoveAction.hpp b/src/openrct2/actions/WallRemoveAction.hpp index 70629ac311..79227447b4 100644 --- a/src/openrct2/actions/WallRemoveAction.hpp +++ b/src/openrct2/actions/WallRemoveAction.hpp @@ -19,7 +19,7 @@ #include "../world/Wall.h" #include "GameAction.h" -DEFINE_GAME_ACTION(WallRemoveAction, GAME_COMMAND_REMOVE_WALL, GameActionResult) +DEFINE_GAME_ACTION(WallRemoveAction, GAME_COMMAND_REMOVE_WALL, GameActions::Result) { private: CoordsXYZD _loc; @@ -43,38 +43,39 @@ public: stream << DS_TAG(_loc); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); res->Cost = 0; res->Expenditure = ExpenditureType::Landscaping; if (!LocationValid(_loc)) { - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); } const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST; if (!isGhost && !(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(_loc)) { - return std::make_unique(GA_ERROR::NOT_OWNED, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return std::make_unique( + GameActions::Status::NotOwned, STR_CANT_REMOVE_THIS, STR_LAND_NOT_OWNED_BY_PARK); } TileElement* wallElement = GetFirstWallElementAt(_loc, isGhost); if (wallElement == nullptr) { - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); } res->Cost = 0; return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { - GameActionResult::Ptr res = std::make_unique(); + GameActions::Result::Ptr res = std::make_unique(); res->Cost = 0; res->Expenditure = ExpenditureType::Landscaping; @@ -83,8 +84,8 @@ public: TileElement* wallElement = GetFirstWallElementAt(_loc, isGhost); if (wallElement == nullptr) { - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_INVALID_SELECTION_OF_OBJECTS); } res->Position.x = _loc.x + 16; diff --git a/src/openrct2/actions/WallSetColourAction.hpp b/src/openrct2/actions/WallSetColourAction.hpp index c72e6db8bc..99e91cc6c0 100644 --- a/src/openrct2/actions/WallSetColourAction.hpp +++ b/src/openrct2/actions/WallSetColourAction.hpp @@ -21,7 +21,7 @@ #include "../world/Surface.h" #include "GameAction.h" -DEFINE_GAME_ACTION(WallSetColourAction, GAME_COMMAND_SET_WALL_COLOUR, GameActionResult) +DEFINE_GAME_ACTION(WallSetColourAction, GAME_COMMAND_SET_WALL_COLOUR, GameActions::Result) { private: CoordsXYZD _loc; @@ -42,7 +42,7 @@ public: uint16_t GetActionFlags() const override { - return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + return GameAction::GetActionFlags() | GameActions::Flags::AllowWhilePaused; } void Serialise(DataSerialiser & stream) override @@ -52,7 +52,7 @@ public: stream << DS_TAG(_loc) << DS_TAG(_primaryColour) << DS_TAG(_secondaryColour) << DS_TAG(_tertiaryColour); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto res = MakeResult(); res->ErrorTitle = STR_CANT_REPAINT_THIS; @@ -64,12 +64,12 @@ public: if (!LocationValid(_loc)) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NotOwned, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); } if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_in_park(_loc) && !gCheatsSandboxMode) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NotOwned, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK); } auto wallElement = map_get_wall_element_at(_loc); @@ -78,7 +78,7 @@ public: log_error( "Could not find wall element at: x = %d, y = %d, z = %d, direction = %u", _loc.x, _loc.y, _loc.z, _loc.direction); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && !(wallElement->IsGhost())) @@ -90,19 +90,19 @@ public: if (sceneryEntry == nullptr) { log_error("Could not find wall object"); - return MakeResult(GA_ERROR::UNKNOWN, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::Unknown, STR_CANT_REPAINT_THIS); } if (_primaryColour > 31) { log_error("Primary colour invalid: colour = %d", _primaryColour); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } if (_secondaryColour > 31) { log_error("Secondary colour invalid: colour = %d", _secondaryColour); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } if (sceneryEntry->wall.flags & WALL_SCENERY_HAS_TERNARY_COLOUR) @@ -110,13 +110,13 @@ public: if (_tertiaryColour > 31) { log_error("Tertiary colour invalid: colour = %d", _tertiaryColour); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } } return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto res = MakeResult(); res->ErrorTitle = STR_CANT_REPAINT_THIS; @@ -131,7 +131,7 @@ public: log_error( "Could not find wall element at: x = %d, y = %d, z = %d, direction = %u", _loc.x, _loc.y, _loc.z, _loc.direction); - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); } if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && !(wallElement->IsGhost())) @@ -143,7 +143,7 @@ public: if (sceneryEntry == nullptr) { log_error("Could not find wall object"); - return MakeResult(GA_ERROR::UNKNOWN, STR_CANT_REPAINT_THIS); + return MakeResult(GameActions::Status::Unknown, STR_CANT_REPAINT_THIS); } wallElement->SetPrimaryColour(_primaryColour); diff --git a/src/openrct2/actions/WaterLowerAction.hpp b/src/openrct2/actions/WaterLowerAction.hpp index c34cdab749..9591e90cba 100644 --- a/src/openrct2/actions/WaterLowerAction.hpp +++ b/src/openrct2/actions/WaterLowerAction.hpp @@ -12,7 +12,7 @@ #include "GameAction.h" #include "WaterSetHeightAction.hpp" -DEFINE_GAME_ACTION(WaterLowerAction, GAME_COMMAND_LOWER_WATER, GameActionResult) +DEFINE_GAME_ACTION(WaterLowerAction, GAME_COMMAND_LOWER_WATER, GameActions::Result) { private: MapRange _range; @@ -36,18 +36,18 @@ public: stream << DS_TAG(_range); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr QueryExecute(bool isExecuting) const + GameActions::Result::Ptr QueryExecute(bool isExecuting) const { auto res = MakeResult(); @@ -105,7 +105,7 @@ private: waterSetHeightAction.SetFlags(GetFlags()); auto result = isExecuting ? GameActions::ExecuteNested(&waterSetHeightAction) : GameActions::QueryNested(&waterSetHeightAction); - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { res->Cost += result->Cost; hasChanged = true; @@ -120,8 +120,8 @@ private: if (!withinOwnership) { - GameActionResult::Ptr ownerShipResult = std::make_unique( - GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK); + GameActions::Result::Ptr ownerShipResult = std::make_unique( + GameActions::Status::Disallowed, STR_LAND_NOT_OWNED_BY_PARK); ownerShipResult->ErrorTitle = STR_CANT_LOWER_WATER_LEVEL_HERE; return ownerShipResult; } diff --git a/src/openrct2/actions/WaterRaiseAction.hpp b/src/openrct2/actions/WaterRaiseAction.hpp index afb07bb73c..f18019bd24 100644 --- a/src/openrct2/actions/WaterRaiseAction.hpp +++ b/src/openrct2/actions/WaterRaiseAction.hpp @@ -13,7 +13,7 @@ #include "GameAction.h" #include "WaterSetHeightAction.hpp" -DEFINE_GAME_ACTION(WaterRaiseAction, GAME_COMMAND_RAISE_WATER, GameActionResult) +DEFINE_GAME_ACTION(WaterRaiseAction, GAME_COMMAND_RAISE_WATER, GameActions::Result) { private: MapRange _range; @@ -37,18 +37,18 @@ public: stream << DS_TAG(_range); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { return QueryExecute(false); } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { return QueryExecute(true); } private: - GameActionResult::Ptr QueryExecute(bool isExecuting) const + GameActions::Result::Ptr QueryExecute(bool isExecuting) const { auto res = MakeResult(); @@ -113,7 +113,7 @@ private: waterSetHeightAction.SetFlags(GetFlags()); auto result = isExecuting ? GameActions::ExecuteNested(&waterSetHeightAction) : GameActions::QueryNested(&waterSetHeightAction); - if (result->Error == GA_ERROR::OK) + if (result->Error == GameActions::Status::Ok) { res->Cost += result->Cost; hasChanged = true; @@ -128,8 +128,8 @@ private: if (!withinOwnership) { - GameActionResult::Ptr ownerShipResult = std::make_unique( - GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK); + GameActions::Result::Ptr ownerShipResult = std::make_unique( + GameActions::Status::Disallowed, STR_LAND_NOT_OWNED_BY_PARK); ownerShipResult->ErrorTitle = STR_CANT_RAISE_WATER_LEVEL_HERE; return ownerShipResult; } diff --git a/src/openrct2/actions/WaterSetHeightAction.hpp b/src/openrct2/actions/WaterSetHeightAction.hpp index bda4019663..423b4c372b 100644 --- a/src/openrct2/actions/WaterSetHeightAction.hpp +++ b/src/openrct2/actions/WaterSetHeightAction.hpp @@ -15,7 +15,7 @@ #include "../world/Surface.h" #include "GameAction.h" -DEFINE_GAME_ACTION(WaterSetHeightAction, GAME_COMMAND_SET_WATER_HEIGHT, GameActionResult) +DEFINE_GAME_ACTION(WaterSetHeightAction, GAME_COMMAND_SET_WATER_HEIGHT, GameActions::Result) { private: CoordsXY _coords; @@ -41,7 +41,7 @@ public: stream << DS_TAG(_coords) << DS_TAG(_height); } - GameActionResult::Ptr Query() const override + GameActions::Result::Ptr Query() const override { auto res = MakeResult(); res->Expenditure = ExpenditureType::Landscaping; @@ -50,25 +50,25 @@ public: if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && gParkFlags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES) { - return MakeResult(GA_ERROR::DISALLOWED, STR_NONE, STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY); + return MakeResult(GameActions::Status::Disallowed, STR_NONE, STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY); } rct_string_id errorMsg = CheckParameters(); if (errorMsg != STR_NONE) { - return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE, errorMsg); + return MakeResult(GameActions::Status::InvalidParameters, STR_NONE, errorMsg); } if (!LocationValid(_coords)) { - return MakeResult(GA_ERROR::NOT_OWNED, STR_NONE, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::NotOwned, STR_NONE, STR_LAND_NOT_OWNED_BY_PARK); } if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) { if (!map_is_location_in_park(_coords)) { - return MakeResult(GA_ERROR::DISALLOWED, STR_NONE, STR_LAND_NOT_OWNED_BY_PARK); + return MakeResult(GameActions::Status::Disallowed, STR_NONE, STR_LAND_NOT_OWNED_BY_PARK); } } @@ -76,7 +76,7 @@ public: if (surfaceElement == nullptr) { log_error("Could not find surface element at: x %u, y %u", _coords.x, _coords.y); - return MakeResult(GA_ERROR::UNKNOWN, STR_NONE); + return MakeResult(GameActions::Status::Unknown, STR_NONE); } int32_t zHigh = surfaceElement->GetBaseZ(); @@ -92,14 +92,14 @@ public: zLow = temp; } - if (auto res2 = MapCanConstructAt({ _coords, zLow, zHigh }, { 0b1111, 0b1111 }); res2->Error != GA_ERROR::OK) + if (auto res2 = MapCanConstructAt({ _coords, zLow, zHigh }, { 0b1111, 0b1111 }); res2->Error != GameActions::Status::Ok) { return MakeResult( - GA_ERROR::NO_CLEARANCE, STR_NONE, res2->ErrorMessage.GetStringId(), res2->ErrorMessageArgs.data()); + GameActions::Status::NoClearance, STR_NONE, res2->ErrorMessage.GetStringId(), res2->ErrorMessageArgs.data()); } if (surfaceElement->HasTrackThatNeedsWater()) { - return MakeResult(GA_ERROR::DISALLOWED, STR_NONE); + return MakeResult(GameActions::Status::Disallowed, STR_NONE); } res->Cost = 250; @@ -107,7 +107,7 @@ public: return res; } - GameActionResult::Ptr Execute() const override + GameActions::Result::Ptr Execute() const override { auto res = MakeResult(); res->Expenditure = ExpenditureType::Landscaping; @@ -122,7 +122,7 @@ public: if (surfaceElement == nullptr) { log_error("Could not find surface element at: x %u, y %u", _coords.x, _coords.y); - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); } if (_height > surfaceElement->base_height) diff --git a/src/openrct2/core/Http.h b/src/openrct2/core/Http.h index 969446a362..873d9b7e5e 100644 --- a/src/openrct2/core/Http.h +++ b/src/openrct2/core/Http.h @@ -22,7 +22,7 @@ namespace Http { enum class Status { - OK = 200, + Ok = 200, NotFound = 404 }; diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 2867bc345d..a2cb34741e 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -739,8 +739,8 @@ static int32_t cc_set(InteractiveConsole& console, const arguments_t& argv) if (gCash != money) { auto setCheatAction = SetCheatAction(CheatType::SetMoney, money); - setCheatAction.SetCallback([&console](const GameAction*, const GameActionResult* res) { - if (res->Error != GA_ERROR::OK) + setCheatAction.SetCallback([&console](const GameAction*, const GameActions::Result* res) { + if (res->Error != GameActions::Status::Ok) console.WriteLineError("Network error: Permission denied!"); else console.Execute("get money"); @@ -947,8 +947,8 @@ static int32_t cc_set(InteractiveConsole& console, const arguments_t& argv) if (gCheatsSandboxMode != (int_val[0] != 0)) { auto setCheatAction = SetCheatAction(CheatType::SandboxMode, int_val[0] != 0); - setCheatAction.SetCallback([&console](const GameAction*, const GameActionResult* res) { - if (res->Error != GA_ERROR::OK) + setCheatAction.SetCallback([&console](const GameAction*, const GameActions::Result* res) { + if (res->Error != GameActions::Status::Ok) console.WriteLineError("Network error: Permission denied!"); else console.Execute("get cheat_sandbox_mode"); @@ -965,8 +965,8 @@ static int32_t cc_set(InteractiveConsole& console, const arguments_t& argv) if (gCheatsDisableClearanceChecks != (int_val[0] != 0)) { auto setCheatAction = SetCheatAction(CheatType::DisableClearanceChecks, int_val[0] != 0); - setCheatAction.SetCallback([&console](const GameAction*, const GameActionResult* res) { - if (res->Error != GA_ERROR::OK) + setCheatAction.SetCallback([&console](const GameAction*, const GameActions::Result* res) { + if (res->Error != GameActions::Status::Ok) console.WriteLineError("Network error: Permission denied!"); else console.Execute("get cheat_disable_clearance_checks"); @@ -983,8 +983,8 @@ static int32_t cc_set(InteractiveConsole& console, const arguments_t& argv) if (gCheatsDisableSupportLimits != (int_val[0] != 0)) { auto setCheatAction = SetCheatAction(CheatType::DisableSupportLimits, int_val[0] != 0); - setCheatAction.SetCallback([&console](const GameAction*, const GameActionResult* res) { - if (res->Error != GA_ERROR::OK) + setCheatAction.SetCallback([&console](const GameAction*, const GameActions::Result* res) { + if (res->Error != GameActions::Status::Ok) console.WriteLineError("Network error: Permission denied!"); else console.Execute("get cheat_disable_support_limits"); diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index b7ceb3f636..9cf8fee65c 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -3482,7 +3482,7 @@ void network_chat_show_server_greeting() } } -GameActionResult::Ptr network_set_player_group( +GameActions::Result::Ptr network_set_player_group( NetworkPlayerId_t actionPlayerId, NetworkPlayerId_t playerId, uint8_t groupId, bool isExecuting) { NetworkPlayer* player = gNetwork.GetPlayerByID(playerId); @@ -3490,22 +3490,23 @@ GameActionResult::Ptr network_set_player_group( NetworkGroup* fromgroup = gNetwork.GetGroupByID(actionPlayerId); if (player == nullptr) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_DO_THIS); + return std::make_unique(GameActions::Status::InvalidParameters, STR_CANT_DO_THIS); } if (!gNetwork.GetGroupByID(groupId)) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_DO_THIS); + return std::make_unique(GameActions::Status::InvalidParameters, STR_CANT_DO_THIS); } if (player->Flags & NETWORK_PLAYER_FLAG_ISSERVER) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_CHANGE_GROUP_THAT_THE_HOST_BELONGS_TO); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CANT_CHANGE_GROUP_THAT_THE_HOST_BELONGS_TO); } if (groupId == 0 && fromgroup && fromgroup->Id != 0) { - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_SET_TO_THIS_GROUP); + return std::make_unique(GameActions::Status::InvalidParameters, STR_CANT_SET_TO_THIS_GROUP); } if (isExecuting) @@ -3536,10 +3537,10 @@ GameActionResult::Ptr network_set_player_group( format_string(log_msg, 256, STR_LOG_SET_PLAYER_GROUP, args); network_append_server_log(log_msg); } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr network_modify_groups( +GameActions::Result::Ptr network_modify_groups( NetworkPlayerId_t actionPlayerId, ModifyGroupType type, uint8_t groupId, const std::string& name, uint32_t permissionIndex, PermissionState permissionState, bool isExecuting) { @@ -3552,7 +3553,7 @@ GameActionResult::Ptr network_modify_groups( NetworkGroup* newgroup = gNetwork.AddGroup(); if (newgroup == nullptr) { - return std::make_unique(GA_ERROR::UNKNOWN, STR_CANT_DO_THIS); + return std::make_unique(GameActions::Status::Unknown, STR_CANT_DO_THIS); } } } @@ -3561,14 +3562,15 @@ GameActionResult::Ptr network_modify_groups( { if (groupId == 0) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_THIS_GROUP_CANNOT_BE_MODIFIED); + return std::make_unique( + GameActions::Status::Disallowed, STR_THIS_GROUP_CANNOT_BE_MODIFIED); } for (const auto& it : gNetwork.player_list) { if ((it.get())->Group == groupId) { - return std::make_unique( - GA_ERROR::DISALLOWED, STR_CANT_REMOVE_GROUP_THAT_PLAYERS_BELONG_TO); + return std::make_unique( + GameActions::Status::Disallowed, STR_CANT_REMOVE_GROUP_THAT_PLAYERS_BELONG_TO); } } if (isExecuting) @@ -3581,7 +3583,8 @@ GameActionResult::Ptr network_modify_groups( { if (groupId == 0) { // cant change admin group permissions - return std::make_unique(GA_ERROR::DISALLOWED, STR_THIS_GROUP_CANNOT_BE_MODIFIED); + return std::make_unique( + GameActions::Status::Disallowed, STR_THIS_GROUP_CANNOT_BE_MODIFIED); } NetworkGroup* mygroup = nullptr; NetworkPlayer* player = gNetwork.GetPlayerByID(actionPlayerId); @@ -3591,8 +3594,8 @@ GameActionResult::Ptr network_modify_groups( mygroup = gNetwork.GetGroupByID(player->Group); if (mygroup == nullptr || !mygroup->CanPerformAction(networkPermission)) { - return std::make_unique( - GA_ERROR::DISALLOWED, STR_CANT_MODIFY_PERMISSION_THAT_YOU_DO_NOT_HAVE_YOURSELF); + return std::make_unique( + GameActions::Status::Disallowed, STR_CANT_MODIFY_PERMISSION_THAT_YOU_DO_NOT_HAVE_YOURSELF); } } if (isExecuting) @@ -3629,13 +3632,13 @@ GameActionResult::Ptr network_modify_groups( if (strcmp(oldName, name.c_str()) == 0) { - return std::make_unique(); + return std::make_unique(); } if (name.empty()) { - return std::make_unique( - GA_ERROR::INVALID_PARAMETERS, STR_CANT_RENAME_GROUP, STR_INVALID_GROUP_NAME); + return std::make_unique( + GameActions::Status::InvalidParameters, STR_CANT_RENAME_GROUP, STR_INVALID_GROUP_NAME); } if (isExecuting) @@ -3651,7 +3654,7 @@ GameActionResult::Ptr network_modify_groups( { if (groupId == 0) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CANT_SET_TO_THIS_GROUP); + return std::make_unique(GameActions::Status::Disallowed, STR_CANT_SET_TO_THIS_GROUP); } if (isExecuting) { @@ -3661,27 +3664,27 @@ GameActionResult::Ptr network_modify_groups( break; default: log_error("Invalid Modify Group Type: %u", static_cast(type)); - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_NONE); } gNetwork.SaveGroups(); - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr network_kick_player(NetworkPlayerId_t playerId, bool isExecuting) +GameActions::Result::Ptr network_kick_player(NetworkPlayerId_t playerId, bool isExecuting) { NetworkPlayer* player = gNetwork.GetPlayerByID(playerId); if (player == nullptr) { // Player might be already removed by the PLAYERLIST command, need to refactor non-game commands executing too // early. - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); } if (player && player->Flags & NETWORK_PLAYER_FLAG_ISSERVER) { - return std::make_unique(GA_ERROR::DISALLOWED, STR_CANT_KICK_THE_HOST); + return std::make_unique(GameActions::Status::Disallowed, STR_CANT_KICK_THE_HOST); } if (isExecuting) @@ -3696,7 +3699,7 @@ GameActionResult::Ptr network_kick_player(NetworkPlayerId_t playerId, bool isExe networkUserManager->Save(); } } - return std::make_unique(); + return std::make_unique(); } uint8_t network_get_default_group() @@ -4109,20 +4112,20 @@ const char* network_get_group_name(uint32_t index) return ""; }; -GameActionResult::Ptr network_set_player_group( +GameActions::Result::Ptr network_set_player_group( NetworkPlayerId_t actionPlayerId, NetworkPlayerId_t playerId, uint8_t groupId, bool isExecuting) { - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr network_modify_groups( +GameActions::Result::Ptr network_modify_groups( NetworkPlayerId_t actionPlayerId, ModifyGroupType type, uint8_t groupId, const std::string& name, uint32_t permissionIndex, PermissionState permissionState, bool isExecuting) { - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr network_kick_player(NetworkPlayerId_t playerId, bool isExecuting) +GameActions::Result::Ptr network_kick_player(NetworkPlayerId_t playerId, bool isExecuting) { - return std::make_unique(); + return std::make_unique(); } uint8_t network_get_default_group() { diff --git a/src/openrct2/network/NetworkServerAdvertiser.cpp b/src/openrct2/network/NetworkServerAdvertiser.cpp index 9ddb83a16a..210bb28eae 100644 --- a/src/openrct2/network/NetworkServerAdvertiser.cpp +++ b/src/openrct2/network/NetworkServerAdvertiser.cpp @@ -185,7 +185,7 @@ private: request.header["Content-Type"] = "application/json"; Http::DoAsync(request, [&](Http::Response response) -> void { - if (response.status != Http::Status::OK) + if (response.status != Http::Status::Ok) { Console::WriteLine("Unable to connect to master server"); return; @@ -209,7 +209,7 @@ private: _lastHeartbeatTime = platform_get_ticks(); Http::DoAsync(request, [&](Http::Response response) -> void { - if (response.status != Http::Status::OK) + if (response.status != Http::Status::Ok) { Console::WriteLine("Unable to connect to master server"); return; diff --git a/src/openrct2/network/ServerList.cpp b/src/openrct2/network/ServerList.cpp index d70c76a200..c514022580 100644 --- a/src/openrct2/network/ServerList.cpp +++ b/src/openrct2/network/ServerList.cpp @@ -349,7 +349,7 @@ std::future> ServerList::FetchOnlineServerListAsync json_t root; try { - if (response.status != Http::Status::OK) + if (response.status != Http::Status::Ok) { throw MasterServerException(STR_SERVER_LIST_NO_CONNECTION); } diff --git a/src/openrct2/network/network.h b/src/openrct2/network/network.h index 3bbcd5a9f7..e5424b7ee0 100644 --- a/src/openrct2/network/network.h +++ b/src/openrct2/network/network.h @@ -26,7 +26,10 @@ struct GameAction; struct Peep; struct CoordsXYZ; -class GameActionResult; +namespace GameActions +{ + class Result; +} enum class ModifyGroupType : uint8_t; enum class PermissionState : uint8_t; enum class NetworkPermission : uint32_t; @@ -79,12 +82,12 @@ int32_t network_get_current_player_group_index(); uint8_t network_get_group_id(uint32_t index); int32_t network_get_num_groups(); const char* network_get_group_name(uint32_t index); -std::unique_ptr network_set_player_group( +std::unique_ptr network_set_player_group( NetworkPlayerId_t actionPlayerId, NetworkPlayerId_t playerId, uint8_t groupId, bool isExecuting); -std::unique_ptr network_modify_groups( +std::unique_ptr network_modify_groups( NetworkPlayerId_t actionPlayerId, ModifyGroupType type, uint8_t groupId, const std::string& name, uint32_t permissionIndex, PermissionState permissionState, bool isExecuting); -std::unique_ptr network_kick_player(NetworkPlayerId_t playerId, bool isExecuting); +std::unique_ptr network_kick_player(NetworkPlayerId_t playerId, bool isExecuting); uint8_t network_get_default_group(); int32_t network_get_num_actions(); rct_string_id network_get_action_name_string_id(uint32_t index); diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 4d63d70654..aea3f2340f 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -732,8 +732,9 @@ void Peep::PickupAbort(int32_t old_x) gPickupPeepImage = UINT32_MAX; } -// Returns GA_ERROR::OK when a peep can be dropped at the given location. When apply is set to true the peep gets dropped. -std::unique_ptr Peep::Place(const TileCoordsXYZ& location, bool apply) +// Returns GameActions::Status::OK when a peep can be dropped at the given location. When apply is set to true the peep gets +// dropped. +std::unique_ptr Peep::Place(const TileCoordsXYZ& location, bool apply) { auto* pathElement = map_get_path_element_at(location); TileElement* tileElement = reinterpret_cast(pathElement); @@ -743,7 +744,7 @@ std::unique_ptr Peep::Place(const TileCoordsXYZ& location, boo } if (!tileElement) - return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_ERR_CANT_PLACE_PERSON_HERE); + return std::make_unique(GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PERSON_HERE); // Set the coordinate of destination to be exactly // in the middle of a tile. @@ -751,18 +752,18 @@ std::unique_ptr Peep::Place(const TileCoordsXYZ& location, boo if (!map_is_location_owned(destination)) { - return std::make_unique(GA_ERROR::NOT_OWNED, STR_ERR_CANT_PLACE_PERSON_HERE); + return std::make_unique(GameActions::Status::NotOwned, STR_ERR_CANT_PLACE_PERSON_HERE); } if (auto res = MapCanConstructAt({ destination, destination.z, destination.z + (1 * 8) }, { 0b1111, 0 }); - res->Error != GA_ERROR::OK) + res->Error != GameActions::Status::Ok) { if (res->ErrorMessage.GetStringId() != STR_RAISE_OR_LOWER_LAND_FIRST) { if (res->ErrorMessage.GetStringId() != STR_FOOTPATH_IN_THE_WAY) { - return std::make_unique( - GA_ERROR::NO_CLEARANCE, STR_ERR_CANT_PLACE_PERSON_HERE, res->ErrorMessage.GetStringId(), + return std::make_unique( + GameActions::Status::NoClearance, STR_ERR_CANT_PLACE_PERSON_HERE, res->ErrorMessage.GetStringId(), res->ErrorMessageArgs.data()); } } @@ -787,7 +788,7 @@ std::unique_ptr Peep::Place(const TileCoordsXYZ& location, boo } } - return std::make_unique(); + return std::make_unique(); } /** diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index 4d41095d77..eb98299689 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -50,7 +50,10 @@ constexpr auto PEEP_CLEARANCE_HEIGHT = 4 * COORDS_Z_STEP; class Formatter; struct TileElement; struct Ride; -class GameActionResult; +namespace GameActions +{ + class Result; +} using ParkEntranceIndex = uint8_t; enum class PeepType : uint8_t @@ -800,7 +803,7 @@ public: // Peep void SetNextFlags(uint8_t next_direction, bool is_sloped, bool is_surface); void Pickup(); void PickupAbort(int32_t old_x); - std::unique_ptr Place(const TileCoordsXYZ& location, bool apply); + std::unique_ptr Place(const TileCoordsXYZ& location, bool apply); static Peep* Generate(const CoordsXYZ& coords); void RemoveFromQueue(); void RemoveFromRide(); diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 93820d34a9..9e3c6a17d3 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -132,7 +132,7 @@ bool staff_hire_new_member(StaffType staffType, EntertainerCostume entertainerTy auto hireStaffAction = StaffHireNewAction(autoPosition, staffType, entertainerType, staffOrders); hireStaffAction.SetCallback([=](const GameAction*, const StaffHireNewActionResult* res) -> void { - if (res->Error != GA_ERROR::OK) + if (res->Error != GameActions::Status::Ok) return; // Open window for new staff. @@ -143,7 +143,7 @@ bool staff_hire_new_member(StaffType staffType, EntertainerCostume entertainerTy }); auto res = GameActions::Execute(&hireStaffAction); - return res->Error == GA_ERROR::OK; + return res->Error == GameActions::Status::Ok; } /** diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 30d3b0a352..944ee6e997 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1768,7 +1768,7 @@ static bool ride_modify_entrance_or_exit(const CoordsXYE& tileElement) auto rideEntranceExitRemove = RideEntranceExitRemoveAction( { tileElement.x, tileElement.y }, rideIndex, stationIndex, entranceType == ENTRANCE_TYPE_RIDE_EXIT); - rideEntranceExitRemove.SetCallback([=](const GameAction* ga, const GameActionResult* result) { + rideEntranceExitRemove.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { gCurrentToolWidget.widget_index = entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE ? WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE : WC_RIDE_CONSTRUCTION__WIDX_EXIT; gRideEntranceExitPlaceType = entranceType; @@ -3743,7 +3743,7 @@ money32 set_operating_setting(ride_id_t rideId, RideSetSetting setting, uint8_t { auto rideSetSetting = RideSetSettingAction(rideId, setting, value); auto res = GameActions::Execute(&rideSetSetting); - return res->Error == GA_ERROR::OK ? 0 : MONEY32_UNDEFINED; + return res->Error == GameActions::Status::Ok ? 0 : MONEY32_UNDEFINED; } money32 set_operating_setting_nested(ride_id_t rideId, RideSetSetting setting, uint8_t value, uint8_t flags) @@ -3752,7 +3752,7 @@ money32 set_operating_setting_nested(ride_id_t rideId, RideSetSetting setting, u rideSetSetting.SetFlags(flags); auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&rideSetSetting) : GameActions::QueryNested(&rideSetSetting); - return res->Error == GA_ERROR::OK ? 0 : MONEY32_UNDEFINED; + return res->Error == GameActions::Status::Ok ? 0 : MONEY32_UNDEFINED; } /** diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index f49b01b7e1..652d2368cc 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -1056,7 +1056,7 @@ static bool TrackDesignPlaceSceneryElement( auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&smallSceneryPlace) : GameActions::QueryNested(&smallSceneryPlace); - cost = res->Error == GA_ERROR::OK ? res->Cost : 0; + cost = res->Error == GameActions::Status::Ok ? res->Cost : 0; break; } case OBJECT_TYPE_LARGE_SCENERY: @@ -1196,7 +1196,7 @@ static bool TrackDesignPlaceSceneryElement( auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&footpathPlaceAction) : GameActions::QueryNested(&footpathPlaceAction); // Ignore failures - cost = res->Error == GA_ERROR::OK ? res->Cost : 0; + cost = res->Error == GameActions::Status::Ok ? res->Cost : 0; } else { @@ -1343,7 +1343,7 @@ static int32_t track_design_place_maze(TrackDesign* td6, const CoordsXYZ& coords if (_trackDesignPlaceOperation == PTD_OPERATION_PLACE_QUERY) { auto res = RideEntranceExitPlaceAction::TrackPlaceQuery({ mapCoord, coords.z }, false); - cost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + cost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; } else { @@ -1364,7 +1364,7 @@ static int32_t track_design_place_maze(TrackDesign* td6, const CoordsXYZ& coords auto rideEntranceExitPlaceAction = RideEntranceExitPlaceAction(mapCoord, rotation, ride->id, 0, false); rideEntranceExitPlaceAction.SetFlags(flags); auto res = GameActions::ExecuteNested(&rideEntranceExitPlaceAction); - cost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + cost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; } if (cost != MONEY32_UNDEFINED) { @@ -1382,7 +1382,7 @@ static int32_t track_design_place_maze(TrackDesign* td6, const CoordsXYZ& coords if (_trackDesignPlaceOperation == PTD_OPERATION_PLACE_QUERY) { auto res = RideEntranceExitPlaceAction::TrackPlaceQuery({ mapCoord, coords.z }, true); - cost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + cost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; } else { @@ -1403,7 +1403,7 @@ static int32_t track_design_place_maze(TrackDesign* td6, const CoordsXYZ& coords auto rideEntranceExitPlaceAction = RideEntranceExitPlaceAction(mapCoord, rotation, ride->id, 0, true); rideEntranceExitPlaceAction.SetFlags(flags); auto res = GameActions::ExecuteNested(&rideEntranceExitPlaceAction); - cost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + cost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; } if (cost != MONEY32_UNDEFINED) { @@ -1440,7 +1440,7 @@ static int32_t track_design_place_maze(TrackDesign* td6, const CoordsXYZ& coords mazePlace.SetFlags(flags); auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&mazePlace) : GameActions::QueryNested(&mazePlace); - cost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + cost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; break; } @@ -1601,7 +1601,7 @@ static bool track_design_place_ride(TrackDesign* td6, const CoordsXYZ& origin, R auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&trackPlaceAction) : GameActions::QueryNested(&trackPlaceAction); - money32 cost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + money32 cost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; _trackDesignPlaceCost += cost; if (cost == MONEY32_UNDEFINED) @@ -1742,7 +1742,7 @@ static bool track_design_place_ride(TrackDesign* td6, const CoordsXYZ& origin, R _trackDesignPlaceCost += res->Cost; - if (res->Error != GA_ERROR::OK) + if (res->Error != GameActions::Status::Ok) { _trackDesignPlaceCost = MONEY32_UNDEFINED; return false; @@ -1757,7 +1757,7 @@ static bool track_design_place_ride(TrackDesign* td6, const CoordsXYZ& origin, R newCoords.z += _trackPreviewOrigin.z; auto res = RideEntranceExitPlaceAction::TrackPlaceQuery(newCoords, false); - if (res->Error != GA_ERROR::OK) + if (res->Error != GameActions::Status::Ok) { _trackDesignPlaceCost = MONEY32_UNDEFINED; return false; @@ -1863,7 +1863,7 @@ static money32 track_design_ride_create_command(int32_t type, int32_t subType, i const RideCreateGameActionResult* res = static_cast(r.get()); // Callee's of this function expect MONEY32_UNDEFINED in case of failure. - if (res->Error != GA_ERROR::OK) + if (res->Error != GameActions::Status::Ok) { return MONEY32_UNDEFINED; } diff --git a/src/openrct2/scripting/ScContext.hpp b/src/openrct2/scripting/ScContext.hpp index 6b0725ad6d..7cd6bdd227 100644 --- a/src/openrct2/scripting/ScContext.hpp +++ b/src/openrct2/scripting/ScContext.hpp @@ -199,9 +199,10 @@ namespace OpenRCT2::Scripting auto plugin = scriptEngine.GetExecInfo().GetCurrentPlugin(); if (isExecute) { - action->SetCallback([this, plugin, callback](const GameAction*, const GameActionResult* res) -> void { - HandleGameActionResult(plugin, *res, callback); - }); + action->SetCallback( + [this, plugin, callback](const GameAction*, const GameActions::Result* res) -> void { + HandleGameActionResult(plugin, *res, callback); + }); GameActions::Execute(action.get()); } else @@ -222,7 +223,7 @@ namespace OpenRCT2::Scripting } void HandleGameActionResult( - const std::shared_ptr& plugin, const GameActionResult& res, const DukValue& callback) + const std::shared_ptr& plugin, const GameActions::Result& res, const DukValue& callback) { // Construct result object auto& scriptEngine = GetContext()->GetScriptEngine(); @@ -231,7 +232,7 @@ namespace OpenRCT2::Scripting duk_push_int(ctx, static_cast(res.Error)); duk_put_prop_string(ctx, objIdx, "error"); - if (res.Error != GA_ERROR::OK) + if (res.Error != GameActions::Status::Ok) { auto title = res.GetErrorTitle(); duk_push_string(ctx, title.c_str()); diff --git a/src/openrct2/scripting/ScriptEngine.cpp b/src/openrct2/scripting/ScriptEngine.cpp index 0a67294fb6..51403c51a7 100644 --- a/src/openrct2/scripting/ScriptEngine.cpp +++ b/src/openrct2/scripting/ScriptEngine.cpp @@ -726,7 +726,7 @@ void ScriptEngine::AddNetworkPlugin(const std::string_view& code) LoadPlugin(plugin); } -std::unique_ptr ScriptEngine::QueryOrExecuteCustomGameAction( +std::unique_ptr ScriptEngine::QueryOrExecuteCustomGameAction( const std::string_view& id, const std::string_view& args, bool isExecute) { std::string actionz = std::string(id); @@ -741,8 +741,8 @@ std::unique_ptr ScriptEngine::QueryOrExecuteCustomGameAction( auto dukArgs = DuktapeTryParseJson(_context, argsz); if (!dukArgs) { - auto action = std::make_unique(); - action->Error = GA_ERROR::INVALID_PARAMETERS; + auto action = std::make_unique(); + action->Error = GameActions::Status::InvalidParameters; action->ErrorTitle = "Invalid JSON"; return action; } @@ -761,17 +761,17 @@ std::unique_ptr ScriptEngine::QueryOrExecuteCustomGameAction( } else { - auto action = std::make_unique(); - action->Error = GA_ERROR::UNKNOWN; + auto action = std::make_unique(); + action->Error = GameActions::Status::Unknown; action->ErrorTitle = "Unknown custom action"; return action; } } -std::unique_ptr ScriptEngine::DukToGameActionResult(const DukValue& d) +std::unique_ptr ScriptEngine::DukToGameActionResult(const DukValue& d) { - auto result = std::make_unique(); - result->Error = static_cast(AsOrDefault(d["error"])); + auto result = std::make_unique(); + result->Error = static_cast(AsOrDefault(d["error"])); result->ErrorTitle = AsOrDefault(d["errorTitle"]); result->ErrorMessage = AsOrDefault(d["errorMessage"]); result->Cost = AsOrDefault(d["cost"]); @@ -825,7 +825,7 @@ ExpenditureType ScriptEngine::StringToExpenditureType(const std::string_view& ex return ExpenditureType::Count; } -DukValue ScriptEngine::GameActionResultToDuk(const GameAction& action, const std::unique_ptr& result) +DukValue ScriptEngine::GameActionResultToDuk(const GameAction& action, const std::unique_ptr& result) { DukStackFrame frame(_context); DukObject obj(_context); @@ -1053,7 +1053,7 @@ static std::unique_ptr CreateGameActionFromActionId(const std::strin return nullptr; } -void ScriptEngine::RunGameActionHooks(const GameAction& action, std::unique_ptr& result, bool isExecute) +void ScriptEngine::RunGameActionHooks(const GameAction& action, std::unique_ptr& result, bool isExecute) { DukStackFrame frame(_context); @@ -1097,7 +1097,7 @@ void ScriptEngine::RunGameActionHooks(const GameAction& action, std::unique_ptr< obj.Set("type", actionId); auto flags = action.GetActionFlags(); - obj.Set("isClientOnly", (flags & GA_FLAGS::CLIENT_ONLY) != 0); + obj.Set("isClientOnly", (flags & GameActions::Flags::ClientOnly) != 0); obj.Set("result", GameActionResultToDuk(action, result)); auto dukEventArgs = obj.Take(); @@ -1112,7 +1112,7 @@ void ScriptEngine::RunGameActionHooks(const GameAction& action, std::unique_ptr< auto error = AsOrDefault(dukResult["error"]); if (error != 0) { - result->Error = static_cast(error); + result->Error = static_cast(error); result->ErrorTitle = AsOrDefault(dukResult["errorTitle"]); result->ErrorMessage = AsOrDefault(dukResult["errorMessage"]); } diff --git a/src/openrct2/scripting/ScriptEngine.h b/src/openrct2/scripting/ScriptEngine.h index c4de63bc56..d66e5c61ba 100644 --- a/src/openrct2/scripting/ScriptEngine.h +++ b/src/openrct2/scripting/ScriptEngine.h @@ -32,7 +32,10 @@ struct duk_hthread; typedef struct duk_hthread duk_context; struct GameAction; -class GameActionResult; +namespace GameActions +{ + class Result; +} class FileWatcher; class InteractiveConsole; @@ -184,12 +187,12 @@ namespace OpenRCT2::Scripting void AddNetworkPlugin(const std::string_view& code); - std::unique_ptr QueryOrExecuteCustomGameAction( + std::unique_ptr QueryOrExecuteCustomGameAction( const std::string_view& id, const std::string_view& args, bool isExecute); bool RegisterCustomAction( const std::shared_ptr& plugin, const std::string_view& action, const DukValue& query, const DukValue& execute); - void RunGameActionHooks(const GameAction& action, std::unique_ptr& result, bool isExecute); + void RunGameActionHooks(const GameAction& action, std::unique_ptr& result, bool isExecute); std::unique_ptr CreateGameAction(const std::string& actionid, const DukValue& args); void SaveSharedStorage(); @@ -211,8 +214,8 @@ namespace OpenRCT2::Scripting void AutoReloadPlugins(); void ProcessREPL(); void RemoveCustomGameActions(const std::shared_ptr& plugin); - std::unique_ptr DukToGameActionResult(const DukValue& d); - DukValue GameActionResultToDuk(const GameAction& action, const std::unique_ptr& result); + std::unique_ptr DukToGameActionResult(const DukValue& d); + DukValue GameActionResultToDuk(const GameAction& action, const std::unique_ptr& result); static std::string_view ExpenditureTypeToString(ExpenditureType expenditureType); static ExpenditureType StringToExpenditureType(const std::string_view& expenditureType); diff --git a/src/openrct2/windows/_legacy.cpp b/src/openrct2/windows/_legacy.cpp index 9b15b35133..27a910576f 100644 --- a/src/openrct2/windows/_legacy.cpp +++ b/src/openrct2/windows/_legacy.cpp @@ -86,7 +86,7 @@ money32 place_provisional_track_piece( // This command must not be sent over the network auto res = GameActions::Execute(&trackPlaceAction); auto tpar = dynamic_cast(res.get()); - result = ((tpar == nullptr) || (res->Error == GA_ERROR::OK)) ? res->Cost : MONEY32_UNDEFINED; + result = ((tpar == nullptr) || (res->Error == GameActions::Status::Ok)) ? res->Cost : MONEY32_UNDEFINED; if (result == MONEY32_UNDEFINED) return result; diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index 709fe9f01e..ab0ca323a5 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -43,7 +43,7 @@ static money32 RideEntranceExitPlaceGhost( rideEntranceExitPlaceAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_GHOST); auto res = GameActions::Execute(&rideEntranceExitPlaceAction); - return res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; + return res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; } /** diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 842ce8091b..8365e6d620 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -153,8 +153,8 @@ money32 footpath_provisional_set(int32_t type, const CoordsXYZ& footpathLoc, int auto footpathPlaceAction = FootpathPlaceAction(footpathLoc, slope, type); footpathPlaceAction.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); auto res = GameActions::Execute(&footpathPlaceAction); - cost = res->Error == GA_ERROR::OK ? res->Cost : MONEY32_UNDEFINED; - if (res->Error == GA_ERROR::OK) + cost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED; + if (res->Error == GameActions::Status::Ok) { gFootpathProvisionalType = type; gFootpathProvisionalPosition = footpathLoc; @@ -176,7 +176,7 @@ money32 footpath_provisional_set(int32_t type, const CoordsXYZ& footpathLoc, int if (!scenery_tool_is_active()) { - if (res->Error != GA_ERROR::OK) + if (res->Error != GameActions::Status::Ok) { // If we can't build this, don't show a virtual floor. virtual_floor_set_height(0); diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 4d6fbf9147..12c79af0ef 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1222,7 +1222,7 @@ TileElement* tile_element_insert(const CoordsXYZ& loc, int32_t occupiedQuadrants * * rct2: 0x0068BB18 */ -void map_obstruction_set_error_text(TileElement* tileElement, GameActionResult& res) +void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Result& res) { Ride* ride; rct_scenery_entry* sceneryEntry; @@ -1297,19 +1297,19 @@ void map_obstruction_set_error_text(TileElement* tileElement, GameActionResult& * ebp = clearFunc * bl = bl */ -std::unique_ptr MapCanConstructWithClearAt( +std::unique_ptr MapCanConstructWithClearAt( const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, uint8_t crossingMode) { int32_t northZ, eastZ, baseHeight, southZ, westZ, water_height; northZ = eastZ = baseHeight = southZ = westZ = water_height = 0; - auto res = std::make_unique(); + auto res = std::make_unique(); uint8_t slope = 0; res->GroundFlags = ELEMENT_IS_ABOVE_GROUND; bool canBuildCrossing = false; if (pos.x >= gMapSizeUnits || pos.y >= gMapSizeUnits || pos.x < 32 || pos.y < 32) { - res->Error = GA_ERROR::INVALID_PARAMETERS; + res->Error = GameActions::Status::InvalidParameters; res->ErrorMessage = STR_OFF_EDGE_OF_MAP; return res; } @@ -1322,7 +1322,7 @@ std::unique_ptr MapCanConstructWithClearAt( TileElement* tileElement = map_get_first_element_at(pos); if (tileElement == nullptr) { - res->Error = GA_ERROR::UNKNOWN; + res->Error = GameActions::Status::Unknown; res->ErrorMessage = STR_NONE; return res; } @@ -1356,7 +1356,7 @@ std::unique_ptr MapCanConstructWithClearAt( if (heightFromGround > (18 * COORDS_Z_STEP)) { - res->Error = GA_ERROR::DISALLOWED; + res->Error = GameActions::Status::Disallowed; res->ErrorMessage = STR_LOCAL_AUTHORITY_WONT_ALLOW_CONSTRUCTION_ABOVE_TREE_HEIGHT; return res; } @@ -1451,7 +1451,7 @@ std::unique_ptr MapCanConstructWithClearAt( if (tileElement != nullptr) { map_obstruction_set_error_text(tileElement, *res); - res->Error = GA_ERROR::NO_CLEARANCE; + res->Error = GameActions::Status::NoClearance; } return res; @@ -1465,7 +1465,7 @@ std::unique_ptr MapCanConstructWithClearAt( } if (tileElement != nullptr) { - res->Error = GA_ERROR::NO_CLEARANCE; + res->Error = GameActions::Status::NoClearance; res->ErrorMessage = STR_CANNOT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_WATER; } return res; @@ -1491,7 +1491,7 @@ bool map_can_construct_with_clear_at( } gMapGroundFlags = res->GroundFlags; - return res->Error == GA_ERROR::OK; + return res->Error == GameActions::Status::Ok; } /** @@ -1503,7 +1503,7 @@ int32_t map_can_construct_at(const CoordsXYRangedZ& pos, QuarterTile bl) return map_can_construct_with_clear_at(pos, nullptr, bl, 0, nullptr, CREATE_CROSSING_MODE_NONE); } -std::unique_ptr MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl) +std::unique_ptr MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl) { return MapCanConstructWithClearAt(pos, nullptr, bl, 0, CREATE_CROSSING_MODE_NONE); } diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index e8eeaed687..6873d5ea70 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -185,8 +185,11 @@ void map_reorganise_elements(); bool map_check_free_elements_and_reorganise(int32_t num_elements); TileElement* tile_element_insert(const CoordsXYZ& loc, int32_t occupiedQuadrants); -class GameActionResult; -class ConstructClearResult; +namespace GameActions +{ + class Result; + class ConstructClearResult; +} // namespace GameActions using CLEAR_FUNC = int32_t (*)(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price); @@ -195,9 +198,9 @@ int32_t map_place_scenery_clear_func(TileElement** tile_element, const CoordsXY& bool map_can_construct_with_clear_at( const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, money32* price, uint8_t crossingMode); -std::unique_ptr MapCanConstructWithClearAt( +std::unique_ptr MapCanConstructWithClearAt( const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, uint8_t crossingMode); -std::unique_ptr MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl); +std::unique_ptr MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl); int32_t map_can_construct_at(const CoordsXYRangedZ& pos, QuarterTile bl); struct tile_element_iterator @@ -257,7 +260,7 @@ TileElement* map_get_track_element_at_from_ride(const CoordsXYZ& trackPos, ride_ TileElement* map_get_track_element_at_with_direction_from_ride(const CoordsXYZD& trackPos, ride_id_t rideIndex); bool map_is_location_at_edge(const CoordsXY& loc); -void map_obstruction_set_error_text(TileElement* tileElement, GameActionResult& res); +void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Result& res); uint16_t check_max_allowable_land_rights_for_tile(const CoordsXYZ& tileMapPos); diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index f234397d47..0534668975 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -78,11 +78,11 @@ static bool map_swap_elements_at(const CoordsXY& loc, int16_t first, int16_t sec * @param elementIndex The nth element on this tile * Returns 0 on success, MONEY_UNDEFINED otherwise. */ -GameActionResult::Ptr tile_inspector_insert_corrupt_at(const CoordsXY& loc, int16_t elementIndex, bool isExecuting) +GameActionResultPtr tile_inspector_insert_corrupt_at(const CoordsXY& loc, int16_t elementIndex, bool isExecuting) { // Make sure there is enough space for the new element if (!map_check_free_elements_and_reorganise(1)) - return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS, STR_NONE); + return std::make_unique(GameActions::Status::NoFreeElements, STR_NONE); if (isExecuting) { @@ -92,7 +92,7 @@ GameActionResult::Ptr tile_inspector_insert_corrupt_at(const CoordsXY& loc, int1 if (corruptElement == nullptr) { log_warning("Failed to insert corrupt element."); - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); } corruptElement->SetType(TILE_ELEMENT_TYPE_CORRUPT); @@ -100,7 +100,7 @@ GameActionResult::Ptr tile_inspector_insert_corrupt_at(const CoordsXY& loc, int1 TileElement* const selectedElement = map_get_nth_element_at(loc, elementIndex + 1); if (selectedElement == nullptr) { - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); } corruptElement->base_height = corruptElement->clearance_height = selectedElement->base_height; @@ -136,7 +136,7 @@ GameActionResult::Ptr tile_inspector_insert_corrupt_at(const CoordsXY& loc, int1 } // Nothing went wrong - return std::make_unique(); + return std::make_unique(); } static int32_t numLargeScenerySequences(const CoordsXY& loc, const LargeSceneryElement* const largeScenery) @@ -191,7 +191,7 @@ static int32_t numLargeScenerySequences(const CoordsXY& loc, const LargeSceneryE * @param y The y coordinate of the tile * @param elementIndex The nth element on this tile */ -GameActionResult::Ptr tile_inspector_remove_element_at(const CoordsXY& loc, int16_t elementIndex, bool isExecuting) +GameActionResultPtr tile_inspector_remove_element_at(const CoordsXY& loc, int16_t elementIndex, bool isExecuting) { if (isExecuting) { @@ -199,7 +199,7 @@ GameActionResult::Ptr tile_inspector_remove_element_at(const CoordsXY& loc, int1 TileElement* const tileElement = map_get_nth_element_at(loc, elementIndex); if (tileElement == nullptr) { - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); } auto largeScenery = tileElement->AsLargeScenery(); @@ -239,16 +239,16 @@ GameActionResult::Ptr tile_inspector_remove_element_at(const CoordsXY& loc, int1 } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_swap_elements_at(const CoordsXY& loc, int16_t first, int16_t second, bool isExecuting) +GameActionResultPtr tile_inspector_swap_elements_at(const CoordsXY& loc, int16_t first, int16_t second, bool isExecuting) { if (isExecuting) { if (!map_swap_elements_at(loc, first, second)) { - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); } map_invalidate_tile_full(loc); @@ -266,10 +266,10 @@ GameActionResult::Ptr tile_inspector_swap_elements_at(const CoordsXY& loc, int16 } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_rotate_element_at(const CoordsXY& loc, int32_t elementIndex, bool isExecuting) +GameActionResultPtr tile_inspector_rotate_element_at(const CoordsXY& loc, int32_t elementIndex, bool isExecuting) { if (isExecuting) { @@ -278,7 +278,7 @@ GameActionResult::Ptr tile_inspector_rotate_element_at(const CoordsXY& loc, int3 TileElement* const tileElement = map_get_nth_element_at(loc, elementIndex); if (tileElement == nullptr) { - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); } switch (tileElement->GetType()) { @@ -347,15 +347,15 @@ GameActionResult::Ptr tile_inspector_rotate_element_at(const CoordsXY& loc, int3 } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_paste_element_at(const CoordsXY& loc, TileElement element, bool isExecuting) +GameActionResultPtr tile_inspector_paste_element_at(const CoordsXY& loc, TileElement element, bool isExecuting) { // Make sure there is enough space for the new element if (!map_check_free_elements_and_reorganise(1)) { - return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS, STR_NONE); + return std::make_unique(GameActions::Status::NoFreeElements, STR_NONE); } auto tileLoc = TileCoordsXY(loc); @@ -370,7 +370,7 @@ GameActionResult::Ptr tile_inspector_paste_element_at(const CoordsXY& loc, TileE auto newBannerIndex = create_new_banner(GAME_COMMAND_FLAG_APPLY); if (newBannerIndex == BANNER_INDEX_NULL) { - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); } auto& newBanner = *GetBanner(newBannerIndex); newBanner = *GetBanner(bannerIndex); @@ -406,16 +406,16 @@ GameActionResult::Ptr tile_inspector_paste_element_at(const CoordsXY& loc, TileE } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_sort_elements_at(const CoordsXY& loc, bool isExecuting) +GameActionResultPtr tile_inspector_sort_elements_at(const CoordsXY& loc, bool isExecuting) { if (isExecuting) { const TileElement* const firstElement = map_get_first_element_at(loc); if (firstElement == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); // Count elements on tile int32_t numElement = 0; @@ -464,41 +464,43 @@ GameActionResult::Ptr tile_inspector_sort_elements_at(const CoordsXY& loc, bool } } - return std::make_unique(); + return std::make_unique(); } -static GameActionResult::Ptr ValidateTileHeight(TileElement* const tileElement, int8_t heightOffset) +static GameActionResultPtr ValidateTileHeight(TileElement* const tileElement, int8_t heightOffset) { int16_t newBaseHeight = static_cast(tileElement->base_height + heightOffset); int16_t newClearanceHeight = static_cast(tileElement->clearance_height + heightOffset); if (newBaseHeight < 0) { - return std::make_unique(GA_ERROR::TOO_LOW, STR_CANT_LOWER_ELEMENT_HERE, STR_TOO_LOW); + return std::make_unique(GameActions::Status::TooLow, STR_CANT_LOWER_ELEMENT_HERE, STR_TOO_LOW); } else if (newBaseHeight > MAX_ELEMENT_HEIGHT) { - return std::make_unique(GA_ERROR::TOO_HIGH, STR_CANT_RAISE_ELEMENT_HERE, STR_TOO_HIGH); + return std::make_unique(GameActions::Status::TooHigh, STR_CANT_RAISE_ELEMENT_HERE, STR_TOO_HIGH); } else if (newClearanceHeight < 0) { - return std::make_unique(GA_ERROR::NO_CLEARANCE, STR_CANT_LOWER_ELEMENT_HERE, STR_NO_CLEARANCE); + return std::make_unique( + GameActions::Status::NoClearance, STR_CANT_LOWER_ELEMENT_HERE, STR_NO_CLEARANCE); } else if (newClearanceHeight > MAX_ELEMENT_HEIGHT) { - return std::make_unique(GA_ERROR::NO_CLEARANCE, STR_CANT_RAISE_ELEMENT_HERE, STR_NO_CLEARANCE); + return std::make_unique( + GameActions::Status::NoClearance, STR_CANT_RAISE_ELEMENT_HERE, STR_NO_CLEARANCE); } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_any_base_height_offset( +GameActionResultPtr tile_inspector_any_base_height_offset( const CoordsXY& loc, int16_t elementIndex, int8_t heightOffset, bool isExecuting) { TileElement* const tileElement = map_get_nth_element_at(loc, elementIndex); if (tileElement == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); auto heightValidationResult = ValidateTileHeight(tileElement, heightOffset); - if (heightValidationResult->Error != GA_ERROR::OK) + if (heightValidationResult->Error != GameActions::Status::Ok) return heightValidationResult; if (isExecuting) @@ -539,16 +541,16 @@ GameActionResult::Ptr tile_inspector_any_base_height_offset( } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_surface_show_park_fences(const CoordsXY& loc, bool showFences, bool isExecuting) +GameActionResultPtr tile_inspector_surface_show_park_fences(const CoordsXY& loc, bool showFences, bool isExecuting) { auto* const surfaceelement = map_get_surface_element_at(loc); // No surface element on tile if (surfaceelement == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -566,16 +568,16 @@ GameActionResult::Ptr tile_inspector_surface_show_park_fences(const CoordsXY& lo } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_surface_toggle_corner(const CoordsXY& loc, int32_t cornerIndex, bool isExecuting) +GameActionResultPtr tile_inspector_surface_toggle_corner(const CoordsXY& loc, int32_t cornerIndex, bool isExecuting) { auto* const surfaceElement = map_get_surface_element_at(loc); // No surface element on tile if (surfaceElement == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -632,16 +634,16 @@ GameActionResult::Ptr tile_inspector_surface_toggle_corner(const CoordsXY& loc, } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_surface_toggle_diagonal(const CoordsXY& loc, bool isExecuting) +GameActionResultPtr tile_inspector_surface_toggle_diagonal(const CoordsXY& loc, bool isExecuting) { auto* const surfaceElement = map_get_surface_element_at(loc); // No surface element on tile if (surfaceElement == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -669,15 +671,15 @@ GameActionResult::Ptr tile_inspector_surface_toggle_diagonal(const CoordsXY& loc } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_path_set_sloped(const CoordsXY& loc, int32_t elementIndex, bool sloped, bool isExecuting) +GameActionResultPtr tile_inspector_path_set_sloped(const CoordsXY& loc, int32_t elementIndex, bool sloped, bool isExecuting) { TileElement* const pathElement = map_get_nth_element_at(loc, elementIndex); if (pathElement == nullptr || pathElement->GetType() != TILE_ELEMENT_TYPE_PATH) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -692,15 +694,15 @@ GameActionResult::Ptr tile_inspector_path_set_sloped(const CoordsXY& loc, int32_ } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_path_set_broken(const CoordsXY& loc, int32_t elementIndex, bool broken, bool isExecuting) +GameActionResultPtr tile_inspector_path_set_broken(const CoordsXY& loc, int32_t elementIndex, bool broken, bool isExecuting) { TileElement* const pathElement = map_get_nth_element_at(loc, elementIndex); if (pathElement == nullptr || pathElement->GetType() != TILE_ELEMENT_TYPE_PATH) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -715,16 +717,16 @@ GameActionResult::Ptr tile_inspector_path_set_broken(const CoordsXY& loc, int32_ } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_path_toggle_edge( +GameActionResultPtr tile_inspector_path_toggle_edge( const CoordsXY& loc, int32_t elementIndex, int32_t edgeIndex, bool isExecuting) { TileElement* const pathElement = map_get_nth_element_at(loc, elementIndex); if (pathElement == nullptr || pathElement->GetType() != TILE_ELEMENT_TYPE_PATH) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -740,19 +742,19 @@ GameActionResult::Ptr tile_inspector_path_toggle_edge( } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_entrance_make_usable(const CoordsXY& loc, int32_t elementIndex, bool isExecuting) +GameActionResultPtr tile_inspector_entrance_make_usable(const CoordsXY& loc, int32_t elementIndex, bool isExecuting) { TileElement* const entranceElement = map_get_nth_element_at(loc, elementIndex); if (entranceElement == nullptr || entranceElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); auto ride = get_ride(entranceElement->AsEntrance()->GetRideIndex()); if (ride == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -781,16 +783,16 @@ GameActionResult::Ptr tile_inspector_entrance_make_usable(const CoordsXY& loc, i } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_wall_set_slope( +GameActionResultPtr tile_inspector_wall_set_slope( const CoordsXY& loc, int32_t elementIndex, int32_t slopeValue, bool isExecuting) { TileElement* const wallElement = map_get_nth_element_at(loc, elementIndex); if (wallElement == nullptr || wallElement->GetType() != TILE_ELEMENT_TYPE_WALL) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -806,16 +808,16 @@ GameActionResult::Ptr tile_inspector_wall_set_slope( } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_wall_animation_frame_offset( +GameActionResultPtr tile_inspector_wall_animation_frame_offset( const CoordsXY& loc, int16_t elementIndex, int8_t animationFrameOffset, bool isExecuting) { TileElement* const wallElement = map_get_nth_element_at(loc, elementIndex); if (wallElement == nullptr || wallElement->GetType() != TILE_ELEMENT_TYPE_WALL) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -831,21 +833,21 @@ GameActionResult::Ptr tile_inspector_wall_animation_frame_offset( } } - return std::make_unique(); + return std::make_unique(); } // Changes the height of all track elements that belong to the same track piece // Broxzier: Copied from track_remove and stripped of unneeded code, but I think this should be smaller -GameActionResult::Ptr tile_inspector_track_base_height_offset( +GameActionResultPtr tile_inspector_track_base_height_offset( const CoordsXY& loc, int32_t elementIndex, int8_t offset, bool isExecuting) { if (offset == 0) - return std::make_unique(); + return std::make_unique(); TileElement* const trackElement = map_get_nth_element_at(loc, elementIndex); if (trackElement == nullptr || trackElement->GetType() != TILE_ELEMENT_TYPE_TRACK) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -857,7 +859,7 @@ GameActionResult::Ptr tile_inspector_track_base_height_offset( auto rideIndex = trackElement->AsTrack()->GetRideIndex(); auto ride = get_ride(rideIndex); if (ride == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); auto trackBlock = get_track_def_from_ride(ride, type); trackBlock += trackElement->AsTrack()->GetSequenceIndex(); @@ -912,7 +914,7 @@ GameActionResult::Ptr tile_inspector_track_base_height_offset( if (!found) { log_error("Track map element part not found!"); - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); } // track_remove returns here on failure, not sure when this would ever be hit. Only thing I can think of is for when @@ -930,18 +932,18 @@ GameActionResult::Ptr tile_inspector_track_base_height_offset( // TODO: Only invalidate when one of the affected tiles is selected window_invalidate_by_class(WC_TILE_INSPECTOR); - return std::make_unique(); + return std::make_unique(); } // Sets chainlift, optionally for an entire track block // Broxzier: Basically a copy of the above function, with just two different lines... should probably be combined somehow -GameActionResult::Ptr tile_inspector_track_set_chain( +GameActionResultPtr tile_inspector_track_set_chain( const CoordsXY& loc, int32_t elementIndex, bool entireTrackBlock, bool setChain, bool isExecuting) { TileElement* const trackElement = map_get_nth_element_at(loc, elementIndex); if (trackElement == nullptr || trackElement->GetType() != TILE_ELEMENT_TYPE_TRACK) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -953,7 +955,7 @@ GameActionResult::Ptr tile_inspector_track_set_chain( trackElement->AsTrack()->SetHasChain(setChain); } - return std::make_unique(); + return std::make_unique(); } auto type = trackElement->AsTrack()->GetTrackType(); @@ -964,7 +966,7 @@ GameActionResult::Ptr tile_inspector_track_set_chain( auto rideIndex = trackElement->AsTrack()->GetRideIndex(); auto ride = get_ride(rideIndex); if (ride == nullptr) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); auto trackBlock = get_track_def_from_ride(ride, type); trackBlock += trackElement->AsTrack()->GetSequenceIndex(); @@ -1019,7 +1021,7 @@ GameActionResult::Ptr tile_inspector_track_set_chain( if (!found) { log_error("Track map element part not found!"); - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); } // track_remove returns here on failure, not sure when this would ever be hit. Only thing I can think of is for when @@ -1039,16 +1041,16 @@ GameActionResult::Ptr tile_inspector_track_set_chain( // TODO: Only invalidate when one of the affected tiles is selected window_invalidate_by_class(WC_TILE_INSPECTOR); - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_track_set_block_brake( +GameActionResultPtr tile_inspector_track_set_block_brake( const CoordsXY& loc, int32_t elementIndex, bool blockBrake, bool isExecuting) { TileElement* const trackElement = map_get_nth_element_at(loc, elementIndex); if (trackElement == nullptr || trackElement->GetType() != TILE_ELEMENT_TYPE_TRACK) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -1063,16 +1065,16 @@ GameActionResult::Ptr tile_inspector_track_set_block_brake( } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_track_set_indestructible( +GameActionResultPtr tile_inspector_track_set_indestructible( const CoordsXY& loc, int32_t elementIndex, bool isIndestructible, bool isExecuting) { TileElement* const trackElement = map_get_nth_element_at(loc, elementIndex); if (trackElement == nullptr || trackElement->GetType() != TILE_ELEMENT_TYPE_TRACK) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -1087,16 +1089,16 @@ GameActionResult::Ptr tile_inspector_track_set_indestructible( } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_scenery_set_quarter_location( +GameActionResultPtr tile_inspector_scenery_set_quarter_location( const CoordsXY& loc, int32_t elementIndex, int32_t quarterIndex, bool isExecuting) { TileElement* const tileElement = map_get_nth_element_at(loc, elementIndex); if (tileElement == nullptr || tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -1113,16 +1115,16 @@ GameActionResult::Ptr tile_inspector_scenery_set_quarter_location( } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_scenery_set_quarter_collision( +GameActionResultPtr tile_inspector_scenery_set_quarter_collision( const CoordsXY& loc, int32_t elementIndex, int32_t quarterIndex, bool isExecuting) { TileElement* const tileElement = map_get_nth_element_at(loc, elementIndex); if (tileElement == nullptr || tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -1137,16 +1139,16 @@ GameActionResult::Ptr tile_inspector_scenery_set_quarter_collision( } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_banner_toggle_blocking_edge( +GameActionResultPtr tile_inspector_banner_toggle_blocking_edge( const CoordsXY& loc, int32_t elementIndex, int32_t edgeIndex, bool isExecuting) { TileElement* const bannerElement = map_get_nth_element_at(loc, elementIndex); if (bannerElement == nullptr || bannerElement->GetType() != TILE_ELEMENT_TYPE_BANNER) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -1160,18 +1162,18 @@ GameActionResult::Ptr tile_inspector_banner_toggle_blocking_edge( } } - return std::make_unique(); + return std::make_unique(); } -GameActionResult::Ptr tile_inspector_corrupt_clamp(const CoordsXY& loc, int32_t elementIndex, bool isExecuting) +GameActionResultPtr tile_inspector_corrupt_clamp(const CoordsXY& loc, int32_t elementIndex, bool isExecuting) { TileElement* const corruptElement = map_get_nth_element_at(loc, elementIndex); if (corruptElement == nullptr || corruptElement->GetType() != TILE_ELEMENT_TYPE_CORRUPT) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (corruptElement->IsLastForTile()) - return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); + return std::make_unique(GameActions::Status::Unknown, STR_NONE); if (isExecuting) { @@ -1184,5 +1186,5 @@ GameActionResult::Ptr tile_inspector_corrupt_clamp(const CoordsXY& loc, int32_t } } - return std::make_unique(); + return std::make_unique(); } diff --git a/src/openrct2/world/TileInspector.h b/src/openrct2/world/TileInspector.h index a4b375dce5..255bfbf763 100644 --- a/src/openrct2/world/TileInspector.h +++ b/src/openrct2/world/TileInspector.h @@ -26,8 +26,12 @@ enum TILE_INSPECTOR_ELEMENT_TYPE TILE_INSPECTOR_ELEMENT_CORRUPT, }; -class GameActionResult; -using GameActionResultPtr = std::unique_ptr; +namespace GameActions +{ + class Result; +} + +using GameActionResultPtr = std::unique_ptr; GameActionResultPtr tile_inspector_insert_corrupt_at(const CoordsXY& loc, int16_t elementIndex, bool isExecuting); GameActionResultPtr tile_inspector_remove_element_at(const CoordsXY& loc, int16_t elementIndex, bool isExecuting); GameActionResultPtr tile_inspector_swap_elements_at(const CoordsXY& loc, int16_t first, int16_t second, bool isExecuting);