From 4446ff9f6f50ddb6a19eb02a82a07a542e5079f8 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Mon, 8 Sep 2025 16:21:29 +0200 Subject: [PATCH] Pass game state ref as parameter to game actions (#25065) --- src/openrct2-ui/input/Shortcuts.cpp | 11 +- .../interface/ViewportInteraction.cpp | 15 ++- src/openrct2-ui/ride/Construction.cpp | 2 +- src/openrct2-ui/windows/Banner.cpp | 15 ++- src/openrct2-ui/windows/Cheats.cpp | 9 +- src/openrct2-ui/windows/ClearScenery.cpp | 6 +- .../windows/DemolishRidePrompt.cpp | 2 +- .../windows/EditorParkEntrance.cpp | 5 +- .../windows/EditorScenarioOptions.cpp | 70 +++++----- src/openrct2-ui/windows/Finances.cpp | 4 +- src/openrct2-ui/windows/Footpath.cpp | 16 +-- src/openrct2-ui/windows/Guest.cpp | 11 +- src/openrct2-ui/windows/Land.cpp | 24 ++-- src/openrct2-ui/windows/LandRights.cpp | 10 +- src/openrct2-ui/windows/Map.cpp | 8 +- src/openrct2-ui/windows/MazeConstruction.cpp | 7 +- src/openrct2-ui/windows/Multiplayer.cpp | 13 +- src/openrct2-ui/windows/NewCampaign.cpp | 3 +- src/openrct2-ui/windows/Options.cpp | 3 +- src/openrct2-ui/windows/Park.cpp | 10 +- src/openrct2-ui/windows/PatrolArea.cpp | 2 +- src/openrct2-ui/windows/Player.cpp | 5 +- .../windows/RefurbishRidePrompt.cpp | 2 +- src/openrct2-ui/windows/Research.cpp | 4 +- src/openrct2-ui/windows/Ride.cpp | 49 +++---- src/openrct2-ui/windows/RideConstruction.cpp | 31 +++-- src/openrct2-ui/windows/RideList.cpp | 6 +- src/openrct2-ui/windows/Scenery.cpp | 39 +++--- src/openrct2-ui/windows/Sign.cpp | 14 +- src/openrct2-ui/windows/Staff.cpp | 16 ++- src/openrct2-ui/windows/StaffFirePrompt.cpp | 2 +- src/openrct2-ui/windows/StaffList.cpp | 14 +- src/openrct2-ui/windows/TileInspector.cpp | 51 ++++---- src/openrct2-ui/windows/TitleMenu.cpp | 3 +- src/openrct2-ui/windows/TopToolbar.cpp | 12 +- src/openrct2-ui/windows/TrackDesignPlace.cpp | 8 +- src/openrct2-ui/windows/Water.cpp | 15 ++- src/openrct2/Cheats.cpp | 2 +- src/openrct2/Editor.cpp | 5 +- src/openrct2/Game.cpp | 14 +- src/openrct2/ReplayManager.cpp | 5 +- src/openrct2/actions/BalloonPressAction.cpp | 6 +- src/openrct2/actions/BalloonPressAction.h | 4 +- src/openrct2/actions/BannerPlaceAction.cpp | 4 +- src/openrct2/actions/BannerPlaceAction.h | 4 +- src/openrct2/actions/BannerRemoveAction.cpp | 4 +- src/openrct2/actions/BannerRemoveAction.h | 4 +- .../actions/BannerSetColourAction.cpp | 4 +- src/openrct2/actions/BannerSetColourAction.h | 4 +- src/openrct2/actions/BannerSetNameAction.cpp | 4 +- src/openrct2/actions/BannerSetNameAction.h | 4 +- src/openrct2/actions/BannerSetStyleAction.cpp | 4 +- src/openrct2/actions/BannerSetStyleAction.h | 4 +- src/openrct2/actions/CheatSetAction.cpp | 17 ++- src/openrct2/actions/CheatSetAction.h | 8 +- src/openrct2/actions/ClearAction.cpp | 37 +++--- src/openrct2/actions/ClearAction.h | 12 +- src/openrct2/actions/CustomAction.cpp | 4 +- src/openrct2/actions/CustomAction.h | 4 +- .../actions/FootpathAdditionPlaceAction.cpp | 4 +- .../actions/FootpathAdditionPlaceAction.h | 4 +- .../actions/FootpathAdditionRemoveAction.cpp | 4 +- .../actions/FootpathAdditionRemoveAction.h | 4 +- .../actions/FootpathLayoutPlaceAction.cpp | 4 +- .../actions/FootpathLayoutPlaceAction.h | 4 +- src/openrct2/actions/FootpathPlaceAction.cpp | 4 +- src/openrct2/actions/FootpathPlaceAction.h | 4 +- src/openrct2/actions/FootpathRemoveAction.cpp | 13 +- src/openrct2/actions/FootpathRemoveAction.h | 6 +- src/openrct2/actions/GameAction.cpp | 28 ++-- src/openrct2/actions/GameAction.h | 17 ++- src/openrct2/actions/GameSetSpeedAction.cpp | 4 +- src/openrct2/actions/GameSetSpeedAction.h | 4 +- src/openrct2/actions/GuestSetFlagsAction.cpp | 6 +- src/openrct2/actions/GuestSetFlagsAction.h | 4 +- src/openrct2/actions/GuestSetNameAction.cpp | 4 +- src/openrct2/actions/GuestSetNameAction.h | 4 +- src/openrct2/actions/LandBuyRightsAction.cpp | 4 +- src/openrct2/actions/LandBuyRightsAction.h | 4 +- src/openrct2/actions/LandLowerAction.cpp | 13 +- src/openrct2/actions/LandLowerAction.h | 6 +- src/openrct2/actions/LandRaiseAction.cpp | 13 +- src/openrct2/actions/LandRaiseAction.h | 6 +- src/openrct2/actions/LandSetHeightAction.cpp | 5 +- src/openrct2/actions/LandSetHeightAction.h | 4 +- src/openrct2/actions/LandSetRightsAction.cpp | 4 +- src/openrct2/actions/LandSetRightsAction.h | 4 +- src/openrct2/actions/LandSmoothAction.cpp | 122 ++++++++++-------- src/openrct2/actions/LandSmoothAction.h | 19 +-- .../actions/LargeSceneryPlaceAction.cpp | 6 +- .../actions/LargeSceneryPlaceAction.h | 4 +- .../actions/LargeSceneryRemoveAction.cpp | 4 +- .../actions/LargeSceneryRemoveAction.h | 4 +- .../actions/LargeScenerySetColourAction.cpp | 4 +- .../actions/LargeScenerySetColourAction.h | 4 +- src/openrct2/actions/LoadOrQuitAction.cpp | 4 +- src/openrct2/actions/LoadOrQuitAction.h | 4 +- src/openrct2/actions/MapChangeSizeAction.cpp | 5 +- src/openrct2/actions/MapChangeSizeAction.h | 4 +- src/openrct2/actions/MazePlaceTrackAction.cpp | 6 +- src/openrct2/actions/MazePlaceTrackAction.h | 4 +- src/openrct2/actions/MazeSetTrackAction.cpp | 6 +- src/openrct2/actions/MazeSetTrackAction.h | 4 +- .../actions/NetworkModifyGroupAction.cpp | 4 +- .../actions/NetworkModifyGroupAction.h | 4 +- .../actions/ParkEntrancePlaceAction.cpp | 5 +- .../actions/ParkEntrancePlaceAction.h | 4 +- .../actions/ParkEntranceRemoveAction.cpp | 4 +- .../actions/ParkEntranceRemoveAction.h | 4 +- src/openrct2/actions/ParkMarketingAction.cpp | 4 +- src/openrct2/actions/ParkMarketingAction.h | 4 +- src/openrct2/actions/ParkSetDateAction.cpp | 5 +- src/openrct2/actions/ParkSetDateAction.h | 4 +- .../actions/ParkSetEntranceFeeAction.cpp | 4 +- .../actions/ParkSetEntranceFeeAction.h | 4 +- src/openrct2/actions/ParkSetLoanAction.cpp | 4 +- src/openrct2/actions/ParkSetLoanAction.h | 4 +- src/openrct2/actions/ParkSetNameAction.cpp | 4 +- src/openrct2/actions/ParkSetNameAction.h | 4 +- .../actions/ParkSetParameterAction.cpp | 4 +- src/openrct2/actions/ParkSetParameterAction.h | 4 +- .../actions/ParkSetResearchFundingAction.cpp | 5 +- .../actions/ParkSetResearchFundingAction.h | 4 +- src/openrct2/actions/PauseToggleAction.cpp | 4 +- src/openrct2/actions/PauseToggleAction.h | 4 +- src/openrct2/actions/PeepPickupAction.cpp | 8 +- src/openrct2/actions/PeepPickupAction.h | 4 +- src/openrct2/actions/PeepSpawnPlaceAction.cpp | 5 +- src/openrct2/actions/PeepSpawnPlaceAction.h | 4 +- src/openrct2/actions/PlayerKickAction.cpp | 4 +- src/openrct2/actions/PlayerKickAction.h | 4 +- src/openrct2/actions/PlayerSetGroupAction.cpp | 4 +- src/openrct2/actions/PlayerSetGroupAction.h | 4 +- src/openrct2/actions/RideCreateAction.cpp | 5 +- src/openrct2/actions/RideCreateAction.h | 4 +- src/openrct2/actions/RideDemolishAction.cpp | 32 +++-- src/openrct2/actions/RideDemolishAction.h | 12 +- .../actions/RideEntranceExitPlaceAction.cpp | 8 +- .../actions/RideEntranceExitPlaceAction.h | 4 +- .../actions/RideEntranceExitRemoveAction.cpp | 4 +- .../actions/RideEntranceExitRemoveAction.h | 4 +- .../actions/RideFreezeRatingAction.cpp | 4 +- src/openrct2/actions/RideFreezeRatingAction.h | 4 +- .../actions/RideSetAppearanceAction.cpp | 4 +- .../actions/RideSetAppearanceAction.h | 4 +- .../actions/RideSetColourSchemeAction.cpp | 4 +- .../actions/RideSetColourSchemeAction.h | 4 +- src/openrct2/actions/RideSetNameAction.cpp | 4 +- src/openrct2/actions/RideSetNameAction.h | 4 +- src/openrct2/actions/RideSetPriceAction.cpp | 4 +- src/openrct2/actions/RideSetPriceAction.h | 4 +- src/openrct2/actions/RideSetSettingAction.cpp | 4 +- src/openrct2/actions/RideSetSettingAction.h | 4 +- src/openrct2/actions/RideSetStatusAction.cpp | 4 +- src/openrct2/actions/RideSetStatusAction.h | 4 +- src/openrct2/actions/RideSetVehicleAction.cpp | 4 +- src/openrct2/actions/RideSetVehicleAction.h | 4 +- .../actions/ScenarioSetSettingAction.cpp | 5 +- .../actions/ScenarioSetSettingAction.h | 4 +- .../actions/ScenerySetRestrictedAction.cpp | 4 +- .../actions/ScenerySetRestrictedAction.h | 4 +- src/openrct2/actions/SignSetNameAction.cpp | 4 +- src/openrct2/actions/SignSetNameAction.h | 4 +- src/openrct2/actions/SignSetStyleAction.cpp | 4 +- src/openrct2/actions/SignSetStyleAction.h | 4 +- .../actions/SmallSceneryPlaceAction.cpp | 5 +- .../actions/SmallSceneryPlaceAction.h | 4 +- .../actions/SmallSceneryRemoveAction.cpp | 4 +- .../actions/SmallSceneryRemoveAction.h | 4 +- .../actions/SmallScenerySetColourAction.cpp | 4 +- .../actions/SmallScenerySetColourAction.h | 4 +- src/openrct2/actions/StaffFireAction.cpp | 4 +- src/openrct2/actions/StaffFireAction.h | 4 +- src/openrct2/actions/StaffHireNewAction.cpp | 4 +- src/openrct2/actions/StaffHireNewAction.h | 4 +- src/openrct2/actions/StaffSetColourAction.cpp | 4 +- src/openrct2/actions/StaffSetColourAction.h | 4 +- .../actions/StaffSetCostumeAction.cpp | 4 +- src/openrct2/actions/StaffSetCostumeAction.h | 4 +- src/openrct2/actions/StaffSetNameAction.cpp | 4 +- src/openrct2/actions/StaffSetNameAction.h | 4 +- src/openrct2/actions/StaffSetOrdersAction.cpp | 4 +- src/openrct2/actions/StaffSetOrdersAction.h | 4 +- .../actions/StaffSetPatrolAreaAction.cpp | 4 +- .../actions/StaffSetPatrolAreaAction.h | 4 +- .../actions/SurfaceSetStyleAction.cpp | 6 +- src/openrct2/actions/SurfaceSetStyleAction.h | 4 +- src/openrct2/actions/TileModifyAction.cpp | 4 +- src/openrct2/actions/TileModifyAction.h | 4 +- src/openrct2/actions/TrackDesignAction.cpp | 24 ++-- src/openrct2/actions/TrackDesignAction.h | 4 +- src/openrct2/actions/TrackPlaceAction.cpp | 8 +- src/openrct2/actions/TrackPlaceAction.h | 4 +- src/openrct2/actions/TrackRemoveAction.cpp | 6 +- src/openrct2/actions/TrackRemoveAction.h | 4 +- .../actions/TrackSetBrakeSpeedAction.cpp | 4 +- .../actions/TrackSetBrakeSpeedAction.h | 4 +- src/openrct2/actions/WallPlaceAction.cpp | 7 +- src/openrct2/actions/WallPlaceAction.h | 4 +- src/openrct2/actions/WallRemoveAction.cpp | 4 +- src/openrct2/actions/WallRemoveAction.h | 4 +- src/openrct2/actions/WallSetColourAction.cpp | 4 +- src/openrct2/actions/WallSetColourAction.h | 4 +- src/openrct2/actions/WaterLowerAction.cpp | 17 +-- src/openrct2/actions/WaterLowerAction.h | 8 +- src/openrct2/actions/WaterRaiseAction.cpp | 17 +-- src/openrct2/actions/WaterRaiseAction.h | 8 +- src/openrct2/actions/WaterSetHeightAction.cpp | 5 +- src/openrct2/actions/WaterSetHeightAction.h | 4 +- src/openrct2/interface/InteractiveConsole.cpp | 20 +-- src/openrct2/management/Research.cpp | 3 +- src/openrct2/network/NetworkBase.cpp | 4 +- src/openrct2/rct12/ScenarioPatcher.cpp | 3 +- src/openrct2/ride/Ride.cpp | 12 +- src/openrct2/ride/RideConstruction.cpp | 14 +- src/openrct2/ride/TrackDesign.cpp | 47 ++++--- src/openrct2/ride/Vehicle.cpp | 6 +- .../scripting/bindings/game/ScContext.hpp | 4 +- .../scripting/bindings/network/ScNetwork.cpp | 13 +- .../scripting/bindings/network/ScPlayer.cpp | 3 +- .../bindings/network/ScPlayerGroup.cpp | 7 +- src/openrct2/world/Entrance.cpp | 6 +- src/openrct2/world/Footpath.cpp | 2 +- src/openrct2/world/Map.cpp | 10 +- src/openrct2/world/Park.cpp | 2 +- src/openrct2/world/Scenery.cpp | 12 +- test/tests/PlayTests.cpp | 2 +- 227 files changed, 927 insertions(+), 848 deletions(-) diff --git a/src/openrct2-ui/input/Shortcuts.cpp b/src/openrct2-ui/input/Shortcuts.cpp index 45018b6e98..713ebcd5a3 100644 --- a/src/openrct2-ui/input/Shortcuts.cpp +++ b/src/openrct2-ui/input/Shortcuts.cpp @@ -430,7 +430,7 @@ static void ShortcutLoadGame() if (!(isInTrackDesignerOrManager())) { auto loadOrQuitAction = GameActions::LoadOrQuitAction(GameActions::LoadOrQuitModes::OpenSavePrompt); - GameActions::Execute(&loadOrQuitAction); + GameActions::Execute(&loadOrQuitAction, getGameState()); } } @@ -525,7 +525,7 @@ static void ShortcutToggleWallSlope() auto modifyTile = GameActions::TileModifyAction( windowTileInspectorTile.ToCoordsXY(), GameActions::TileModifyType::WallSetSlope, windowTileInspectorSelectedIndex, newSlopeValue); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } static void ShortcutIncreaseElementHeight() @@ -610,9 +610,10 @@ static void ShortcutDecreaseElementHeight() static void ShortcutToggleClearanceChecks() { + auto& gameState = getGameState(); auto cheatSetAction = GameActions::CheatSetAction( - CheatType::DisableClearanceChecks, getGameState().cheats.disableClearanceChecks ? 0 : 1); - GameActions::Execute(&cheatSetAction); + CheatType::DisableClearanceChecks, gameState.cheats.disableClearanceChecks ? 0 : 1); + GameActions::Execute(&cheatSetAction, gameState); } static void ShortcutToggleConsole() @@ -784,7 +785,7 @@ void ShortcutManager::RegisterDefaultShortcuts() if (gLegacyScene != LegacyScene::titleSequence && gLegacyScene != LegacyScene::scenarioEditor && gLegacyScene != LegacyScene::trackDesignsManager) { auto pauseToggleAction = GameActions::PauseToggleAction(); - GameActions::Execute(&pauseToggleAction); + GameActions::Execute(&pauseToggleAction, getGameState()); } }); RegisterShortcut(ShortcutId::kInterfaceDecreaseSpeed, STR_SHORTCUT_REDUCE_GAME_SPEED, "-", ShortcutReduceGameSpeed); diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 3e89975c48..764ed36ce0 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -196,6 +196,7 @@ namespace OpenRCT2::Ui bool ViewportInteractionLeftClick(const ScreenCoordsXY& screenCoords) { auto info = ViewportInteractionGetItemLeft(screenCoords); + auto& gameState = getGameState(); switch (info.interactionType) { @@ -224,7 +225,7 @@ namespace OpenRCT2::Ui if (GameIsNotPaused()) { auto balloonPress = GameActions::BalloonPressAction(entity->Id); - GameActions::Execute(&balloonPress); + GameActions::Execute(&balloonPress, gameState); } } break; @@ -627,7 +628,7 @@ namespace OpenRCT2::Ui { mapCoords.x, mapCoords.y, smallSceneryElement.GetBaseZ() }, smallSceneryElement.GetSceneryQuadrant(), smallSceneryElement.GetEntryIndex()); - GameActions::Execute(&removeSceneryAction); + GameActions::Execute(&removeSceneryAction, getGameState()); } /** @@ -651,7 +652,7 @@ namespace OpenRCT2::Ui if (tileElement2->GetType() == TileElementType::Path && tileElement2->GetBaseZ() == z) { auto action = GameActions::FootpathRemoveAction({ mapCoords, z }); - GameActions::Execute(&action); + GameActions::Execute(&action, getGameState()); break; } } while (!(tileElement2++)->IsLastForTile()); @@ -665,7 +666,7 @@ namespace OpenRCT2::Ui { auto footpathAdditionRemoveAction = GameActions::FootpathAdditionRemoveAction( { mapCoords.x, mapCoords.y, pathElement.GetBaseZ() }); - GameActions::Execute(&footpathAdditionRemoveAction); + GameActions::Execute(&footpathAdditionRemoveAction, getGameState()); } /** @@ -686,7 +687,7 @@ namespace OpenRCT2::Ui } auto parkEntranceRemoveAction = GameActions::ParkEntranceRemoveAction( { mapCoords.x, mapCoords.y, entranceElement.GetBaseZ() }); - GameActions::Execute(&parkEntranceRemoveAction); + GameActions::Execute(&parkEntranceRemoveAction, getGameState()); } /** @@ -704,7 +705,7 @@ namespace OpenRCT2::Ui { CoordsXYZD wallLocation = { mapCoords.x, mapCoords.y, wallElement.GetBaseZ(), wallElement.GetDirection() }; auto wallRemoveAction = GameActions::WallRemoveAction(wallLocation); - GameActions::Execute(&wallRemoveAction); + GameActions::Execute(&wallRemoveAction, getGameState()); } } @@ -726,7 +727,7 @@ namespace OpenRCT2::Ui auto removeSceneryAction = GameActions::LargeSceneryRemoveAction( { mapCoords.x, mapCoords.y, largeSceneryElement.GetBaseZ(), largeSceneryElement.GetDirection() }, largeSceneryElement.GetSequenceIndex()); - GameActions::Execute(&removeSceneryAction); + GameActions::Execute(&removeSceneryAction, getGameState()); } } diff --git a/src/openrct2-ui/ride/Construction.cpp b/src/openrct2-ui/ride/Construction.cpp index 06868839f2..921e67c822 100644 --- a/src/openrct2-ui/ride/Construction.cpp +++ b/src/openrct2-ui/ride/Construction.cpp @@ -241,7 +241,7 @@ namespace OpenRCT2 RideConstructionStart(*ride); }); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } SpecialElementsDropdownState BuildSpecialElementsList( diff --git a/src/openrct2-ui/windows/Banner.cpp b/src/openrct2-ui/windows/Banner.cpp index f4a6a6fa71..7526999f45 100644 --- a/src/openrct2-ui/windows/Banner.cpp +++ b/src/openrct2-ui/windows/Banner.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -191,6 +192,9 @@ namespace OpenRCT2::Ui::Windows Close(); return; } + + auto& gameState = getGameState(); + switch (widgetIndex) { case WIDX_CLOSE: @@ -204,7 +208,7 @@ namespace OpenRCT2::Ui::Windows auto bannerRemoveAction = GameActions::BannerRemoveAction( { banner->position.ToCoordsXY(), bannerElement->GetBaseZ(), bannerElement->GetPosition() }); - GameActions::Execute(&bannerRemoveAction); + GameActions::Execute(&bannerRemoveAction, gameState); break; } case WIDX_BANNER_TEXT: @@ -216,7 +220,7 @@ namespace OpenRCT2::Ui::Windows TextinputCancel(); auto bannerSetStyle = GameActions::BannerSetStyleAction( GameActions::BannerSetStyleType::NoEntry, GetBannerIndex(), !banner->flags.has(BannerFlag::noEntry)); - GameActions::Execute(&bannerSetStyle); + GameActions::Execute(&bannerSetStyle, gameState); break; } } @@ -224,6 +228,7 @@ namespace OpenRCT2::Ui::Windows void OnDropdown(WidgetIndex widgetIndex, int32_t dropdownIndex) override { + auto& gameState = getGameState(); switch (widgetIndex) { case WIDX_MAIN_COLOUR: @@ -234,7 +239,7 @@ namespace OpenRCT2::Ui::Windows auto bannerSetStyle = GameActions::BannerSetStyleAction( GameActions::BannerSetStyleType::PrimaryColour, GetBannerIndex(), ColourDropDownIndexToColour(dropdownIndex)); - GameActions::Execute(&bannerSetStyle); + GameActions::Execute(&bannerSetStyle, gameState); break; } case WIDX_TEXT_COLOUR_DROPDOWN_BUTTON: @@ -243,7 +248,7 @@ namespace OpenRCT2::Ui::Windows break; auto bannerSetStyle = GameActions::BannerSetStyleAction( GameActions::BannerSetStyleType::TextColour, GetBannerIndex(), dropdownIndex + 1); - GameActions::Execute(&bannerSetStyle); + GameActions::Execute(&bannerSetStyle, gameState); break; } } @@ -254,7 +259,7 @@ namespace OpenRCT2::Ui::Windows if (widgetIndex == WIDX_BANNER_TEXT) { auto bannerSetNameAction = GameActions::BannerSetNameAction(GetBannerIndex(), std::string(text)); - GameActions::Execute(&bannerSetNameAction); + GameActions::Execute(&bannerSetNameAction, getGameState()); } } diff --git a/src/openrct2-ui/windows/Cheats.cpp b/src/openrct2-ui/windows/Cheats.cpp index b5f80621be..19753844c6 100644 --- a/src/openrct2-ui/windows/Cheats.cpp +++ b/src/openrct2-ui/windows/Cheats.cpp @@ -865,7 +865,8 @@ static StringId window_cheats_page_titles[] = { void OnMouseDownDate(WidgetIndex widgetIndex) { - auto* windowMgr = Ui::GetWindowManager(); + auto* windowMgr = GetWindowManager(); + auto& gameState = getGameState(); switch (widgetIndex) { @@ -911,14 +912,14 @@ static StringId window_cheats_page_titles[] = { { auto setDateAction = GameActions::ParkSetDateAction( _yearSpinnerValue - 1, _monthSpinnerValue - 1, _daySpinnerValue - 1); - GameActions::Execute(&setDateAction); + GameActions::Execute(&setDateAction, gameState); windowMgr->InvalidateByClass(WindowClass::BottomToolbar); break; } case WIDX_DATE_RESET: { auto setDateAction = GameActions::ParkSetDateAction(0, 0, 0); - GameActions::Execute(&setDateAction); + GameActions::Execute(&setDateAction, gameState); windowMgr->InvalidateByClass(WindowClass::BottomToolbar); InvalidateWidget(WIDX_YEAR_BOX); InvalidateWidget(WIDX_MONTH_BOX); @@ -961,7 +962,7 @@ static StringId window_cheats_page_titles[] = { { auto cheatSetAction = GameActions::CheatSetAction( CheatType::SetForcedParkRating, _parkRatingSpinnerValue); - GameActions::Execute(&cheatSetAction); + GameActions::Execute(&cheatSetAction, getGameState()); } break; case WIDX_DECREASE_PARK_RATING: diff --git a/src/openrct2-ui/windows/ClearScenery.cpp b/src/openrct2-ui/windows/ClearScenery.cpp index 8f5ce3e745..538a527c7b 100644 --- a/src/openrct2-ui/windows/ClearScenery.cpp +++ b/src/openrct2-ui/windows/ClearScenery.cpp @@ -289,7 +289,7 @@ namespace OpenRCT2::Ui::Windows return; auto action = GetClearAction(); - auto result = GameActions::Query(&action); + auto result = GameActions::Query(&action, getGameState()); auto cost = (result.Error == GameActions::Status::Ok ? result.Cost : kMoney64Undefined); if (_clearSceneryCost != cost) { @@ -317,7 +317,7 @@ namespace OpenRCT2::Ui::Windows if (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) { auto action = GetClearAction(); - GameActions::Execute(&action); + GameActions::Execute(&action, getGameState()); gCurrentToolId = Tool::bulldozer; } break; @@ -334,7 +334,7 @@ namespace OpenRCT2::Ui::Windows if (windowMgr->FindByClass(WindowClass::Error) == nullptr && (gMapSelectFlags & MAP_SELECT_FLAG_ENABLE)) { auto action = GetClearAction(); - GameActions::Execute(&action); + GameActions::Execute(&action, getGameState()); gCurrentToolId = Tool::bulldozer; } break; diff --git a/src/openrct2-ui/windows/DemolishRidePrompt.cpp b/src/openrct2-ui/windows/DemolishRidePrompt.cpp index c7d63832e4..71b4c9a7d9 100644 --- a/src/openrct2-ui/windows/DemolishRidePrompt.cpp +++ b/src/openrct2-ui/windows/DemolishRidePrompt.cpp @@ -63,7 +63,7 @@ namespace OpenRCT2::Ui::Windows case WIDX_DEMOLISH: { auto gameAction = GameActions::RideDemolishAction(rideId, GameActions::RideModifyType::demolish); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); break; } case WIDX_CANCEL: diff --git a/src/openrct2-ui/windows/EditorParkEntrance.cpp b/src/openrct2-ui/windows/EditorParkEntrance.cpp index 4dcccb28d8..df2af7ecd5 100644 --- a/src/openrct2-ui/windows/EditorParkEntrance.cpp +++ b/src/openrct2-ui/windows/EditorParkEntrance.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -200,7 +201,7 @@ namespace OpenRCT2::Ui::Windows parkEntrancePosition, gFootpathSelectedId, _selectedEntranceType); gameAction.SetFlags(GAME_COMMAND_FLAG_GHOST); - auto result = GameActions::Execute(&gameAction); + auto result = GameActions::Execute(&gameAction, getGameState()); if (result.Error == GameActions::Status::Ok) { gParkEntranceGhostPosition = parkEntrancePosition; @@ -217,7 +218,7 @@ namespace OpenRCT2::Ui::Windows { auto gameAction = GameActions::ParkEntrancePlaceAction( parkEntrancePosition, gFootpathSelectedId, _selectedEntranceType); - auto result = GameActions::Execute(&gameAction); + auto result = GameActions::Execute(&gameAction, getGameState()); if (result.Error == GameActions::Status::Ok) { Audio::Play3D(Audio::SoundId::PlaceItem, result.Position); diff --git a/src/openrct2-ui/windows/EditorScenarioOptions.cpp b/src/openrct2-ui/windows/EditorScenarioOptions.cpp index 8cc5347596..f865740f24 100644 --- a/src/openrct2-ui/windows/EditorScenarioOptions.cpp +++ b/src/openrct2-ui/windows/EditorScenarioOptions.cpp @@ -966,7 +966,7 @@ namespace OpenRCT2::Ui::Windows auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::ParkRatingHigherDifficultyLevel, gameState.park.flags & PARK_FLAGS_DIFFICULT_PARK_RATING ? 0 : 1); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); Invalidate(); break; } @@ -1338,7 +1338,7 @@ namespace OpenRCT2::Ui::Windows case WIDX_PARK_NAME: { auto action = GameActions::ParkSetNameAction(std::string(text)); - GameActions::Execute(&action); + GameActions::Execute(&action, gameState); if (scenarioOptions.name.empty()) { @@ -1382,7 +1382,7 @@ namespace OpenRCT2::Ui::Windows auto newMoneySetting = (gameState.park.flags & PARK_FLAGS_NO_MONEY) ? 0 : 1; auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::NoMoney, newMoneySetting); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); Invalidate(); break; } @@ -1391,7 +1391,7 @@ namespace OpenRCT2::Ui::Windows auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::ForbidMarketingCampaigns, gameState.park.flags & PARK_FLAGS_FORBID_MARKETING_CAMPAIGN ? 0 : 1); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); Invalidate(); break; } @@ -1400,7 +1400,7 @@ namespace OpenRCT2::Ui::Windows auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::UseRCT1Interest, gameState.park.flags & PARK_FLAGS_RCT1_INTEREST ? 0 : 1); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); Invalidate(); break; } @@ -1422,7 +1422,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::InitialCash, gameState.scenarioOptions.initialCash + 500.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1435,7 +1435,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::InitialCash, gameState.scenarioOptions.initialCash - 500.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1448,7 +1448,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::InitialLoan, gameState.park.bankLoan + 1000.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1461,7 +1461,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::InitialLoan, gameState.park.bankLoan - 1000.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1474,7 +1474,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::MaximumLoanSize, gameState.park.maxBankLoan + 1000.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1487,7 +1487,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::MaximumLoanSize, gameState.park.maxBankLoan - 1000.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1500,7 +1500,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::AnnualInterestRate, gameState.park.bankLoanInterestRate + 1); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1514,7 +1514,7 @@ namespace OpenRCT2::Ui::Windows auto interest = std::min(kMaxBankLoanInterestRate, gameState.park.bankLoanInterestRate - 1); auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::AnnualInterestRate, interest); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1527,7 +1527,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::ParkChargeEntryFee, gameState.park.entranceFee + 1.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1540,7 +1540,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::ParkChargeEntryFee, gameState.park.entranceFee - 1.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1592,7 +1592,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::ParkChargeMethod, dropdownIndex); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, getGameState()); Invalidate(); break; } @@ -1785,7 +1785,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::AverageCashPerGuest, scenarioOptions.guestInitialCash + 1.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1798,7 +1798,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::AverageCashPerGuest, scenarioOptions.guestInitialCash - 1.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1811,7 +1811,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::GuestInitialHappiness, scenarioOptions.guestInitialHappiness + 4); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1824,7 +1824,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::GuestInitialHappiness, scenarioOptions.guestInitialHappiness - 4); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1837,7 +1837,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::GuestInitialHunger, scenarioOptions.guestInitialHunger - 4); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1850,7 +1850,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::GuestInitialHunger, scenarioOptions.guestInitialHunger + 4); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1863,7 +1863,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::GuestInitialThirst, scenarioOptions.guestInitialThirst - 4); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1876,7 +1876,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::GuestInitialThirst, scenarioOptions.guestInitialThirst + 4); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -1917,7 +1917,7 @@ namespace OpenRCT2::Ui::Windows auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::GuestGenerationHigherDifficultyLevel, gameState.park.flags & PARK_FLAGS_DIFFICULT_GUEST_GENERATION ? 0 : 1); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); Invalidate(); break; } @@ -1932,13 +1932,15 @@ namespace OpenRCT2::Ui::Windows bool preferLess = dropdownIndex == 0 || dropdownIndex == 2; bool preferMore = dropdownIndex == 0 || dropdownIndex == 3; + auto& gameState = getGameState(); + auto scenarioSetLessSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::GuestsPreferLessIntenseRides, preferLess); - GameActions::Execute(&scenarioSetLessSetting); + GameActions::Execute(&scenarioSetLessSetting, gameState); auto scenarioSetMoreSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::GuestsPreferMoreIntenseRides, preferMore); - GameActions::Execute(&scenarioSetMoreSetting); + GameActions::Execute(&scenarioSetMoreSetting, gameState); } void GuestsUpdate() @@ -2044,7 +2046,7 @@ namespace OpenRCT2::Ui::Windows auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::ForbidTreeRemoval, gameState.park.flags & PARK_FLAGS_FORBID_TREE_REMOVAL ? 0 : 1); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); Invalidate(); break; } @@ -2053,7 +2055,7 @@ namespace OpenRCT2::Ui::Windows auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::ForbidLandscapeChanges, gameState.park.flags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES ? 0 : 1); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); Invalidate(); break; } @@ -2062,7 +2064,7 @@ namespace OpenRCT2::Ui::Windows auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::ForbidHighConstruction, gameState.park.flags & PARK_FLAGS_FORBID_HIGH_CONSTRUCTION ? 0 : 1); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); Invalidate(); break; } @@ -2086,7 +2088,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::CostToBuyLand, scenarioOptions.landPrice + 1.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -2099,7 +2101,7 @@ namespace OpenRCT2::Ui::Windows { auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::CostToBuyLand, scenarioOptions.landPrice - 1.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -2113,7 +2115,7 @@ namespace OpenRCT2::Ui::Windows auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::CostToBuyConstructionRights, scenarioOptions.constructionRightsPrice + 1.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { @@ -2127,7 +2129,7 @@ namespace OpenRCT2::Ui::Windows auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::CostToBuyConstructionRights, scenarioOptions.constructionRightsPrice - 1.00_GBP); - GameActions::Execute(&scenarioSetSetting); + GameActions::Execute(&scenarioSetSetting, gameState); } else { diff --git a/src/openrct2-ui/windows/Finances.cpp b/src/openrct2-ui/windows/Finances.cpp index 93767afa31..c7da283112 100644 --- a/src/openrct2-ui/windows/Finances.cpp +++ b/src/openrct2-ui/windows/Finances.cpp @@ -548,7 +548,7 @@ namespace OpenRCT2::Ui::Windows newLoan = std::min(gameState.park.maxBankLoan, newLoan); } auto gameAction = GameActions::ParkSetLoanAction(newLoan); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, gameState); break; } case WIDX_LOAN_DECREASE: @@ -564,7 +564,7 @@ namespace OpenRCT2::Ui::Windows newLoan = std::max(static_cast(0LL), newLoan); } auto gameAction = GameActions::ParkSetLoanAction(newLoan); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, gameState); } break; } diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 8b410eaf44..35ff65f640 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -1158,7 +1158,7 @@ namespace OpenRCT2::Ui::Windows _footpathErrorOccured = true; } }); - GameActions::Execute(&footpathPlaceAction); + GameActions::Execute(&footpathPlaceAction, getGameState()); } /** @@ -1278,7 +1278,7 @@ namespace OpenRCT2::Ui::Windows } self->WindowFootpathSetEnabledAndPressedWidgets(); }); - GameActions::Execute(&footpathPlaceAction); + GameActions::Execute(&footpathPlaceAction, getGameState()); } /** @@ -1319,7 +1319,7 @@ namespace OpenRCT2::Ui::Windows gFootpathConstructFromPosition.z = tileElement->GetBaseZ(); auto action = GameActions::FootpathRemoveAction(gFootpathConstructFromPosition); - GameActions::Execute(&action); + GameActions::Execute(&action, getGameState()); // Move selection edge = DirectionReverse(edge); @@ -1750,15 +1750,15 @@ namespace OpenRCT2::Ui::Windows ObjectEntryIndex type, ObjectEntryIndex railingsType, const CoordsXYZ& footpathLoc, int32_t slope, PathConstructFlags constructFlags) { - money64 cost; - FootpathRemoveProvisional(); auto footpathPlaceAction = GameActions::FootpathPlaceAction( footpathLoc, slope, type, railingsType, kInvalidDirection, constructFlags); footpathPlaceAction.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); - auto res = GameActions::Execute(&footpathPlaceAction); - cost = res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; + + auto res = GameActions::Execute(&footpathPlaceAction, getGameState()); + money64 cost = res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; + if (res.Error == GameActions::Status::Ok) { _provisionalFootpath.surfaceIndex = type; @@ -1814,7 +1814,7 @@ namespace OpenRCT2::Ui::Windows auto action = GameActions::FootpathRemoveAction(_provisionalFootpath.position); action.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); - GameActions::Execute(&action); + GameActions::Execute(&action, getGameState()); } } diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 6ba3891897..6f881887c0 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -641,6 +641,7 @@ namespace OpenRCT2::Ui::Windows return; } + auto& gameState = getGameState(); switch (widgetIndex) { case WIDX_PICKUP: @@ -666,7 +667,7 @@ namespace OpenRCT2::Ui::Windows ToolSet(*wind, WC_PEEP__WIDX_PICKUP, Tool::picker); } }); - GameActions::Execute(&pickupAction); + GameActions::Execute(&pickupAction, gameState); } break; case WIDX_RENAME: @@ -681,7 +682,7 @@ namespace OpenRCT2::Ui::Windows uint32_t guestFlags = peep->PeepFlags ^ PEEP_FLAGS_TRACKING; auto guestSetFlagsAction = GameActions::GuestSetFlagsAction(EntityId::FromUnderlying(number), guestFlags); - GameActions::Execute(&guestSetFlagsAction); + GameActions::Execute(&guestSetFlagsAction, gameState); } break; } @@ -965,7 +966,7 @@ namespace OpenRCT2::Ui::Windows return; std::string sText(text); auto gameAction = GameActions::GuestSetNameAction(EntityId::FromUnderlying(number), sText); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } void OnToolUpdateOverview(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords) @@ -1031,7 +1032,7 @@ namespace OpenRCT2::Ui::Windows ToolCancel(); gPickupPeepImage = ImageId(); }); - GameActions::Execute(&pickupAction); + GameActions::Execute(&pickupAction, getGameState()); } void OnToolAbortOverview(WidgetIndex widgetIndex) @@ -1043,7 +1044,7 @@ namespace OpenRCT2::Ui::Windows EntityId::FromUnderlying(number), { _pickedPeepX, 0, 0 }, Network::GetCurrentPlayerId() }; - GameActions::Execute(&pickupAction); + GameActions::Execute(&pickupAction, getGameState()); } #pragma endregion diff --git a/src/openrct2-ui/windows/Land.cpp b/src/openrct2-ui/windows/Land.cpp index bc2366ff5c..5170ca359c 100644 --- a/src/openrct2-ui/windows/Land.cpp +++ b/src/openrct2-ui/windows/Land.cpp @@ -338,22 +338,24 @@ namespace OpenRCT2::Ui::Windows centreX += 16; centreY += 16; + auto& gameState = getGameState(); + if (_landToolMountainMode) { auto landSmoothAction = GameActions::LandSmoothAction( { centreX, centreY }, { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, gMapSelectType, false); - auto res = (flag & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landSmoothAction) - : GameActions::Query(&landSmoothAction); + auto res = (flag & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landSmoothAction, gameState) + : GameActions::Query(&landSmoothAction, gameState); return res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; } auto landRaiseAction = GameActions::LandRaiseAction( { centreX, centreY }, { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, gMapSelectType); - auto res = (flag & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landRaiseAction) - : GameActions::Query(&landRaiseAction); + auto res = (flag & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landRaiseAction, gameState) + : GameActions::Query(&landRaiseAction, gameState); return res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; } @@ -369,22 +371,24 @@ namespace OpenRCT2::Ui::Windows centreX += 16; centreY += 16; + auto& gameState = getGameState(); + if (_landToolMountainMode) { auto landSmoothAction = GameActions::LandSmoothAction( { centreX, centreY }, { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, gMapSelectType, true); - auto res = (flag & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landSmoothAction) - : GameActions::Query(&landSmoothAction); + auto res = (flag & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landSmoothAction, gameState) + : GameActions::Query(&landSmoothAction, gameState); return res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; } auto landLowerAction = GameActions::LandLowerAction( { centreX, centreY }, { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, gMapSelectType); - auto res = (flag & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landLowerAction) - : GameActions::Query(&landLowerAction); + auto res = (flag & GAME_COMMAND_FLAG_APPLY) ? GameActions::Execute(&landLowerAction, gameState) + : GameActions::Query(&landLowerAction, gameState); return res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; } @@ -526,7 +530,7 @@ namespace OpenRCT2::Ui::Windows { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, gLandToolTerrainSurface, gLandToolTerrainEdge); - GameActions::Execute(&surfaceSetStyleAction); + GameActions::Execute(&surfaceSetStyleAction, getGameState()); gCurrentToolId = Tool::upDownArrow; } @@ -553,7 +557,7 @@ namespace OpenRCT2::Ui::Windows { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }, gLandToolTerrainSurface, gLandToolTerrainEdge); - GameActions::Execute(&surfaceSetStyleAction); + GameActions::Execute(&surfaceSetStyleAction, getGameState()); // The tool is set to 12 here instead of 3 so that the dragging cursor is not the elevation change // cursor diff --git a/src/openrct2-ui/windows/LandRights.cpp b/src/openrct2-ui/windows/LandRights.cpp index a537ab0367..bd9ffd9eb4 100644 --- a/src/openrct2-ui/windows/LandRights.cpp +++ b/src/openrct2-ui/windows/LandRights.cpp @@ -533,16 +533,17 @@ namespace OpenRCT2::Ui::Windows if (!state_changed) return; + auto& gameState = getGameState(); if (IsOwnershipMode()) { auto landSetRightsAction = GetLandSetAction(); - auto res = GameActions::Query(&landSetRightsAction); + auto res = GameActions::Query(&landSetRightsAction, gameState); _landRightsCost = res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; } else { auto landBuyRightsAction = GetLandBuyAction(); - auto res = GameActions::Query(&landBuyRightsAction); + auto res = GameActions::Query(&landBuyRightsAction, gameState); _landRightsCost = res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; } } @@ -561,15 +562,16 @@ namespace OpenRCT2::Ui::Windows if (screenCoords.x == kLocationNull) return; + auto& gameState = getGameState(); if (IsOwnershipMode()) { auto landSetRightsAction = GetLandSetAction(); - GameActions::Execute(&landSetRightsAction); + GameActions::Execute(&landSetRightsAction, gameState); } else { auto landBuyRightsAction = GetLandBuyAction(); - GameActions::Execute(&landBuyRightsAction); + GameActions::Execute(&landBuyRightsAction, gameState); } } diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 18c681abf9..dfd64e3abe 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -484,7 +484,7 @@ namespace OpenRCT2::Ui::Windows int32_t mapZ = tileElement->GetBaseZ(); auto gameAction = GameActions::PeepSpawnPlaceAction({ mapCoords, mapZ, static_cast(direction) }); - auto result = GameActions::Execute(&gameAction); + auto result = GameActions::Execute(&gameAction, getGameState()); if (result.Error == GameActions::Status::Ok) { Audio::Play3D(Audio::SoundId::PlaceItem, result.Position); @@ -518,7 +518,7 @@ namespace OpenRCT2::Ui::Windows newMapSize.x = size; auto mapChangeSizeAction = GameActions::MapChangeSizeAction(newMapSize); - GameActions::Execute(&mapChangeSizeAction); + GameActions::Execute(&mapChangeSizeAction, getGameState()); Invalidate(); } break; @@ -766,7 +766,7 @@ namespace OpenRCT2::Ui::Windows newMapSize.x++; auto increaseMapSizeAction = GameActions::MapChangeSizeAction(newMapSize); - GameActions::Execute(&increaseMapSizeAction); + GameActions::Execute(&increaseMapSizeAction, getGameState()); } void DecreaseMapSize() @@ -778,7 +778,7 @@ namespace OpenRCT2::Ui::Windows newMapSize.x--; auto decreaseMapSizeAction = GameActions::MapChangeSizeAction(newMapSize); - GameActions::Execute(&decreaseMapSizeAction); + GameActions::Execute(&decreaseMapSizeAction, getGameState()); } void SetMapPixels() diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index 5d0be1ecfb..f690680095 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -134,7 +135,7 @@ namespace OpenRCT2::Ui::Windows { auto gameAction = GameActions::RideDemolishAction(currentRide->id, GameActions::RideModifyType::demolish); gameAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } else { @@ -393,7 +394,7 @@ namespace OpenRCT2::Ui::Windows WindowMazeConstructionUpdatePressedWidgets(); } }); - auto res = GameActions::Execute(&rideEntranceExitPlaceAction); + auto res = GameActions::Execute(&rideEntranceExitPlaceAction, getGameState()); } void WindowMazeConstructionConstruct(int32_t direction) @@ -426,7 +427,7 @@ namespace OpenRCT2::Ui::Windows const auto loc = CoordsXYZD{ x, y, z, static_cast(direction) }; auto action = GameActions::MazeSetTrackAction(loc, false, _currentRideIndex, mode); action.SetFlags(actionFlags); - const auto res = GameActions::Execute(&action); + const auto res = GameActions::Execute(&action, getGameState()); if (res.Error != GameActions::Status::Ok) { return; diff --git a/src/openrct2-ui/windows/Multiplayer.cpp b/src/openrct2-ui/windows/Multiplayer.cpp index bafd4bdd8c..e6b7c83bb3 100644 --- a/src/openrct2-ui/windows/Multiplayer.cpp +++ b/src/openrct2-ui/windows/Multiplayer.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -242,6 +243,8 @@ namespace OpenRCT2::Ui::Windows } break; } + + auto& gameState = getGameState(); switch (page) { case WINDOW_MULTIPLAYER_PAGE_GROUPS: @@ -251,14 +254,14 @@ namespace OpenRCT2::Ui::Windows case WIDX_ADD_GROUP: { auto networkModifyGroup = GameActions::NetworkModifyGroupAction(GameActions::ModifyGroupType::AddGroup); - GameActions::Execute(&networkModifyGroup); + GameActions::Execute(&networkModifyGroup, gameState); break; } case WIDX_REMOVE_GROUP: { auto networkModifyGroup = GameActions::NetworkModifyGroupAction( GameActions::ModifyGroupType::RemoveGroup, _selectedGroup); - GameActions::Execute(&networkModifyGroup); + GameActions::Execute(&networkModifyGroup, gameState); break; } case WIDX_RENAME_GROUP: @@ -483,7 +486,7 @@ namespace OpenRCT2::Ui::Windows { auto networkModifyGroup = GameActions::NetworkModifyGroupAction( GameActions::ModifyGroupType::SetDefault, Network::GetGroupID(selectedIndex)); - GameActions::Execute(&networkModifyGroup); + GameActions::Execute(&networkModifyGroup, getGameState()); break; } case WIDX_SELECTED_GROUP_DROPDOWN: @@ -512,7 +515,7 @@ namespace OpenRCT2::Ui::Windows auto networkModifyGroup = GameActions::NetworkModifyGroupAction( GameActions::ModifyGroupType::SetName, _selectedGroup, std::string(text)); - GameActions::Execute(&networkModifyGroup); + GameActions::Execute(&networkModifyGroup, getGameState()); break; } } @@ -638,7 +641,7 @@ namespace OpenRCT2::Ui::Windows auto networkModifyGroup = GameActions::NetworkModifyGroupAction( GameActions::ModifyGroupType::SetPermissions, _selectedGroup, "", index, GameActions::PermissionState::Toggle); - GameActions::Execute(&networkModifyGroup); + GameActions::Execute(&networkModifyGroup, getGameState()); break; } } diff --git a/src/openrct2-ui/windows/NewCampaign.cpp b/src/openrct2-ui/windows/NewCampaign.cpp index 401345ab04..f1a119051f 100644 --- a/src/openrct2-ui/windows/NewCampaign.cpp +++ b/src/openrct2-ui/windows/NewCampaign.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -272,7 +273,7 @@ namespace OpenRCT2::Ui::Windows windowMgr->CloseByClass(WindowClass::NewCampaign); } }); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); break; } } diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index c0a30d3500..ba60e0ce6d 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -1887,7 +1888,7 @@ namespace OpenRCT2::Ui::Windows { auto setAllowEarlyCompletionAction = GameActions::ScenarioSetSettingAction( GameActions::ScenarioSetSetting::AllowEarlyCompletion, Config::Get().general.AllowEarlyCompletion); - GameActions::Execute(&setAllowEarlyCompletionAction); + GameActions::Execute(&setAllowEarlyCompletionAction, getGameState()); } Config::Save(); Invalidate(); diff --git a/src/openrct2-ui/windows/Park.cpp b/src/openrct2-ui/windows/Park.cpp index 4144508012..bc07751b91 100644 --- a/src/openrct2-ui/windows/Park.cpp +++ b/src/openrct2-ui/windows/Park.cpp @@ -492,7 +492,7 @@ namespace OpenRCT2::Ui::Windows if (widgetIndex == WIDX_RENAME && !text.empty()) { auto action = GameActions::ParkSetNameAction(std::string(text)); - GameActions::Execute(&action); + GameActions::Execute(&action, getGameState()); } } @@ -810,21 +810,21 @@ namespace OpenRCT2::Ui::Windows void OnMouseDownPrice(WidgetIndex widgetIndex) { - const auto& gameState = getGameState(); + auto& gameState = getGameState(); switch (widgetIndex) { case WIDX_INCREASE_PRICE: { const auto newFee = std::min(kMaxEntranceFee, gameState.park.entranceFee + 1.00_GBP); auto gameAction = GameActions::ParkSetEntranceFeeAction(newFee); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, gameState); break; } case WIDX_DECREASE_PRICE: { const auto newFee = std::max(0.00_GBP, gameState.park.entranceFee - 1.00_GBP); auto gameAction = GameActions::ParkSetEntranceFeeAction(newFee); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, gameState); break; } case WIDX_PRICE: @@ -1039,7 +1039,7 @@ namespace OpenRCT2::Ui::Windows money = std::clamp(money, 0.00_GBP, kMaxEntranceFee); auto gameAction = GameActions::ParkSetEntranceFeeAction(money); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } } diff --git a/src/openrct2-ui/windows/PatrolArea.cpp b/src/openrct2-ui/windows/PatrolArea.cpp index a97c9aa9c5..e99f4c44b4 100644 --- a/src/openrct2-ui/windows/PatrolArea.cpp +++ b/src/openrct2-ui/windows/PatrolArea.cpp @@ -223,7 +223,7 @@ namespace OpenRCT2::Ui::Windows { MapRange range(gMapSelectPositionA, gMapSelectPositionB); auto staffSetPatrolAreaAction = GameActions::StaffSetPatrolAreaAction(_staffId, range, _mode); - GameActions::Execute(&staffSetPatrolAreaAction); + GameActions::Execute(&staffSetPatrolAreaAction, getGameState()); } } diff --git a/src/openrct2-ui/windows/Player.cpp b/src/openrct2-ui/windows/Player.cpp index f12e6002f0..a8cafb959a 100644 --- a/src/openrct2-ui/windows/Player.cpp +++ b/src/openrct2-ui/windows/Player.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -509,7 +510,7 @@ namespace OpenRCT2::Ui::Windows case WIDX_KICK: { auto kickPlayerAction = GameActions::PlayerKickAction(number); - GameActions::Execute(&kickPlayerAction); + GameActions::Execute(&kickPlayerAction, getGameState()); } break; } @@ -538,7 +539,7 @@ namespace OpenRCT2::Ui::Windows windowMgr->InvalidateByNumber(windowHandle.first, windowHandle.second); } }); - GameActions::Execute(&playerSetGroupAction); + GameActions::Execute(&playerSetGroupAction, getGameState()); } void ShowGroupDropdownOverview(Widget* widget) diff --git a/src/openrct2-ui/windows/RefurbishRidePrompt.cpp b/src/openrct2-ui/windows/RefurbishRidePrompt.cpp index eb11f009ce..f99e742738 100644 --- a/src/openrct2-ui/windows/RefurbishRidePrompt.cpp +++ b/src/openrct2-ui/windows/RefurbishRidePrompt.cpp @@ -62,7 +62,7 @@ namespace OpenRCT2::Ui::Windows case WIDX_REFURBISH: { auto gameAction = GameActions::RideDemolishAction(rideId, GameActions::RideModifyType::renew); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); break; } case WIDX_CANCEL: diff --git a/src/openrct2-ui/windows/Research.cpp b/src/openrct2-ui/windows/Research.cpp index ac09c9ab4a..7ad6b0a5b8 100644 --- a/src/openrct2-ui/windows/Research.cpp +++ b/src/openrct2-ui/windows/Research.cpp @@ -507,7 +507,7 @@ namespace OpenRCT2::Ui::Windows activeResearchTypes ^= 1uLL << (widgetIndex - (WIDX_TRANSPORT_RIDES + widgetOffset)); auto gameAction = GameActions::ParkSetResearchFundingAction( activeResearchTypes, gameState.researchFundingLevel); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); break; } } @@ -522,7 +522,7 @@ namespace OpenRCT2::Ui::Windows return; auto gameAction = GameActions::ParkSetResearchFundingAction(gameState.researchPriorities, selectedIndex); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } void WindowResearchFundingPrepareDraw(WindowBase* w, WidgetIndex baseWidgetIndex) diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 7ac54a9562..f6bbd89eea 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1673,7 +1673,7 @@ namespace OpenRCT2::Ui::Windows break; } auto gameAction = GameActions::RideSetStatusAction(ride->id, status); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } break; } @@ -2167,6 +2167,7 @@ namespace OpenRCT2::Ui::Windows void MainOnDropdown(WidgetIndex widgetIndex, int32_t dropdownIndex) { + auto& gameState = getGameState(); switch (widgetIndex) { case WIDX_VIEW_DROPDOWN: @@ -2207,7 +2208,7 @@ namespace OpenRCT2::Ui::Windows status = static_cast(gDropdown.items[dropdownIndex].value); } auto gameAction = GameActions::RideSetStatusAction(ride->id, status); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, gameState); } break; } @@ -2228,7 +2229,7 @@ namespace OpenRCT2::Ui::Windows _currentTrackAlternative.clearAll(); RideConstructionSetDefaultNextPiece(); }); - GameActions::Execute(&rideSetSetting); + GameActions::Execute(&rideSetSetting, gameState); } } break; @@ -2291,7 +2292,7 @@ namespace OpenRCT2::Ui::Windows { auto strText = std::string(text); auto gameAction = GameActions::RideSetNameAction(ride->id, strText); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } } @@ -4181,7 +4182,7 @@ namespace OpenRCT2::Ui::Windows auto gameAction = GameActions::RideSetColourSchemeAction( CoordsXYZD{ info.Loc, z, static_cast(direction) }, info.Element->AsTrack()->GetTrackType(), newColourScheme); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } void ColourClose() @@ -4192,6 +4193,7 @@ namespace OpenRCT2::Ui::Windows void ColourOnMouseUp(WidgetIndex widgetIndex) { + auto& gameState = getGameState(); switch (widgetIndex) { case WIDX_CLOSE: @@ -4220,7 +4222,7 @@ namespace OpenRCT2::Ui::Windows const bool currentlyEnabled = ride->hasLifecycleFlag(RIDE_LIFECYCLE_RANDOM_SHOP_COLOURS); auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::SellingItemColourIsRandom, currentlyEnabled ? 0 : 1, 0); - GameActions::Execute(&rideSetAppearanceAction); + GameActions::Execute(&rideSetAppearanceAction, gameState); } break; } @@ -4262,7 +4264,7 @@ namespace OpenRCT2::Ui::Windows colour_t colour = UtilRand() % kColourNumNormal; auto vehicleSetBodyColourAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::VehicleColourBody, colour, i); - GameActions::Execute(&vehicleSetBodyColourAction); + GameActions::Execute(&vehicleSetBodyColourAction, gameState); } if (allowChangingTrimColour) @@ -4270,7 +4272,7 @@ namespace OpenRCT2::Ui::Windows colour_t colour = UtilRand() % kColourNumNormal; auto vehicleSetTrimColourAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::VehicleColourTrim, colour, i); - GameActions::Execute(&vehicleSetTrimColourAction); + GameActions::Execute(&vehicleSetTrimColourAction, gameState); } if (allowChangingTertiaryColour) @@ -4278,7 +4280,7 @@ namespace OpenRCT2::Ui::Windows colour_t colour = UtilRand() % kColourNumNormal; auto vehicleSetTertiaryColourAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::VehicleColourTertiary, colour, i); - GameActions::Execute(&vehicleSetTertiaryColourAction); + GameActions::Execute(&vehicleSetTertiaryColourAction, gameState); } } break; @@ -4438,6 +4440,7 @@ namespace OpenRCT2::Ui::Windows if (dropdownIndex == -1) return; + auto& gameState = getGameState(); switch (widgetIndex) { case WIDX_TRACK_COLOUR_SCHEME_DROPDOWN: @@ -4449,7 +4452,7 @@ namespace OpenRCT2::Ui::Windows auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::TrackColourMain, ColourDropDownIndexToColour(dropdownIndex), _rideColour); - GameActions::Execute(&rideSetAppearanceAction); + GameActions::Execute(&rideSetAppearanceAction, gameState); } break; case WIDX_TRACK_ADDITIONAL_COLOUR: @@ -4457,7 +4460,7 @@ namespace OpenRCT2::Ui::Windows auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::TrackColourAdditional, ColourDropDownIndexToColour(dropdownIndex), _rideColour); - GameActions::Execute(&rideSetAppearanceAction); + GameActions::Execute(&rideSetAppearanceAction, gameState); } break; case WIDX_TRACK_SUPPORT_COLOUR: @@ -4465,14 +4468,14 @@ namespace OpenRCT2::Ui::Windows auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::TrackColourSupports, ColourDropDownIndexToColour(dropdownIndex), _rideColour); - GameActions::Execute(&rideSetAppearanceAction); + GameActions::Execute(&rideSetAppearanceAction, gameState); } break; case WIDX_MAZE_STYLE_DROPDOWN: { auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::MazeStyle, dropdownIndex, _rideColour); - GameActions::Execute(&rideSetAppearanceAction); + GameActions::Execute(&rideSetAppearanceAction, gameState); } break; case WIDX_ENTRANCE_STYLE_DROPDOWN: @@ -4490,7 +4493,7 @@ namespace OpenRCT2::Ui::Windows return; getGameState().lastEntranceStyle = objIndex; }); - GameActions::Execute(&rideSetAppearanceAction); + GameActions::Execute(&rideSetAppearanceAction, gameState); break; } case WIDX_VEHICLE_COLOUR_SCHEME_DROPDOWN: @@ -4504,7 +4507,7 @@ namespace OpenRCT2::Ui::Windows ResetVehicleIndex(); } }); - GameActions::Execute(&rideSetAppearanceAction); + GameActions::Execute(&rideSetAppearanceAction, gameState); break; } case WIDX_VEHICLE_COLOUR_INDEX_DROPDOWN: @@ -4516,7 +4519,7 @@ namespace OpenRCT2::Ui::Windows auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::VehicleColourBody, ColourDropDownIndexToColour(dropdownIndex), _vehicleIndex); - GameActions::Execute(&rideSetAppearanceAction); + GameActions::Execute(&rideSetAppearanceAction, gameState); } break; case WIDX_VEHICLE_TRIM_COLOUR: @@ -4524,7 +4527,7 @@ namespace OpenRCT2::Ui::Windows auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::VehicleColourTrim, ColourDropDownIndexToColour(dropdownIndex), _vehicleIndex); - GameActions::Execute(&rideSetAppearanceAction); + GameActions::Execute(&rideSetAppearanceAction, gameState); } break; case WIDX_VEHICLE_TERTIARY_COLOUR: @@ -4532,7 +4535,7 @@ namespace OpenRCT2::Ui::Windows auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::VehicleColourTertiary, ColourDropDownIndexToColour(dropdownIndex), _vehicleIndex); - GameActions::Execute(&rideSetAppearanceAction); + GameActions::Execute(&rideSetAppearanceAction, gameState); } break; } @@ -6241,7 +6244,7 @@ namespace OpenRCT2::Ui::Windows } auto parkSetParameter = GameActions::ParkSetParameterAction(GameActions::ParkParameter::SamePriceInPark, newFlags); - GameActions::Execute(&parkSetParameter); + GameActions::Execute(&parkSetParameter, getGameState()); } void IncomeTogglePrimaryPrice() @@ -6274,7 +6277,7 @@ namespace OpenRCT2::Ui::Windows UpdateSamePriceThroughoutFlags(shopItem); auto rideSetPriceAction = GameActions::RideSetPriceAction(rideId, ride->price[0], true); - GameActions::Execute(&rideSetPriceAction); + GameActions::Execute(&rideSetPriceAction, getGameState()); } void IncomeToggleSecondaryPrice() @@ -6294,13 +6297,13 @@ namespace OpenRCT2::Ui::Windows UpdateSamePriceThroughoutFlags(shop_item); auto rideSetPriceAction = GameActions::RideSetPriceAction(rideId, ride->price[1], false); - GameActions::Execute(&rideSetPriceAction); + GameActions::Execute(&rideSetPriceAction, getGameState()); } void IncomeSetPrimaryPrice(money64 price) { auto rideSetPriceAction = GameActions::RideSetPriceAction(rideId, price, true); - GameActions::Execute(&rideSetPriceAction); + GameActions::Execute(&rideSetPriceAction, getGameState()); } void IncomeIncreasePrimaryPrice() @@ -6347,7 +6350,7 @@ namespace OpenRCT2::Ui::Windows void IncomeSetSecondaryPrice(money64 price) { auto rideSetPriceAction = GameActions::RideSetPriceAction(rideId, price, false); - GameActions::Execute(&rideSetPriceAction); + GameActions::Execute(&rideSetPriceAction, getGameState()); } bool IncomeCanModifyPrimaryPrice() diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index bb93c844d8..1ea87feee8 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -306,6 +306,8 @@ namespace OpenRCT2::Ui::Windows return; } + auto& gameState = getGameState(); + if (RideTryGetOriginElement(*currentRide, nullptr)) { // Auto open shops if required. @@ -317,7 +319,7 @@ namespace OpenRCT2::Ui::Windows { _autoOpeningShop = true; auto gameAction = GameActions::RideSetStatusAction(currentRide->id, RideStatus::open); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, gameState); _autoOpeningShop = false; } } @@ -331,7 +333,7 @@ namespace OpenRCT2::Ui::Windows { auto gameAction = GameActions::RideDemolishAction(currentRide->id, GameActions::RideModifyType::demolish); gameAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, gameState); } } @@ -1104,7 +1106,7 @@ namespace OpenRCT2::Ui::Windows auto status = currentRide->status == RideStatus::simulating ? RideStatus::closed : RideStatus::simulating; auto gameAction = GameActions::RideSetStatusAction(currentRide->id, status); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } break; } @@ -2333,8 +2335,8 @@ namespace OpenRCT2::Ui::Windows { trackPlaceAction.SetCallback(RideConstructPlacedForwardGameActionCallback); } - auto res = GameActions::Execute(&trackPlaceAction); - // Used by some functions + + auto res = GameActions::Execute(&trackPlaceAction, getGameState()); if (res.Error != GameActions::Status::Ok) { _trackPlaceCost = kMoney64Undefined; @@ -2350,7 +2352,8 @@ namespace OpenRCT2::Ui::Windows { return; } - OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, trackPos); + + Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, trackPos); if (Network::GetMode() != Network::Mode::none) { @@ -2478,7 +2481,7 @@ namespace OpenRCT2::Ui::Windows } }); - GameActions::Execute(&trackRemoveAction); + GameActions::Execute(&trackRemoveAction, getGameState()); } void Rotate() @@ -2576,7 +2579,7 @@ namespace OpenRCT2::Ui::Windows trackSetBrakeSpeed.SetCallback([](const GameActions::GameAction* ga, const GameActions::Result* result) { WindowRideConstructionUpdateActiveElements(); }); - GameActions::Execute(&trackSetBrakeSpeed); + GameActions::Execute(&trackSetBrakeSpeed, getGameState()); return; } WindowRideConstructionUpdateActiveElements(); @@ -2692,7 +2695,7 @@ namespace OpenRCT2::Ui::Windows ToolSet(*this, newToolWidgetIndex, Tool::crosshair); } }); - auto res = GameActions::Execute(&rideEntranceExitPlaceAction); + auto res = GameActions::Execute(&rideEntranceExitPlaceAction, getGameState()); } void DrawTrackPiece( @@ -3709,7 +3712,7 @@ namespace OpenRCT2::Ui::Windows auto gameAction = GameActions::MazeSetTrackAction( CoordsXYZD{ _currentTrackBegin, 0 }, true, _currentRideIndex, GC_SET_MAZE_TRACK_BUILD); - auto mazeSetTrackResult = GameActions::Execute(&gameAction); + auto mazeSetTrackResult = GameActions::Execute(&gameAction, getGameState()); if (mazeSetTrackResult.Error == GameActions::Status::Ok) { _trackPlaceCost = mazeSetTrackResult.Cost; @@ -4770,7 +4773,7 @@ namespace OpenRCT2::Ui::Windows auto gameAction = GameActions::MazeSetTrackAction( CoordsXYZD{ trackPos, 0 }, true, rideIndex, GC_SET_MAZE_TRACK_BUILD); gameAction.SetFlags(flags); - auto result = GameActions::Execute(&gameAction); + auto result = GameActions::Execute(&gameAction, getGameState()); if (result.Error != GameActions::Status::Ok) return kMoney64Undefined; @@ -4789,7 +4792,7 @@ namespace OpenRCT2::Ui::Windows liftHillAndAlternativeState, false); trackPlaceAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); // This command must not be sent over the network - auto res = GameActions::Execute(&trackPlaceAction); + auto res = GameActions::Execute(&trackPlaceAction, getGameState()); if (res.Error != GameActions::Status::Ok) return kMoney64Undefined; @@ -5158,7 +5161,7 @@ namespace OpenRCT2::Ui::Windows { auto gameAction = GameActions::MazeSetTrackAction(quadrant, false, rideIndex, GC_SET_MAZE_TRACK_FILL); gameAction.SetFlags(flags); - auto res = GameActions::Execute(&gameAction); + auto res = GameActions::Execute(&gameAction, getGameState()); } } else @@ -5179,7 +5182,7 @@ namespace OpenRCT2::Ui::Windows }; trackRemoveAction.SetFlags( GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); - GameActions::Execute(&trackRemoveAction); + GameActions::Execute(&trackRemoveAction, getGameState()); } } } diff --git a/src/openrct2-ui/windows/RideList.cpp b/src/openrct2-ui/windows/RideList.cpp index 933efaf959..8bec63b4e3 100644 --- a/src/openrct2-ui/windows/RideList.cpp +++ b/src/openrct2-ui/windows/RideList.cpp @@ -462,7 +462,7 @@ namespace OpenRCT2::Ui::Windows if (_quickDemolishMode && Network::GetMode() != Network::Mode::client) { auto gameAction = GameActions::RideDemolishAction(selectedRideId, GameActions::RideModifyType::demolish); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); RefreshList(); } else @@ -1099,7 +1099,7 @@ namespace OpenRCT2::Ui::Windows && rideRef.getClassification() == static_cast(page)) { auto gameAction = GameActions::RideSetStatusAction(rideRef.id, RideStatus::closed); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } } } @@ -1112,7 +1112,7 @@ namespace OpenRCT2::Ui::Windows if (rideRef.status != RideStatus::open && rideRef.getClassification() == static_cast(page)) { auto gameAction = GameActions::RideSetStatusAction(rideRef.id, RideStatus::open); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } } } diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index 52736fde7f..d8d291287e 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -333,7 +333,7 @@ namespace OpenRCT2::Ui::Windows const auto objectType = GetObjectTypeFromSceneryType(tabSelectedScenery.SceneryType); auto action = GameActions::ScenerySetRestrictedAction( objectType, tabSelectedScenery.EntryIndex, newStatus); - GameActions::Execute(&action); + GameActions::Execute(&action, getGameState()); } break; } @@ -2092,7 +2092,7 @@ namespace OpenRCT2::Ui::Windows auto smallSceneryPlaceAction = GameActions::SmallSceneryPlaceAction( loc, quadrant, entryIndex, primaryColour, secondaryColour, tertiaryColour); smallSceneryPlaceAction.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); - auto res = GameActions::Execute(&smallSceneryPlaceAction); + auto res = GameActions::Execute(&smallSceneryPlaceAction, getGameState()); if (res.Error != GameActions::Status::Ok) return kMoney64Undefined; @@ -2134,7 +2134,7 @@ namespace OpenRCT2::Ui::Windows gSceneryGhostPosition = loc; gSceneryGhostType |= SCENERY_GHOST_FLAG_1; }); - auto res = GameActions::Execute(&footpathAdditionPlaceAction); + auto res = GameActions::Execute(&footpathAdditionPlaceAction, getGameState()); if (res.Error != GameActions::Status::Ok) return kMoney64Undefined; @@ -2163,7 +2163,7 @@ namespace OpenRCT2::Ui::Windows gSceneryGhostType |= SCENERY_GHOST_FLAG_2; }); - auto res = GameActions::Execute(&wallPlaceAction); + auto res = GameActions::Execute(&wallPlaceAction, getGameState()); if (res.Error != GameActions::Status::Ok) return kMoney64Undefined; @@ -2181,7 +2181,7 @@ namespace OpenRCT2::Ui::Windows loc, entryIndex, primaryColour, secondaryColour, tertiaryColour); sceneryPlaceAction.SetFlags( GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND); - auto res = GameActions::Execute(&sceneryPlaceAction); + auto res = GameActions::Execute(&sceneryPlaceAction, getGameState()); if (res.Error != GameActions::Status::Ok) return kMoney64Undefined; @@ -2214,7 +2214,7 @@ namespace OpenRCT2::Ui::Windows auto bannerPlaceAction = GameActions::BannerPlaceAction(loc, entryIndex, primaryColour); bannerPlaceAction.SetFlags( GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND); - auto res = GameActions::Execute(&bannerPlaceAction); + auto res = GameActions::Execute(&bannerPlaceAction, getGameState()); if (res.Error != GameActions::Status::Ok) return kMoney64Undefined; @@ -2235,6 +2235,7 @@ namespace OpenRCT2::Ui::Windows ViewportInteractionItem::Scenery, ViewportInteractionItem::Wall, ViewportInteractionItem::LargeScenery, ViewportInteractionItem::Banner); auto info = GetMapCoordinatesFromPos(screenCoords, flag); + auto& gameState = getGameState(); switch (info.interactionType) { case ViewportInteractionItem::Scenery: @@ -2250,7 +2251,7 @@ namespace OpenRCT2::Ui::Windows { info.Loc, info.Element->GetBaseZ() }, quadrant, info.Element->AsSmallScenery()->GetEntryIndex(), _sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour); - GameActions::Execute(&repaintScenery); + GameActions::Execute(&repaintScenery, gameState); break; } case ViewportInteractionItem::Wall: @@ -2265,7 +2266,7 @@ namespace OpenRCT2::Ui::Windows { info.Loc, info.Element->GetBaseZ(), info.Element->GetDirection() }, _sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour); - GameActions::Execute(&repaintScenery); + GameActions::Execute(&repaintScenery, gameState); break; } case ViewportInteractionItem::LargeScenery: @@ -2281,7 +2282,7 @@ namespace OpenRCT2::Ui::Windows info.Element->AsLargeScenery()->GetSequenceIndex(), _sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour); - GameActions::Execute(&repaintScenery); + GameActions::Execute(&repaintScenery, gameState); break; } case ViewportInteractionItem::Banner: @@ -2296,7 +2297,7 @@ namespace OpenRCT2::Ui::Windows { info.Loc, info.Element->GetBaseZ(), info.Element->AsBanner()->GetPosition() }, _sceneryPrimaryColour); - GameActions::Execute(&repaintScenery); + GameActions::Execute(&repaintScenery, gameState); } } break; @@ -2958,6 +2959,8 @@ namespace OpenRCT2::Ui::Windows uint16_t selectedScenery = selectedTab.EntryIndex; CoordsXY gridPos; + auto& gameState = getGameState(); + switch (sceneryType) { case SCENERY_TYPE_SMALL: @@ -3036,7 +3039,7 @@ namespace OpenRCT2::Ui::Windows auto smallSceneryPlaceAction = GameActions::SmallSceneryPlaceAction( { cur_grid_x, cur_grid_y, gSceneryPlaceZ, gSceneryPlaceRotation }, quadrant, selectedScenery, _sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour); - auto res = GameActions::Query(&smallSceneryPlaceAction); + auto res = GameActions::Query(&smallSceneryPlaceAction, gameState); success = res.Error; if (res.Error == GameActions::Status::Ok) { @@ -3067,7 +3070,7 @@ namespace OpenRCT2::Ui::Windows Audio::Play3D(Audio::SoundId::PlaceItem, result->Position); } }); - auto res = GameActions::Execute(&smallSceneryPlaceAction); + auto res = GameActions::Execute(&smallSceneryPlaceAction, gameState); if (res.Error == GameActions::Status::Ok) { forceError = false; @@ -3100,7 +3103,7 @@ namespace OpenRCT2::Ui::Windows } Audio::Play3D(Audio::SoundId::PlaceItem, result->Position); }); - auto res = GameActions::Execute(&footpathAdditionPlaceAction); + auto res = GameActions::Execute(&footpathAdditionPlaceAction, gameState); break; } case SCENERY_TYPE_WALL: @@ -3122,7 +3125,7 @@ namespace OpenRCT2::Ui::Windows selectedScenery, { gridPos, gSceneryPlaceZ }, edges, _sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour); - auto res = GameActions::Query(&wallPlaceAction); + auto res = GameActions::Query(&wallPlaceAction, gameState); if (res.Error == GameActions::Status::Ok) { break; @@ -3152,7 +3155,7 @@ namespace OpenRCT2::Ui::Windows Audio::Play3D(Audio::SoundId::PlaceItem, result->Position); } }); - auto res = GameActions::Execute(&wallPlaceAction); + auto res = GameActions::Execute(&wallPlaceAction, gameState); break; } case SCENERY_TYPE_LARGE: @@ -3175,7 +3178,7 @@ namespace OpenRCT2::Ui::Windows auto sceneryPlaceAction = GameActions::LargeSceneryPlaceAction( loc, selectedScenery, _sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour); - auto res = GameActions::Query(&sceneryPlaceAction); + auto res = GameActions::Query(&sceneryPlaceAction, gameState); if (res.Error == GameActions::Status::Ok) { break; @@ -3209,7 +3212,7 @@ namespace OpenRCT2::Ui::Windows Audio::Play3D(Audio::SoundId::Error, { loc.x, loc.y, gSceneryPlaceZ }); } }); - auto res = GameActions::Execute(&sceneryPlaceAction); + auto res = GameActions::Execute(&sceneryPlaceAction, gameState); break; } case SCENERY_TYPE_BANNER: @@ -3231,7 +3234,7 @@ namespace OpenRCT2::Ui::Windows ContextOpenDetailWindow(WD_BANNER, data.bannerId.ToUnderlying()); } }); - GameActions::Execute(&bannerPlaceAction); + GameActions::Execute(&bannerPlaceAction, gameState); break; } } diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index 6902554722..60c6718ec3 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -154,6 +155,8 @@ namespace OpenRCT2::Ui::Windows Close(); return; } + + auto& gameState = getGameState(); switch (widgetIndex) { case WIDX_CLOSE: @@ -173,14 +176,14 @@ namespace OpenRCT2::Ui::Windows { CoordsXYZD wallLocation = { bannerCoords, tileElement->GetBaseZ(), tileElement->GetDirection() }; auto wallRemoveAction = GameActions::WallRemoveAction(wallLocation); - GameActions::Execute(&wallRemoveAction); + GameActions::Execute(&wallRemoveAction, gameState); } else { auto sceneryRemoveAction = GameActions::LargeSceneryRemoveAction( { bannerCoords, tileElement->GetBaseZ(), tileElement->GetDirection() }, tileElement->AsLargeScenery()->GetSequenceIndex()); - GameActions::Execute(&sceneryRemoveAction); + GameActions::Execute(&sceneryRemoveAction, gameState); } break; } @@ -206,6 +209,7 @@ namespace OpenRCT2::Ui::Windows void OnDropdown(WidgetIndex widgetIndex, int32_t dropdownIndex) override { + auto& gameState = getGameState(); switch (widgetIndex) { case WIDX_MAIN_COLOUR: @@ -215,7 +219,7 @@ namespace OpenRCT2::Ui::Windows _mainColour = ColourDropDownIndexToColour(dropdownIndex); auto signSetStyleAction = GameActions::SignSetStyleAction( GetBannerIndex(), _mainColour, _textColour, !_isSmall); - GameActions::Execute(&signSetStyleAction); + GameActions::Execute(&signSetStyleAction, gameState); break; } case WIDX_TEXT_COLOUR: @@ -225,7 +229,7 @@ namespace OpenRCT2::Ui::Windows _textColour = ColourDropDownIndexToColour(dropdownIndex); auto signSetStyleAction = GameActions::SignSetStyleAction( GetBannerIndex(), _mainColour, _textColour, !_isSmall); - GameActions::Execute(&signSetStyleAction); + GameActions::Execute(&signSetStyleAction, gameState); break; } default: @@ -240,7 +244,7 @@ namespace OpenRCT2::Ui::Windows if (widgetIndex == WIDX_SIGN_TEXT && !text.empty()) { auto signSetNameAction = GameActions::SignSetNameAction(GetBannerIndex(), std::string(text)); - GameActions::Execute(&signSetNameAction); + GameActions::Execute(&signSetNameAction, getGameState()); } } diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 93e039abdb..d04ddc4a8b 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -375,6 +375,7 @@ namespace OpenRCT2::Ui::Windows return; } + auto& gameState = getGameState(); switch (widgetIndex) { case WIDX_PICKUP: @@ -397,7 +398,7 @@ namespace OpenRCT2::Ui::Windows ToolSet(*wind, WC_STAFF__WIDX_PICKUP, Tool::picker); } }); - GameActions::Execute(&pickupAction); + GameActions::Execute(&pickupAction, gameState); } break; case WIDX_FIRE: @@ -455,6 +456,7 @@ namespace OpenRCT2::Ui::Windows void OverviewOnDropdown(WidgetIndex widgetIndex, int32_t dropdownIndex) { + auto& gameState = getGameState(); switch (widgetIndex) { case WIDX_LOCATE: @@ -485,7 +487,7 @@ namespace OpenRCT2::Ui::Windows auto staffSetPatrolAreaAction = GameActions::StaffSetPatrolAreaAction( staff->Id, {}, GameActions::StaffSetPatrolAreaMode::ClearAll); - GameActions::Execute(&staffSetPatrolAreaAction); + GameActions::Execute(&staffSetPatrolAreaAction, gameState); } else { @@ -719,7 +721,7 @@ namespace OpenRCT2::Ui::Windows ToolCancel(); gPickupPeepImage = ImageId(); }); - GameActions::Execute(&pickupAction); + GameActions::Execute(&pickupAction, getGameState()); } void OverviewToolAbort(WidgetIndex widgetIndex) @@ -731,7 +733,7 @@ namespace OpenRCT2::Ui::Windows EntityId::FromUnderlying(number), { _pickedPeepOldX, 0, 0 }, Network::GetCurrentPlayerId() }; - GameActions::Execute(&pickupAction); + GameActions::Execute(&pickupAction, getGameState()); } void OverviewViewportRotate() @@ -748,7 +750,7 @@ namespace OpenRCT2::Ui::Windows return; auto gameAction = GameActions::StaffSetNameAction(EntityId::FromUnderlying(number), std::string{ text }); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } #pragma endregion @@ -815,7 +817,7 @@ namespace OpenRCT2::Ui::Windows ObjectEntryIndex costume = _availableCostumes[dropdownIndex].index; auto staffSetCostumeAction = GameActions::StaffSetCostumeAction(EntityId::FromUnderlying(number), costume); - GameActions::Execute(&staffSetCostumeAction); + GameActions::Execute(&staffSetCostumeAction, getGameState()); } void OptionsPrepareDraw() @@ -1102,7 +1104,7 @@ namespace OpenRCT2::Ui::Windows uint8_t newOrders = staff->StaffOrders ^ (1 << orderId); auto staffSetOrdersAction = GameActions::StaffSetOrdersAction(EntityId::FromUnderlying(number), newOrders); - GameActions::Execute(&staffSetOrdersAction); + GameActions::Execute(&staffSetOrdersAction, getGameState()); } void ViewportInit() diff --git a/src/openrct2-ui/windows/StaffFirePrompt.cpp b/src/openrct2-ui/windows/StaffFirePrompt.cpp index 54370f52ce..1e16afd1eb 100644 --- a/src/openrct2-ui/windows/StaffFirePrompt.cpp +++ b/src/openrct2-ui/windows/StaffFirePrompt.cpp @@ -63,7 +63,7 @@ namespace OpenRCT2::Ui::Windows case WIDX_YES: { auto staffFireAction = GameActions::StaffFireAction(EntityId::FromUnderlying(number)); - GameActions::Execute(&staffFireAction); + GameActions::Execute(&staffFireAction, getGameState()); break; } case WIDX_CLOSE: diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index e1d4174e2b..23cb4871a9 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -234,7 +234,7 @@ namespace OpenRCT2::Ui::Windows { auto action = GameActions::StaffSetColourAction( GetSelectedStaffType(), ColourDropDownIndexToColour(dropdownIndex)); - GameActions::Execute(&action); + GameActions::Execute(&action, getGameState()); } } @@ -336,6 +336,8 @@ namespace OpenRCT2::Ui::Windows void OnScrollMouseDown(int32_t scrollIndex, const ScreenCoordsXY& screenCoords) override { int32_t i = screenCoords.y / kScrollableRowHeight; + auto& gameState = getGameState(); + for (const auto& entry : _staffList) { if (i == 0) @@ -343,11 +345,11 @@ namespace OpenRCT2::Ui::Windows if (_quickFireMode) { auto staffFireAction = GameActions::StaffFireAction(entry.Id); - GameActions::Execute(&staffFireAction); + GameActions::Execute(&staffFireAction, gameState); } else { - auto peep = getGameState().entities.GetEntity(entry.Id); + auto peep = gameState.entities.GetEntity(entry.Id); if (peep != nullptr) { auto intent = Intent(WindowClass::Peep); @@ -537,6 +539,8 @@ namespace OpenRCT2::Ui::Windows else costume = findPeepAnimationsIndexForType(animPeepType); + auto& gameState = getGameState(); + auto hireStaffAction = GameActions::StaffHireNewAction(autoPosition, staffType, costume, staffOrders); hireStaffAction.SetCallback([=](const GameActions::GameAction*, const GameActions::Result* res) -> void { if (res->Error != GameActions::Status::Ok) @@ -569,7 +573,7 @@ namespace OpenRCT2::Ui::Windows ToolSet(*wind, WC_STAFF__WIDX_PICKUP, Tool::picker); } }); - GameActions::Execute(&pickupAction); + GameActions::Execute(&pickupAction, getGameState()); } else { @@ -580,7 +584,7 @@ namespace OpenRCT2::Ui::Windows } }); - GameActions::Execute(&hireStaffAction); + GameActions::Execute(&hireStaffAction, gameState); } StaffType GetSelectedStaffType() const diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index fe709f8223..4169853f2c 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1866,14 +1867,14 @@ static uint64_t PageDisabledWidgets[] = { { Guard::Assert(elementIndex >= 0 && elementIndex < windowTileInspectorElementCount, "elementIndex out of range"); auto modifyTile = GameActions::TileModifyAction(_toolMap, GameActions::TileModifyType::AnyRemove, elementIndex); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void RotateElement(int32_t elementIndex) { Guard::Assert(elementIndex >= 0 && elementIndex < windowTileInspectorElementCount, "elementIndex out of range"); auto modifyTile = GameActions::TileModifyAction(_toolMap, GameActions::TileModifyType::AnyRotate, elementIndex); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } // Swap element with its parent @@ -1885,14 +1886,14 @@ static uint64_t PageDisabledWidgets[] = { if (!firstInRange || !secondInRange) return; auto modifyTile = GameActions::TileModifyAction(_toolMap, GameActions::TileModifyType::AnySwap, first, second); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void SortElements() { Guard::Assert(_tileSelected, "No tile selected"); auto modifyTile = GameActions::TileModifyAction(_toolMap, GameActions::TileModifyType::AnySort); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void CopyElement() @@ -1917,55 +1918,55 @@ static uint64_t PageDisabledWidgets[] = { { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::AnyPaste, 0, 0, _copiedElement, _copiedBanner); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void BaseHeightOffset(int16_t elementIndex, int8_t heightOffset) { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::AnyBaseHeightOffset, elementIndex, heightOffset); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void SurfaceShowParkFences(bool showFences) { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::SurfaceShowParkFences, showFences); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void SurfaceToggleCorner(int32_t cornerIndex) { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::SurfaceToggleCorner, cornerIndex); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void SurfaceToggleDiagonal() { auto modifyTile = GameActions::TileModifyAction(_toolMap, GameActions::TileModifyType::SurfaceToggleDiagonal); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void PathSetSloped(int32_t elementIndex, bool sloped) { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::PathSetSlope, elementIndex, sloped); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void PathSetJunctionRailings(int32_t elementIndex, bool hasJunctionRailings) { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::PathSetJunctionRailings, elementIndex, hasJunctionRailings); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void PathSetBroken(int32_t elementIndex, bool broken) { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::PathSetBroken, elementIndex, broken); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void PathToggleEdge(int32_t elementIndex, int32_t cornerIndex) @@ -1974,7 +1975,7 @@ static uint64_t PageDisabledWidgets[] = { Guard::Assert(cornerIndex >= 0 && cornerIndex < 8, "cornerIndex out of range"); auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::PathToggleEdge, elementIndex, cornerIndex); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void EntranceMakeUsable(int32_t elementIndex) @@ -1982,7 +1983,7 @@ static uint64_t PageDisabledWidgets[] = { Guard::ArgumentInRange(elementIndex, 0, windowTileInspectorElementCount - 1); auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::EntranceMakeUsable, elementIndex); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void WallSetSlope(int32_t elementIndex, int32_t slopeValue) @@ -1991,21 +1992,21 @@ static uint64_t PageDisabledWidgets[] = { Guard::Assert((slopeValue & 3) == slopeValue, "slopeValue doesn't match its mask"); auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::WallSetSlope, elementIndex, slopeValue); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void WallAnimationFrameOffset(int16_t elementIndex, int8_t animationFrameOffset) { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::WallSetAnimationFrame, elementIndex, animationFrameOffset); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void TrackBlockHeightOffset(int32_t elementIndex, int8_t heightOffset) { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::TrackBaseHeightOffset, elementIndex, heightOffset); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void TrackBlockSetLift(int32_t elementIndex, bool entireTrackBlock, bool chain) @@ -2014,21 +2015,21 @@ static uint64_t PageDisabledWidgets[] = { _toolMap, entireTrackBlock ? GameActions::TileModifyType::TrackSetChainBlock : GameActions::TileModifyType::TrackSetChain, elementIndex, chain); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void TrackSetBrakeClosed(int32_t elementIndex, bool isClosed) { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::TrackSetBrake, elementIndex, isClosed); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void TrackSetIndestructible(int32_t elementIndex, bool isIndestructible) { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::TrackSetIndestructible, elementIndex, isIndestructible); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void QuarterTileSet(int32_t elementIndex, const int32_t quarterIndex) @@ -2038,7 +2039,7 @@ static uint64_t PageDisabledWidgets[] = { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::ScenerySetQuarterLocation, elementIndex, (quarterIndex - GetCurrentRotation()) & 3); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } // ToggleQuadrantCollision? @@ -2047,7 +2048,7 @@ static uint64_t PageDisabledWidgets[] = { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::ScenerySetQuarterCollision, elementIndex, (quadrantIndex + 2 - GetCurrentRotation()) & 3); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void BannerToggleBlock(int32_t elementIndex, int32_t edgeIndex) @@ -2057,7 +2058,7 @@ static uint64_t PageDisabledWidgets[] = { edgeIndex = (edgeIndex - GetCurrentRotation()) & 3; auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::BannerToggleBlockingEdge, elementIndex, edgeIndex); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void ToggleInvisibility(int32_t elementIndex) @@ -2065,14 +2066,14 @@ static uint64_t PageDisabledWidgets[] = { Guard::Assert(elementIndex >= 0 && elementIndex < windowTileInspectorElementCount, "elementIndex out of range"); auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::AnyToggleInvisilibity, elementIndex); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void WallSetAnimationIsBackwards(int32_t elementIndex, bool backwards) { auto modifyTile = GameActions::TileModifyAction( _toolMap, GameActions::TileModifyType::WallSetAnimationIsBackwards, elementIndex, backwards); - GameActions::Execute(&modifyTile); + GameActions::Execute(&modifyTile, getGameState()); } void OnPrepareDraw() override diff --git a/src/openrct2-ui/windows/TitleMenu.cpp b/src/openrct2-ui/windows/TitleMenu.cpp index 0966ffc85e..f2793a547a 100644 --- a/src/openrct2-ui/windows/TitleMenu.cpp +++ b/src/openrct2-ui/windows/TitleMenu.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -148,7 +149,7 @@ namespace OpenRCT2::Ui::Windows windowMgr->CloseByClass(WindowClass::ScenarioSelect); windowMgr->CloseByClass(WindowClass::ServerList); auto loadOrQuitAction = GameActions::LoadOrQuitAction(GameActions::LoadOrQuitModes::OpenSavePrompt); - GameActions::Execute(&loadOrQuitAction); + GameActions::Execute(&loadOrQuitAction, getGameState()); } break; case WIDX_MULTIPLAYER: diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 32d5831d4c..1ae750d612 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -316,7 +316,7 @@ namespace OpenRCT2::Ui::Windows if (Network::GetMode() != Network::Mode::client) { auto pauseToggleAction = GameActions::PauseToggleAction(); - GameActions::Execute(&pauseToggleAction); + GameActions::Execute(&pauseToggleAction, getGameState()); _waitingForPause = true; } break; @@ -425,6 +425,8 @@ namespace OpenRCT2::Ui::Windows { return; } + + auto& gameState = getGameState(); switch (widgetIndex) { case WIDX_FILE_MENU: @@ -453,13 +455,13 @@ namespace OpenRCT2::Ui::Windows { auto loadOrQuitAction = GameActions::LoadOrQuitAction( GameActions::LoadOrQuitModes::OpenSavePrompt, PromptMode::saveBeforeNewGame); - GameActions::Execute(&loadOrQuitAction); + GameActions::Execute(&loadOrQuitAction, gameState); break; } case DDIDX_LOAD_GAME: { auto loadOrQuitAction = GameActions::LoadOrQuitAction(GameActions::LoadOrQuitModes::OpenSavePrompt); - GameActions::Execute(&loadOrQuitAction); + GameActions::Execute(&loadOrQuitAction, gameState); break; } case DDIDX_SAVE_GAME: @@ -513,7 +515,7 @@ namespace OpenRCT2::Ui::Windows windowMgr->CloseByClass(WindowClass::TrackDeletePrompt); auto loadOrQuitAction = GameActions::LoadOrQuitAction( GameActions::LoadOrQuitModes::OpenSavePrompt, PromptMode::saveBeforeQuit); - GameActions::Execute(&loadOrQuitAction); + GameActions::Execute(&loadOrQuitAction, gameState); break; } case DDIDX_EXIT_OPENRCT2: @@ -1301,7 +1303,7 @@ namespace OpenRCT2::Ui::Windows newSpeed = 8; auto setSpeedAction = GameActions::GameSetSpeedAction(newSpeed); - GameActions::Execute(&setSpeedAction); + GameActions::Execute(&setSpeedAction, getGameState()); } } } diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 3464889561..1b5600d092 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -225,7 +225,7 @@ namespace OpenRCT2::Ui::Windows _hasPlacementGhost = true; } }); - res = GameActions::Execute(&tdAction); + res = GameActions::Execute(&tdAction, getGameState()); cost = res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; VirtualFloorSetHeight(trackLoc.z); @@ -318,7 +318,7 @@ namespace OpenRCT2::Ui::Windows } } }); - GameActions::Execute(&tdAction); + GameActions::Execute(&tdAction, getGameState()); } void OnToolAbort(WidgetIndex widgetIndex) override @@ -382,7 +382,7 @@ namespace OpenRCT2::Ui::Windows { auto tdAction = GameActions::TrackDesignAction({ _placementGhostLoc }, *_trackDesign); tdAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); - auto res = GameActions::Execute(&tdAction); + auto res = GameActions::Execute(&tdAction, getGameState()); if (res.Error != GameActions::Status::Ok) { _hasPlacementGhost = false; @@ -708,7 +708,7 @@ namespace OpenRCT2::Ui::Windows auto tdAction = GameActions::TrackDesignAction( CoordsXYZD{ loc.x, loc.y, loc.z, _currentTrackPieceDirection }, *_trackDesign); tdAction.SetFlags(newFlags); - res = GameActions::Query(&tdAction); + res = GameActions::Query(&tdAction, getGameState()); // If successful don't keep trying. // If failure due to no money then increasing height only makes problem worse diff --git a/src/openrct2-ui/windows/Water.cpp b/src/openrct2-ui/windows/Water.cpp index 3b43c8f191..2d90ec7ae0 100644 --- a/src/openrct2-ui/windows/Water.cpp +++ b/src/openrct2-ui/windows/Water.cpp @@ -257,13 +257,15 @@ namespace OpenRCT2::Ui::Windows auto offsetPos = screenPos - ScreenCoordsXY{ 0, gInputDragLast.y }; + auto& gameState = getGameState(); + if (offsetPos.y <= dx) { gInputDragLast.y += dx; auto waterRaiseAction = GameActions::WaterRaiseAction( { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }); - GameActions::Execute(&waterRaiseAction); + GameActions::Execute(&waterRaiseAction, gameState); _waterToolRaiseCost = kMoney64Undefined; _waterToolLowerCost = kMoney64Undefined; @@ -279,7 +281,7 @@ namespace OpenRCT2::Ui::Windows auto waterLowerAction = GameActions::WaterLowerAction( { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }); - GameActions::Execute(&waterLowerAction); + GameActions::Execute(&waterLowerAction, gameState); _waterToolRaiseCost = kMoney64Undefined; _waterToolLowerCost = kMoney64Undefined; @@ -296,6 +298,7 @@ namespace OpenRCT2::Ui::Windows MapInvalidateSelectionRect(); auto* windowMgr = Ui::GetWindowManager(); + auto& gameState = getGameState(); if (gCurrentToolId == Tool::upDownArrow) { @@ -307,10 +310,10 @@ namespace OpenRCT2::Ui::Windows auto waterRaiseAction = GameActions::WaterRaiseAction( { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }); - auto res = GameActions::Query(&waterLowerAction); + auto res = GameActions::Query(&waterLowerAction, gameState); money64 lowerCost = res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; - res = GameActions::Query(&waterRaiseAction); + res = GameActions::Query(&waterRaiseAction, gameState); money64 raiseCost = res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; if (_waterToolRaiseCost != raiseCost || _waterToolLowerCost != lowerCost) @@ -398,10 +401,10 @@ namespace OpenRCT2::Ui::Windows auto waterRaiseAction = GameActions::WaterRaiseAction( { gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y }); - auto res = GameActions::Query(&waterLowerAction); + auto res = GameActions::Query(&waterLowerAction, gameState); money64 lowerCost = res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; - res = GameActions::Query(&waterRaiseAction); + res = GameActions::Query(&waterRaiseAction, gameState); money64 raiseCost = res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; if (_waterToolRaiseCost != raiseCost || _waterToolLowerCost != lowerCost) diff --git a/src/openrct2/Cheats.cpp b/src/openrct2/Cheats.cpp index 239c1859d4..7a75ad6ef1 100644 --- a/src/openrct2/Cheats.cpp +++ b/src/openrct2/Cheats.cpp @@ -61,7 +61,7 @@ void CheatsReset() void CheatsSet(CheatType cheatType, int64_t param1 /* = 0*/, int64_t param2 /* = 0*/) { auto cheatSetAction = GameActions::CheatSetAction(cheatType, param1, param2); - GameActions::Execute(&cheatSetAction); + GameActions::Execute(&cheatSetAction, getGameState()); } template diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 8c8fcbf5fd..a7093cbcb0 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -238,16 +238,17 @@ namespace OpenRCT2::Editor static void SetAllLandOwned() { auto& gameState = getGameState(); + MapRange range = { 2 * kCoordsXYStep, 2 * kCoordsXYStep, (gameState.mapSize.x - 3) * kCoordsXYStep, (gameState.mapSize.y - 3) * kCoordsXYStep }; auto landSetRightsAction = GameActions::LandSetRightsAction(range, GameActions::LandSetRightSetting::SetForSale); landSetRightsAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND); - GameActions::Execute(&landSetRightsAction); + GameActions::Execute(&landSetRightsAction, gameState); auto landBuyRightsAction = GameActions::LandBuyRightsAction(range, GameActions::LandBuyRightSetting::BuyLand); landBuyRightsAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND); - GameActions::Execute(&landBuyRightsAction); + GameActions::Execute(&landBuyRightsAction, gameState); } static void AfterLoadCleanup(bool loadedFromSave) diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index a196811b8d..351c5f74f6 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -110,7 +110,7 @@ using namespace OpenRCT2; void GameResetSpeed() { auto setSpeedAction = GameActions::GameSetSpeedAction(1); - GameActions::Execute(&setSpeedAction); + GameActions::Execute(&setSpeedAction, getGameState()); } void GameIncreaseGameSpeed() @@ -120,7 +120,7 @@ void GameIncreaseGameSpeed() newSpeed = 8; auto setSpeedAction = GameActions::GameSetSpeedAction(newSpeed); - GameActions::Execute(&setSpeedAction); + GameActions::Execute(&setSpeedAction, getGameState()); } void GameReduceGameSpeed() @@ -130,7 +130,7 @@ void GameReduceGameSpeed() newSpeed = 4; auto setSpeedAction = GameActions::GameSetSpeedAction(newSpeed); - GameActions::Execute(&setSpeedAction); + GameActions::Execute(&setSpeedAction, getGameState()); } /** @@ -679,12 +679,14 @@ static void NewGameWindowCallback(const utf8* path) */ void GameLoadOrQuitNoSavePrompt() { + auto& gameState = getGameState(); + switch (gSavePromptMode) { case PromptMode::saveBeforeLoad: { auto loadOrQuitAction = GameActions::LoadOrQuitAction(GameActions::LoadOrQuitModes::CloseSavePrompt); - GameActions::Execute(&loadOrQuitAction); + GameActions::Execute(&loadOrQuitAction, gameState); ToolCancel(); if (gLegacyScene == LegacyScene::scenarioEditor) { @@ -703,7 +705,7 @@ void GameLoadOrQuitNoSavePrompt() case PromptMode::saveBeforeQuit: { auto loadOrQuitAction = GameActions::LoadOrQuitAction(GameActions::LoadOrQuitModes::CloseSavePrompt); - GameActions::Execute(&loadOrQuitAction); + GameActions::Execute(&loadOrQuitAction, gameState); ToolCancel(); if (gInputFlags.has(InputFlag::unk5)) { @@ -724,7 +726,7 @@ void GameLoadOrQuitNoSavePrompt() case PromptMode::saveBeforeNewGame: { auto loadOrQuitAction = GameActions::LoadOrQuitAction(GameActions::LoadOrQuitModes::CloseSavePrompt); - GameActions::Execute(&loadOrQuitAction); + GameActions::Execute(&loadOrQuitAction, gameState); ToolCancel(); auto intent = Intent(WindowClass::ScenarioSelect); intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(NewGameWindowCallback)); diff --git a/src/openrct2/ReplayManager.cpp b/src/openrct2/ReplayManager.cpp index f3db8ba3ba..3fdb2ede3c 100644 --- a/src/openrct2/ReplayManager.cpp +++ b/src/openrct2/ReplayManager.cpp @@ -812,7 +812,8 @@ namespace OpenRCT2 { auto& replayQueue = _currentReplay->commands; - const auto currentTicks = getGameState().currentTicks; + auto& gameState = getGameState(); + const auto currentTicks = gameState.currentTicks; while (replayQueue.begin() != replayQueue.end()) { @@ -838,7 +839,7 @@ namespace OpenRCT2 GameAction* action = command.action.get(); action->SetFlags(action->GetFlags() | GAME_COMMAND_FLAG_REPLAY); - GameActions::Result result = GameActions::Execute(action); + GameActions::Result result = GameActions::Execute(action, gameState); if (result.Error == GameActions::Status::Ok) { isPositionValid = true; diff --git a/src/openrct2/actions/BalloonPressAction.cpp b/src/openrct2/actions/BalloonPressAction.cpp index 8eb42d817a..f3562fb956 100644 --- a/src/openrct2/actions/BalloonPressAction.cpp +++ b/src/openrct2/actions/BalloonPressAction.cpp @@ -38,9 +38,8 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_spriteIndex); } - Result BalloonPressAction::Query() const + Result BalloonPressAction::Query(GameState_t& gameState) const { - auto& gameState = getGameState(); auto balloon = gameState.entities.TryGetEntity(_spriteIndex); if (balloon == nullptr) { @@ -50,9 +49,8 @@ namespace OpenRCT2::GameActions return Result(); } - Result BalloonPressAction::Execute() const + Result BalloonPressAction::Execute(GameState_t& gameState) const { - auto& gameState = getGameState(); auto balloon = gameState.entities.TryGetEntity(_spriteIndex); if (balloon == nullptr) { diff --git a/src/openrct2/actions/BalloonPressAction.h b/src/openrct2/actions/BalloonPressAction.h index 423c51fe43..468cba5809 100644 --- a/src/openrct2/actions/BalloonPressAction.h +++ b/src/openrct2/actions/BalloonPressAction.h @@ -27,7 +27,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/BannerPlaceAction.cpp b/src/openrct2/actions/BannerPlaceAction.cpp index 220a430f92..7f8fa5fca4 100644 --- a/src/openrct2/actions/BannerPlaceAction.cpp +++ b/src/openrct2/actions/BannerPlaceAction.cpp @@ -51,7 +51,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc) << DS_TAG(_bannerType) << DS_TAG(_primaryColour); } - Result BannerPlaceAction::Query() const + Result BannerPlaceAction::Query(GameState_t& gameState) const { auto res = Result(); res.Position.x = _loc.x + 16; @@ -108,7 +108,7 @@ namespace OpenRCT2::GameActions return res; } - Result BannerPlaceAction::Execute() const + Result BannerPlaceAction::Execute(GameState_t& gameState) const { auto res = Result(); res.Position.x = _loc.x + 16; diff --git a/src/openrct2/actions/BannerPlaceAction.h b/src/openrct2/actions/BannerPlaceAction.h index fe3885a5ab..b6dbd55e46 100644 --- a/src/openrct2/actions/BannerPlaceAction.h +++ b/src/openrct2/actions/BannerPlaceAction.h @@ -34,8 +34,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: PathElement* GetValidPathElement() const; diff --git a/src/openrct2/actions/BannerRemoveAction.cpp b/src/openrct2/actions/BannerRemoveAction.cpp index 4273aca20e..af96b926a9 100644 --- a/src/openrct2/actions/BannerRemoveAction.cpp +++ b/src/openrct2/actions/BannerRemoveAction.cpp @@ -44,7 +44,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc); } - Result BannerRemoveAction::Query() const + Result BannerRemoveAction::Query(GameState_t& gameState) const { auto res = Result(); res.Expenditure = ExpenditureType::landscaping; @@ -93,7 +93,7 @@ namespace OpenRCT2::GameActions return res; } - Result BannerRemoveAction::Execute() const + Result BannerRemoveAction::Execute(GameState_t& gameState) const { auto res = Result(); res.Expenditure = ExpenditureType::landscaping; diff --git a/src/openrct2/actions/BannerRemoveAction.h b/src/openrct2/actions/BannerRemoveAction.h index e9571f2bcd..448e7e82a6 100644 --- a/src/openrct2/actions/BannerRemoveAction.h +++ b/src/openrct2/actions/BannerRemoveAction.h @@ -27,8 +27,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: BannerElement* GetBannerElementAt() const; diff --git a/src/openrct2/actions/BannerSetColourAction.cpp b/src/openrct2/actions/BannerSetColourAction.cpp index 56e1113ad0..1b8348513d 100644 --- a/src/openrct2/actions/BannerSetColourAction.cpp +++ b/src/openrct2/actions/BannerSetColourAction.cpp @@ -44,12 +44,12 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc) << DS_TAG(_primaryColour); } - Result BannerSetColourAction::Query() const + Result BannerSetColourAction::Query(GameState_t& gameState) const { return QueryExecute(false); } - Result BannerSetColourAction::Execute() const + Result BannerSetColourAction::Execute(GameState_t& gameState) const { return QueryExecute(true); } diff --git a/src/openrct2/actions/BannerSetColourAction.h b/src/openrct2/actions/BannerSetColourAction.h index 3d74238f75..271c2073a4 100644 --- a/src/openrct2/actions/BannerSetColourAction.h +++ b/src/openrct2/actions/BannerSetColourAction.h @@ -28,8 +28,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: Result QueryExecute(bool isExecuting) const; diff --git a/src/openrct2/actions/BannerSetNameAction.cpp b/src/openrct2/actions/BannerSetNameAction.cpp index aed4d15326..e2252acf2c 100644 --- a/src/openrct2/actions/BannerSetNameAction.cpp +++ b/src/openrct2/actions/BannerSetNameAction.cpp @@ -45,7 +45,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_bannerIndex) << DS_TAG(_name); } - Result BannerSetNameAction::Query() const + Result BannerSetNameAction::Query(GameState_t& gameState) const { auto banner = GetBanner(_bannerIndex); if (banner == nullptr) @@ -77,7 +77,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result BannerSetNameAction::Execute() const + Result BannerSetNameAction::Execute(GameState_t& gameState) const { auto banner = GetBanner(_bannerIndex); if (banner == nullptr) diff --git a/src/openrct2/actions/BannerSetNameAction.h b/src/openrct2/actions/BannerSetNameAction.h index 1d047386ea..f4b75ac506 100644 --- a/src/openrct2/actions/BannerSetNameAction.h +++ b/src/openrct2/actions/BannerSetNameAction.h @@ -28,7 +28,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/BannerSetStyleAction.cpp b/src/openrct2/actions/BannerSetStyleAction.cpp index 0cea1ce646..1101da6b14 100644 --- a/src/openrct2/actions/BannerSetStyleAction.cpp +++ b/src/openrct2/actions/BannerSetStyleAction.cpp @@ -47,7 +47,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_type) << DS_TAG(_bannerIndex) << DS_TAG(_parameter); } - Result BannerSetStyleAction::Query() const + Result BannerSetStyleAction::Query(GameState_t& gameState) const { StringId errorTitle = STR_CANT_REPAINT_THIS; if (_type == BannerSetStyleType::NoEntry) @@ -119,7 +119,7 @@ namespace OpenRCT2::GameActions return res; } - Result BannerSetStyleAction::Execute() const + Result BannerSetStyleAction::Execute(GameState_t& gameState) const { auto res = Result(); diff --git a/src/openrct2/actions/BannerSetStyleAction.h b/src/openrct2/actions/BannerSetStyleAction.h index ad994bcbab..504e301cd2 100644 --- a/src/openrct2/actions/BannerSetStyleAction.h +++ b/src/openrct2/actions/BannerSetStyleAction.h @@ -39,7 +39,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/CheatSetAction.cpp b/src/openrct2/actions/CheatSetAction.cpp index 07f6e55c69..76db1ec95d 100644 --- a/src/openrct2/actions/CheatSetAction.cpp +++ b/src/openrct2/actions/CheatSetAction.cpp @@ -74,7 +74,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_cheatType) << DS_TAG(_param1) << DS_TAG(_param2); } - Result CheatSetAction::Query() const + Result CheatSetAction::Query(GameState_t& gameState) const { if (static_cast(_cheatType) >= static_cast(CheatType::Count)) { @@ -102,9 +102,8 @@ namespace OpenRCT2::GameActions return Result(); } - Result CheatSetAction::Execute() const + Result CheatSetAction::Execute(GameState_t& gameState) const { - auto& gameState = getGameState(); auto* windowMgr = Ui::GetWindowManager(); switch (static_cast(_cheatType.id)) @@ -168,7 +167,7 @@ namespace OpenRCT2::GameActions SetMoney(_param1); break; case CheatType::ClearLoan: - ClearLoan(); + ClearLoan(gameState); break; case CheatType::SetGuestParameter: SetGuestParameter(_param1, _param2); @@ -230,7 +229,7 @@ namespace OpenRCT2::GameActions gameState.cheats.neverendingMarketing = _param1 != 0; break; case CheatType::OpenClosePark: - ParkSetOpen(!Park::IsOpen(gameState.park)); + ParkSetOpen(!Park::IsOpen(gameState.park), gameState); break; case CheatType::HaveFun: gameState.scenarioOptions.objective.Type = Scenario::ObjectiveType::haveFun; @@ -624,14 +623,14 @@ namespace OpenRCT2::GameActions windowMgr->InvalidateByClass(WindowClass::BottomToolbar); } - void CheatSetAction::ClearLoan() const + void CheatSetAction::ClearLoan(GameState_t& gameState) const { // First give money AddMoney(getGameState().park.bankLoan); // Then pay the loan auto gameAction = ParkSetLoanAction(0.00_GBP); - ExecuteNested(&gameAction); + ExecuteNested(&gameAction, gameState); } void CheatSetAction::GenerateGuests(int32_t count) const @@ -833,10 +832,10 @@ namespace OpenRCT2::GameActions MapCountRemainingLandRights(); } - void CheatSetAction::ParkSetOpen(bool isOpen) const + void CheatSetAction::ParkSetOpen(bool isOpen, GameState_t& gameState) const { auto parkSetParameter = ParkSetParameterAction(isOpen ? ParkParameter::Open : ParkParameter::Close); - ExecuteNested(&parkSetParameter); + ExecuteNested(&parkSetParameter, gameState); } void CheatSetAction::CreateDucks(int count) const diff --git a/src/openrct2/actions/CheatSetAction.h b/src/openrct2/actions/CheatSetAction.h index c96b0370b4..999552a830 100644 --- a/src/openrct2/actions/CheatSetAction.h +++ b/src/openrct2/actions/CheatSetAction.h @@ -31,8 +31,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: ParametersRange GetParameterRange(CheatType cheatType) const; @@ -47,14 +47,14 @@ namespace OpenRCT2::GameActions void SetScenarioNoMoney(bool enabled) const; void SetMoney(money64 amount) const; void AddMoney(money64 amount) const; - void ClearLoan() const; + void ClearLoan(GameState_t& gameState) const; void GenerateGuests(int32_t count) const; void SetGuestParameter(int32_t parameter, int32_t value) const; void GiveObjectToGuests(int32_t object) const; void RemoveAllGuests() const; void SetStaffSpeed(uint8_t value) const; void OwnAllLand() const; - void ParkSetOpen(bool isOpen) const; + void ParkSetOpen(bool isOpen, GameState_t& gameState) const; void CreateDucks(int count) const; void RemoveParkFences() const; }; diff --git a/src/openrct2/actions/ClearAction.cpp b/src/openrct2/actions/ClearAction.cpp index 8ae34f4f1c..323fcaccc8 100644 --- a/src/openrct2/actions/ClearAction.cpp +++ b/src/openrct2/actions/ClearAction.cpp @@ -51,14 +51,14 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_range) << DS_TAG(_itemsToClear); } - Result ClearAction::Query() const + Result ClearAction::Query(GameState_t& gameState) const { - return QueryExecute(false); + return QueryExecute(gameState, false); } - Result ClearAction::Execute() const + Result ClearAction::Execute(GameState_t& gameState) const { - return QueryExecute(true); + return QueryExecute(gameState, true); } Result ClearAction::CreateResult() const @@ -75,7 +75,7 @@ namespace OpenRCT2::GameActions return result; } - Result ClearAction::QueryExecute(bool executing) const + Result ClearAction::QueryExecute(GameState_t& gameState, bool executing) const { auto result = CreateResult(); @@ -89,9 +89,9 @@ namespace OpenRCT2::GameActions { for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { - if (LocationValid({ x, y }) && MapCanClearAt({ x, y })) + if (LocationValid({ x, y }) && MapCanClearAt(gameState, { x, y })) { - auto cost = ClearSceneryFromTile({ x, y }, executing); + auto cost = ClearSceneryFromTile({ x, y }, executing, gameState); if (cost != kMoney64Undefined) { noValidTiles = false; @@ -108,7 +108,7 @@ namespace OpenRCT2::GameActions if (_itemsToClear & CLEARABLE_ITEMS::kSceneryLarge) { - ResetClearLargeSceneryFlag(); + ResetClearLargeSceneryFlag(gameState); } if (noValidTiles) @@ -121,7 +121,7 @@ namespace OpenRCT2::GameActions return result; } - money64 ClearAction::ClearSceneryFromTile(const CoordsXY& tilePos, bool executing) const + money64 ClearAction::ClearSceneryFromTile(const CoordsXY& tilePos, bool executing, GameState_t& gameState) const { // Pass down all flags. TileElement* tileElement = nullptr; @@ -146,7 +146,8 @@ namespace OpenRCT2::GameActions auto footpathRemoveAction = FootpathRemoveAction({ tilePos, tileElement->GetBaseZ() }); footpathRemoveAction.SetFlags(GetFlags()); - auto res = executing ? ExecuteNested(&footpathRemoveAction) : QueryNested(&footpathRemoveAction); + auto res = executing ? ExecuteNested(&footpathRemoveAction, gameState) + : QueryNested(&footpathRemoveAction, gameState); if (res.Error == Status::Ok) { @@ -163,7 +164,8 @@ namespace OpenRCT2::GameActions tileElement->AsSmallScenery()->GetEntryIndex()); removeSceneryAction.SetFlags(GetFlags()); - auto res = executing ? ExecuteNested(&removeSceneryAction) : QueryNested(&removeSceneryAction); + auto res = executing ? ExecuteNested(&removeSceneryAction, gameState) + : QueryNested(&removeSceneryAction, gameState); if (res.Error == Status::Ok) { @@ -179,7 +181,8 @@ namespace OpenRCT2::GameActions auto wallRemoveAction = WallRemoveAction(wallLocation); wallRemoveAction.SetFlags(GetFlags()); - auto res = executing ? ExecuteNested(&wallRemoveAction) : QueryNested(&wallRemoveAction); + auto res = executing ? ExecuteNested(&wallRemoveAction, gameState) + : QueryNested(&wallRemoveAction, gameState); if (res.Error == Status::Ok) { @@ -196,7 +199,8 @@ namespace OpenRCT2::GameActions tileElement->AsLargeScenery()->GetSequenceIndex()); removeSceneryAction.SetFlags(GetFlags() | GAME_COMMAND_FLAG_TRACK_DESIGN); - auto res = executing ? ExecuteNested(&removeSceneryAction) : QueryNested(&removeSceneryAction); + auto res = executing ? ExecuteNested(&removeSceneryAction, gameState) + : QueryNested(&removeSceneryAction, gameState); if (res.Error == Status::Ok) { @@ -214,9 +218,8 @@ namespace OpenRCT2::GameActions return totalCost; } - void ClearAction::ResetClearLargeSceneryFlag() + void ClearAction::ResetClearLargeSceneryFlag(GameState_t& gameState) { - auto& gameState = getGameState(); // TODO: Improve efficiency of this for (int32_t y = 0; y < gameState.mapSize.y; y++) { @@ -236,9 +239,9 @@ namespace OpenRCT2::GameActions } } - bool ClearAction::MapCanClearAt(const CoordsXY& location) + bool ClearAction::MapCanClearAt(const GameState_t& gameState, const CoordsXY& location) { - return gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode + return gLegacyScene == LegacyScene::scenarioEditor || gameState.cheats.sandboxMode || MapIsLocationOwnedOrHasRights(location); } } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/ClearAction.h b/src/openrct2/actions/ClearAction.h index a36da05382..d0d9b58a42 100644 --- a/src/openrct2/actions/ClearAction.h +++ b/src/openrct2/actions/ClearAction.h @@ -39,20 +39,20 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: Result CreateResult() const; - Result QueryExecute(bool executing) const; - money64 ClearSceneryFromTile(const CoordsXY& tilePos, bool executing) const; + Result QueryExecute(GameState_t& gameState, bool executing) const; + money64 ClearSceneryFromTile(const CoordsXY& tilePos, bool executing, GameState_t& gameState) const; /** * Function to clear the flag that is set to prevent cost duplication * when using the clear scenery tool with large scenery. */ - static void ResetClearLargeSceneryFlag(); + static void ResetClearLargeSceneryFlag(GameState_t& gameState); - static bool MapCanClearAt(const CoordsXY& location); + static bool MapCanClearAt(const GameState_t& gameState, const CoordsXY& location); }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/CustomAction.cpp b/src/openrct2/actions/CustomAction.cpp index 11fae91d5f..1a4c08a62f 100644 --- a/src/openrct2/actions/CustomAction.cpp +++ b/src/openrct2/actions/CustomAction.cpp @@ -48,13 +48,13 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_id) << DS_TAG(_json); } - Result CustomAction::Query() const + Result CustomAction::Query(GameState_t& gameState) const { auto& scriptingEngine = GetContext()->GetScriptEngine(); return scriptingEngine.QueryOrExecuteCustomGameAction(*this, false); } - Result CustomAction::Execute() const + Result CustomAction::Execute(GameState_t& gameState) const { auto& scriptingEngine = GetContext()->GetScriptEngine(); return scriptingEngine.QueryOrExecuteCustomGameAction(*this, true); diff --git a/src/openrct2/actions/CustomAction.h b/src/openrct2/actions/CustomAction.h index c7b41ec9bb..fcf8ca14b2 100644 --- a/src/openrct2/actions/CustomAction.h +++ b/src/openrct2/actions/CustomAction.h @@ -33,8 +33,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/FootpathAdditionPlaceAction.cpp b/src/openrct2/actions/FootpathAdditionPlaceAction.cpp index 49097e4a28..ed3e3c816a 100644 --- a/src/openrct2/actions/FootpathAdditionPlaceAction.cpp +++ b/src/openrct2/actions/FootpathAdditionPlaceAction.cpp @@ -51,7 +51,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc) << DS_TAG(_entryIndex); } - Result FootpathAdditionPlaceAction::Query() const + Result FootpathAdditionPlaceAction::Query(GameState_t& gameState) const { auto res = Result(); res.Expenditure = ExpenditureType::landscaping; @@ -140,7 +140,7 @@ namespace OpenRCT2::GameActions return res; } - Result FootpathAdditionPlaceAction::Execute() const + Result FootpathAdditionPlaceAction::Execute(GameState_t& gameState) const { auto res = Result(); res.Position = _loc; diff --git a/src/openrct2/actions/FootpathAdditionPlaceAction.h b/src/openrct2/actions/FootpathAdditionPlaceAction.h index 8c2481a3a5..4e032c4c88 100644 --- a/src/openrct2/actions/FootpathAdditionPlaceAction.h +++ b/src/openrct2/actions/FootpathAdditionPlaceAction.h @@ -28,7 +28,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/FootpathAdditionRemoveAction.cpp b/src/openrct2/actions/FootpathAdditionRemoveAction.cpp index ee923dfa25..bf90e9b4b3 100644 --- a/src/openrct2/actions/FootpathAdditionRemoveAction.cpp +++ b/src/openrct2/actions/FootpathAdditionRemoveAction.cpp @@ -46,7 +46,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc); } - Result FootpathAdditionRemoveAction::Query() const + Result FootpathAdditionRemoveAction::Query(GameState_t& gameState) const { if (!LocationValid(_loc)) { @@ -93,7 +93,7 @@ namespace OpenRCT2::GameActions return res; } - Result FootpathAdditionRemoveAction::Execute() const + Result FootpathAdditionRemoveAction::Execute(GameState_t& gameState) const { auto* pathElement = MapGetFootpathElement(_loc); if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST)) diff --git a/src/openrct2/actions/FootpathAdditionRemoveAction.h b/src/openrct2/actions/FootpathAdditionRemoveAction.h index 7cf9b21aea..c7f2b9298b 100644 --- a/src/openrct2/actions/FootpathAdditionRemoveAction.h +++ b/src/openrct2/actions/FootpathAdditionRemoveAction.h @@ -27,7 +27,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/FootpathLayoutPlaceAction.cpp b/src/openrct2/actions/FootpathLayoutPlaceAction.cpp index 12cdff4df3..1b89f02fb7 100644 --- a/src/openrct2/actions/FootpathLayoutPlaceAction.cpp +++ b/src/openrct2/actions/FootpathLayoutPlaceAction.cpp @@ -64,7 +64,7 @@ namespace OpenRCT2::GameActions return GameAction::GetActionFlags(); } - Result FootpathLayoutPlaceAction::Query() const + Result FootpathLayoutPlaceAction::Query(GameState_t& gameState) const { auto res = Result(); res.Cost = 0; @@ -96,7 +96,7 @@ namespace OpenRCT2::GameActions return ElementInsertQuery(std::move(res)); } - Result FootpathLayoutPlaceAction::Execute() const + Result FootpathLayoutPlaceAction::Execute(GameState_t& gameState) const { auto res = Result(); res.Cost = 0; diff --git a/src/openrct2/actions/FootpathLayoutPlaceAction.h b/src/openrct2/actions/FootpathLayoutPlaceAction.h index fd909c2777..9a08ecd0a5 100644 --- a/src/openrct2/actions/FootpathLayoutPlaceAction.h +++ b/src/openrct2/actions/FootpathLayoutPlaceAction.h @@ -35,8 +35,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: Result ElementInsertQuery(Result res) const; diff --git a/src/openrct2/actions/FootpathPlaceAction.cpp b/src/openrct2/actions/FootpathPlaceAction.cpp index ce2777d00e..0d49259354 100644 --- a/src/openrct2/actions/FootpathPlaceAction.cpp +++ b/src/openrct2/actions/FootpathPlaceAction.cpp @@ -73,7 +73,7 @@ namespace OpenRCT2::GameActions << DS_TAG(_constructFlags); } - Result FootpathPlaceAction::Query() const + Result FootpathPlaceAction::Query(GameState_t& gameState) const { auto res = Result(); res.Cost = 0; @@ -124,7 +124,7 @@ namespace OpenRCT2::GameActions return ElementUpdateQuery(tileElement, std::move(res)); } - Result FootpathPlaceAction::Execute() const + Result FootpathPlaceAction::Execute(GameState_t& gameState) const { auto res = Result(); res.Cost = 0; diff --git a/src/openrct2/actions/FootpathPlaceAction.h b/src/openrct2/actions/FootpathPlaceAction.h index 1a04e57ec3..c474acd042 100644 --- a/src/openrct2/actions/FootpathPlaceAction.h +++ b/src/openrct2/actions/FootpathPlaceAction.h @@ -34,8 +34,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: Result ElementUpdateQuery(PathElement* pathElement, Result res) const; diff --git a/src/openrct2/actions/FootpathRemoveAction.cpp b/src/openrct2/actions/FootpathRemoveAction.cpp index 056106c0d1..d2fc3fc2dd 100644 --- a/src/openrct2/actions/FootpathRemoveAction.cpp +++ b/src/openrct2/actions/FootpathRemoveAction.cpp @@ -47,7 +47,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc); } - Result FootpathRemoveAction::Query() const + Result FootpathRemoveAction::Query(GameState_t& gameState) const { auto res = Result(); res.Cost = 0; @@ -75,7 +75,7 @@ namespace OpenRCT2::GameActions return res; } - Result FootpathRemoveAction::Execute() const + Result FootpathRemoveAction::Execute(GameState_t& gameState) const { auto res = Result(); res.Cost = 0; @@ -92,7 +92,7 @@ namespace OpenRCT2::GameActions if (footpathElement != nullptr) { FootpathQueueChainReset(); - auto bannerRes = RemoveBannersAtElement(_loc, footpathElement); + auto bannerRes = RemoveBannersAtElement(gameState, _loc, footpathElement); if (bannerRes.Error == Status::Ok) { res.Cost += bannerRes.Cost; @@ -102,7 +102,6 @@ namespace OpenRCT2::GameActions TileElementRemove(footpathElement); FootpathUpdateQueueChains(); - auto& gameState = getGameState(); // Remove the spawn point (if there is one in the current tile) gameState.peepSpawns.erase( std::remove_if( @@ -164,7 +163,8 @@ namespace OpenRCT2::GameActions * * rct2: 0x006BA23E */ - Result FootpathRemoveAction::RemoveBannersAtElement(const CoordsXY& loc, TileElement* tileElement) const + Result FootpathRemoveAction::RemoveBannersAtElement( + GameState_t& gameState, const CoordsXY& loc, TileElement* tileElement) const { auto result = Result(); while (!(tileElement++)->IsLastForTile()) @@ -180,7 +180,8 @@ namespace OpenRCT2::GameActions bool isGhost = tileElement->IsGhost(); auto bannerFlags = GetFlags() | (isGhost ? static_cast(GAME_COMMAND_FLAG_GHOST) : 0); bannerRemoveAction.SetFlags(bannerFlags); - auto res = ExecuteNested(&bannerRemoveAction); + + auto res = ExecuteNested(&bannerRemoveAction, gameState); // Ghost removal is free if (res.Error == Status::Ok && !isGhost) { diff --git a/src/openrct2/actions/FootpathRemoveAction.h b/src/openrct2/actions/FootpathRemoveAction.h index a2acda5b3f..302bde76e3 100644 --- a/src/openrct2/actions/FootpathRemoveAction.h +++ b/src/openrct2/actions/FootpathRemoveAction.h @@ -28,12 +28,12 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: TileElement* GetFootpathElement() const; money64 GetRefundPrice(TileElement* footpathElement) const; - Result RemoveBannersAtElement(const CoordsXY& loc, TileElement* tileElement) const; + Result RemoveBannersAtElement(GameState_t& gameState, const CoordsXY& loc, TileElement* tileElement) const; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index cd8838e08e..9fdff4938d 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -142,7 +142,7 @@ namespace OpenRCT2::GameActions Guard::Assert(action != nullptr); - Result result = Execute(action); + Result result = Execute(action, getGameState()); if (result.Error == Status::Ok && Network::GetMode() == Network::Mode::server) { // Relay this action to all other clients. @@ -188,7 +188,7 @@ namespace OpenRCT2::GameActions return false; } - static Result QueryInternal(const GameAction* action, bool topLevel) + static Result QueryInternal(const GameAction* action, GameState_t& gameState, bool topLevel) { Guard::ArgumentNotNull(action); @@ -204,7 +204,7 @@ namespace OpenRCT2::GameActions return result; } - auto result = action->Query(); + auto result = action->Query(gameState); if (result.Error == Status::Ok) { @@ -219,14 +219,14 @@ namespace OpenRCT2::GameActions return result; } - Result Query(const GameAction* action) + Result Query(const GameAction* action, GameState_t& gameState) { - return QueryInternal(action, true); + return QueryInternal(action, gameState, true); } - Result QueryNested(const GameAction* action) + Result QueryNested(const GameAction* action, GameState_t& gameState) { - return QueryInternal(action, false); + return QueryInternal(action, gameState, false); } static const char* GetRealm() @@ -283,7 +283,7 @@ namespace OpenRCT2::GameActions Network::AppendServerLog(text); } - static Result ExecuteInternal(const GameAction* action, bool topLevel) + static Result ExecuteInternal(const GameAction* action, GameState_t& gameState, bool topLevel) { Guard::ArgumentNotNull(action); @@ -309,7 +309,7 @@ namespace OpenRCT2::GameActions } } - Result result = QueryInternal(action, topLevel); + Result result = QueryInternal(action, gameState, topLevel); #ifdef ENABLE_SCRIPTING if (result.Error == Status::Ok && ((Network::GetMode() == Network::Mode::none) || (flags & GAME_COMMAND_FLAG_NETWORKED))) @@ -354,7 +354,7 @@ namespace OpenRCT2::GameActions LogActionBegin(logContext, action); // Execute the action, changing the game state - result = action->Execute(); + result = action->Execute(gameState); #ifdef ENABLE_SCRIPTING if (result.Error == Status::Ok) { @@ -456,14 +456,14 @@ namespace OpenRCT2::GameActions return result; } - Result Execute(const GameAction* action) + Result Execute(const GameAction* action, GameState_t& gameState) { - return ExecuteInternal(action, true); + return ExecuteInternal(action, gameState, true); } - Result ExecuteNested(const GameAction* action) + Result ExecuteNested(const GameAction* action, GameState_t& gameState) { - return ExecuteInternal(action, false); + return ExecuteInternal(action, gameState, false); } const char* GameAction::GetName() const diff --git a/src/openrct2/actions/GameAction.h b/src/openrct2/actions/GameAction.h index d3a305df66..7f4dee877a 100644 --- a/src/openrct2/actions/GameAction.h +++ b/src/openrct2/actions/GameAction.h @@ -17,6 +17,11 @@ #include #include +namespace OpenRCT2 +{ + struct GameState_t; +} + namespace OpenRCT2::GameActions { namespace Flags @@ -229,12 +234,12 @@ namespace OpenRCT2::GameActions /** * Query the result of the game action without changing the game state. */ - virtual OpenRCT2::GameActions::Result Query() const = 0; + virtual Result Query(GameState_t& gameState) const = 0; /** * Apply the game action and change the game state. */ - virtual OpenRCT2::GameActions::Result Execute() const = 0; + virtual Result Execute(GameState_t& gameState) const = 0; bool LocationValid(const CoordsXY& coords) const; }; @@ -282,11 +287,11 @@ namespace OpenRCT2::GameActions GameAction::Ptr Clone(const GameAction* action); // This should be used if a round trip is to be expected. - Result Query(const GameAction* action); - Result Execute(const GameAction* action); + Result Query(const GameAction* action, GameState_t& gameState); + Result Execute(const GameAction* action, GameState_t& gameState); // This should be used from within game actions. - Result QueryNested(const GameAction* action); - Result ExecuteNested(const GameAction* action); + Result QueryNested(const GameAction* action, GameState_t& gameState); + Result ExecuteNested(const GameAction* action, GameState_t& gameState); } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/GameSetSpeedAction.cpp b/src/openrct2/actions/GameSetSpeedAction.cpp index af791f6bc6..c792416923 100644 --- a/src/openrct2/actions/GameSetSpeedAction.cpp +++ b/src/openrct2/actions/GameSetSpeedAction.cpp @@ -37,7 +37,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_speed); } - Result GameSetSpeedAction::Query() const + Result GameSetSpeedAction::Query(GameState_t& gameState) const { Result res = Result(); @@ -50,7 +50,7 @@ namespace OpenRCT2::GameActions return res; } - Result GameSetSpeedAction::Execute() const + Result GameSetSpeedAction::Execute(GameState_t& gameState) const { Result res = Result(); diff --git a/src/openrct2/actions/GameSetSpeedAction.h b/src/openrct2/actions/GameSetSpeedAction.h index 45b126a0cb..e42cfed527 100644 --- a/src/openrct2/actions/GameSetSpeedAction.h +++ b/src/openrct2/actions/GameSetSpeedAction.h @@ -27,8 +27,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: bool IsValidSpeed(uint8_t speed) const; diff --git a/src/openrct2/actions/GuestSetFlagsAction.cpp b/src/openrct2/actions/GuestSetFlagsAction.cpp index c8142eb94b..5183f15ee8 100644 --- a/src/openrct2/actions/GuestSetFlagsAction.cpp +++ b/src/openrct2/actions/GuestSetFlagsAction.cpp @@ -41,9 +41,8 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_peepId) << DS_TAG(_newFlags); } - Result GuestSetFlagsAction::Query() const + Result GuestSetFlagsAction::Query(GameState_t& gameState) const { - auto& gameState = getGameState(); auto* peep = gameState.entities.TryGetEntity(_peepId); if (peep == nullptr) { @@ -53,9 +52,8 @@ namespace OpenRCT2::GameActions return Result(); } - Result GuestSetFlagsAction::Execute() const + Result GuestSetFlagsAction::Execute(GameState_t& gameState) const { - auto& gameState = getGameState(); auto* peep = gameState.entities.TryGetEntity(_peepId); if (peep == nullptr) { diff --git a/src/openrct2/actions/GuestSetFlagsAction.h b/src/openrct2/actions/GuestSetFlagsAction.h index 675c2c232f..d20c58e7c3 100644 --- a/src/openrct2/actions/GuestSetFlagsAction.h +++ b/src/openrct2/actions/GuestSetFlagsAction.h @@ -28,7 +28,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/GuestSetNameAction.cpp b/src/openrct2/actions/GuestSetNameAction.cpp index 85cee44ac2..6c0f622f5a 100644 --- a/src/openrct2/actions/GuestSetNameAction.cpp +++ b/src/openrct2/actions/GuestSetNameAction.cpp @@ -56,7 +56,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_spriteIndex) << DS_TAG(_name); } - Result GuestSetNameAction::Query() const + Result GuestSetNameAction::Query(GameState_t& gameState) const { if (_spriteIndex.ToUnderlying() >= kMaxEntities || _spriteIndex.IsNull()) { @@ -73,7 +73,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result GuestSetNameAction::Execute() const + Result GuestSetNameAction::Execute(GameState_t& gameState) const { auto guest = getGameState().entities.TryGetEntity(_spriteIndex); if (guest == nullptr) diff --git a/src/openrct2/actions/GuestSetNameAction.h b/src/openrct2/actions/GuestSetNameAction.h index 571b11f02a..d9a423c0a4 100644 --- a/src/openrct2/actions/GuestSetNameAction.h +++ b/src/openrct2/actions/GuestSetNameAction.h @@ -31,7 +31,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/LandBuyRightsAction.cpp b/src/openrct2/actions/LandBuyRightsAction.cpp index cffd12afd6..01e9249857 100644 --- a/src/openrct2/actions/LandBuyRightsAction.cpp +++ b/src/openrct2/actions/LandBuyRightsAction.cpp @@ -57,12 +57,12 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_range) << DS_TAG(_setting); } - Result LandBuyRightsAction::Query() const + Result LandBuyRightsAction::Query(GameState_t& gameState) const { return QueryExecute(false); } - Result LandBuyRightsAction::Execute() const + Result LandBuyRightsAction::Execute(GameState_t& gameState) const { return QueryExecute(true); } diff --git a/src/openrct2/actions/LandBuyRightsAction.h b/src/openrct2/actions/LandBuyRightsAction.h index e3d024b278..6269d633e0 100644 --- a/src/openrct2/actions/LandBuyRightsAction.h +++ b/src/openrct2/actions/LandBuyRightsAction.h @@ -41,8 +41,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: Result QueryExecute(bool isExecuting) const; diff --git a/src/openrct2/actions/LandLowerAction.cpp b/src/openrct2/actions/LandLowerAction.cpp index 46046f8db8..152f43cf9a 100644 --- a/src/openrct2/actions/LandLowerAction.cpp +++ b/src/openrct2/actions/LandLowerAction.cpp @@ -55,17 +55,17 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_coords) << DS_TAG(_range) << DS_TAG(_selectionType); } - Result LandLowerAction::Query() const + Result LandLowerAction::Query(GameState_t& gameState) const { - return QueryExecute(false); + return QueryExecute(gameState, false); } - Result LandLowerAction::Execute() const + Result LandLowerAction::Execute(GameState_t& gameState) const { - return QueryExecute(true); + return QueryExecute(gameState, true); } - Result LandLowerAction::QueryExecute(bool isExecuting) const + Result LandLowerAction::QueryExecute(GameState_t& gameState, bool isExecuting) const { auto res = Result(); size_t tableRow = _selectionType; @@ -125,7 +125,8 @@ namespace OpenRCT2::GameActions auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope); landSetHeightAction.SetFlags(GetFlags()); - auto result = isExecuting ? ExecuteNested(&landSetHeightAction) : QueryNested(&landSetHeightAction); + auto result = isExecuting ? ExecuteNested(&landSetHeightAction, gameState) + : QueryNested(&landSetHeightAction, gameState); if (result.Error == Status::Ok) { res.Cost += result.Cost; diff --git a/src/openrct2/actions/LandLowerAction.h b/src/openrct2/actions/LandLowerAction.h index 3bfefc3b86..5c36b37c15 100644 --- a/src/openrct2/actions/LandLowerAction.h +++ b/src/openrct2/actions/LandLowerAction.h @@ -29,10 +29,10 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: - Result QueryExecute(bool isExecuting) const; + Result QueryExecute(GameState_t& gameState, bool isExecuting) const; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/LandRaiseAction.cpp b/src/openrct2/actions/LandRaiseAction.cpp index 60eb3f6e2c..1ba71259b2 100644 --- a/src/openrct2/actions/LandRaiseAction.cpp +++ b/src/openrct2/actions/LandRaiseAction.cpp @@ -56,17 +56,17 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_coords) << DS_TAG(_range) << DS_TAG(_selectionType); } - Result LandRaiseAction::Query() const + Result LandRaiseAction::Query(GameState_t& gameState) const { - return QueryExecute(false); + return QueryExecute(gameState, false); } - Result LandRaiseAction::Execute() const + Result LandRaiseAction::Execute(GameState_t& gameState) const { - return QueryExecute(true); + return QueryExecute(gameState, true); } - Result LandRaiseAction::QueryExecute(bool isExecuting) const + Result LandRaiseAction::QueryExecute(GameState_t& gameState, bool isExecuting) const { auto res = Result(); size_t tableRow = _selectionType; @@ -129,7 +129,8 @@ namespace OpenRCT2::GameActions auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope); landSetHeightAction.SetFlags(GetFlags()); - auto result = isExecuting ? ExecuteNested(&landSetHeightAction) : QueryNested(&landSetHeightAction); + auto result = isExecuting ? ExecuteNested(&landSetHeightAction, gameState) + : QueryNested(&landSetHeightAction, gameState); if (result.Error == Status::Ok) { res.Cost += result.Cost; diff --git a/src/openrct2/actions/LandRaiseAction.h b/src/openrct2/actions/LandRaiseAction.h index 4e335352df..3c61cf54e9 100644 --- a/src/openrct2/actions/LandRaiseAction.h +++ b/src/openrct2/actions/LandRaiseAction.h @@ -29,10 +29,10 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: - Result QueryExecute(bool isExecuting) const; + Result QueryExecute(GameState_t& gameState, bool isExecuting) const; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/LandSetHeightAction.cpp b/src/openrct2/actions/LandSetHeightAction.cpp index c2bd14cc9e..840059f58b 100644 --- a/src/openrct2/actions/LandSetHeightAction.cpp +++ b/src/openrct2/actions/LandSetHeightAction.cpp @@ -58,9 +58,8 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_coords) << DS_TAG(_height) << DS_TAG(_style); } - Result LandSetHeightAction::Query() const + Result LandSetHeightAction::Query(GameState_t& gameState) const { - auto& gameState = getGameState(); if (gameState.park.flags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES) { return Result(Status::Disallowed, STR_FORBIDDEN_BY_THE_LOCAL_AUTHORITY, kStringIdNone); @@ -155,7 +154,7 @@ namespace OpenRCT2::GameActions return res; } - Result LandSetHeightAction::Execute() const + Result LandSetHeightAction::Execute(GameState_t& gameState) const { money64 cost = 0.00_GBP; auto surfaceHeight = TileElementHeight(_coords); diff --git a/src/openrct2/actions/LandSetHeightAction.h b/src/openrct2/actions/LandSetHeightAction.h index 2669411711..191d56ec4e 100644 --- a/src/openrct2/actions/LandSetHeightAction.h +++ b/src/openrct2/actions/LandSetHeightAction.h @@ -29,8 +29,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: StringId CheckParameters() const; diff --git a/src/openrct2/actions/LandSetRightsAction.cpp b/src/openrct2/actions/LandSetRightsAction.cpp index 86a54b39f5..0d65cfefca 100644 --- a/src/openrct2/actions/LandSetRightsAction.cpp +++ b/src/openrct2/actions/LandSetRightsAction.cpp @@ -64,12 +64,12 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_range) << DS_TAG(_setting) << DS_TAG(_ownership); } - Result LandSetRightsAction::Query() const + Result LandSetRightsAction::Query(GameState_t& gameState) const { return QueryExecute(false); } - Result LandSetRightsAction::Execute() const + Result LandSetRightsAction::Execute(GameState_t& gameState) const { return QueryExecute(true); } diff --git a/src/openrct2/actions/LandSetRightsAction.h b/src/openrct2/actions/LandSetRightsAction.h index 4dee79f29d..e64975708b 100644 --- a/src/openrct2/actions/LandSetRightsAction.h +++ b/src/openrct2/actions/LandSetRightsAction.h @@ -40,8 +40,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: Result QueryExecute(bool isExecuting) const; diff --git a/src/openrct2/actions/LandSmoothAction.cpp b/src/openrct2/actions/LandSmoothAction.cpp index 58ee554a46..81f910d78e 100644 --- a/src/openrct2/actions/LandSmoothAction.cpp +++ b/src/openrct2/actions/LandSmoothAction.cpp @@ -60,18 +60,18 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_coords) << DS_TAG(_range) << DS_TAG(_selectionType) << DS_TAG(_isLowering); } - Result LandSmoothAction::Query() const + Result LandSmoothAction::Query(GameState_t& gameState) const { - return SmoothLand(false); + return SmoothLand(gameState, false); } - Result LandSmoothAction::Execute() const + Result LandSmoothAction::Execute(GameState_t& gameState) const { - return SmoothLand(true); + return SmoothLand(gameState, true); } Result LandSmoothAction::SmoothLandTile( - int32_t direction, bool isExecuting, const CoordsXY& loc, SurfaceElement* surfaceElement) const + GameState_t& gameState, int32_t direction, bool isExecuting, const CoordsXY& loc, SurfaceElement* surfaceElement) const { int32_t targetBaseZ = surfaceElement->BaseHeight; int32_t slope = surfaceElement->GetSlope(); @@ -96,14 +96,15 @@ namespace OpenRCT2::GameActions auto landSetHeightAction = LandSetHeightAction(loc, targetBaseZ, slope); landSetHeightAction.SetFlags(GetFlags()); - auto res = isExecuting ? ExecuteNested(&landSetHeightAction) : QueryNested(&landSetHeightAction); + auto res = isExecuting ? ExecuteNested(&landSetHeightAction, gameState) : QueryNested(&landSetHeightAction, gameState); return res; } money64 LandSmoothAction::SmoothLandRowByEdge( - bool isExecuting, const CoordsXY& loc, int32_t expectedLandHeight1, int32_t expectedLandHeight2, int32_t stepX, - int32_t stepY, int32_t direction1, int32_t direction2, int32_t checkDirection1, int32_t checkDirection2) const + GameState_t& gameState, bool isExecuting, const CoordsXY& loc, int32_t expectedLandHeight1, int32_t expectedLandHeight2, + int32_t stepX, int32_t stepY, int32_t direction1, int32_t direction2, int32_t checkDirection1, + int32_t checkDirection2) const { uint8_t shouldContinue = 0xF; int32_t landChangePerTile = _isLowering ? 2 : -2; @@ -235,7 +236,8 @@ namespace OpenRCT2::GameActions } auto landSetHeightAction = LandSetHeightAction(nextLoc, targetBaseZ, slope); landSetHeightAction.SetFlags(GetFlags()); - auto res = isExecuting ? ExecuteNested(&landSetHeightAction) : QueryNested(&landSetHeightAction); + auto res = isExecuting ? ExecuteNested(&landSetHeightAction, gameState) + : QueryNested(&landSetHeightAction, gameState); if (res.Error == Status::Ok) { totalCost += res.Cost; @@ -245,8 +247,8 @@ namespace OpenRCT2::GameActions } money64 LandSmoothAction::SmoothLandRowByCorner( - bool isExecuting, const CoordsXY& loc, int32_t expectedLandHeight, int32_t stepX, int32_t stepY, int32_t direction, - int32_t checkDirection) const + GameState_t& gameState, bool isExecuting, const CoordsXY& loc, int32_t expectedLandHeight, int32_t stepX, int32_t stepY, + int32_t direction, int32_t checkDirection) const { bool shouldContinue = true; money64 totalCost = 0; @@ -315,15 +317,15 @@ namespace OpenRCT2::GameActions if (stepX * stepY != 0) { totalCost += SmoothLandRowByCorner( - isExecuting, nextLoc, expectedLandHeight + (landChangePerTile / 2), 0, stepY, direction, + gameState, isExecuting, nextLoc, expectedLandHeight + (landChangePerTile / 2), 0, stepY, direction, checkDirection ^ 3); totalCost += SmoothLandRowByCorner( - isExecuting, nextLoc, expectedLandHeight + (landChangePerTile / 2), stepX, 0, direction, + gameState, isExecuting, nextLoc, expectedLandHeight + (landChangePerTile / 2), stepX, 0, direction, checkDirection ^ 1); } expectedLandHeight += landChangePerTile; // change land of current tile - auto result = SmoothLandTile(direction, isExecuting, nextLoc, surfaceElement); + auto result = SmoothLandTile(gameState, direction, isExecuting, nextLoc, surfaceElement); if (result.Error == Status::Ok) { totalCost += result.Cost; @@ -332,7 +334,7 @@ namespace OpenRCT2::GameActions return totalCost; } - Result LandSmoothAction::SmoothLand(bool isExecuting) const + Result LandSmoothAction::SmoothLand(GameState_t& gameState, bool isExecuting) const { const bool raiseLand = !_isLowering; const int32_t selectionType = _selectionType; @@ -369,7 +371,7 @@ namespace OpenRCT2::GameActions int32_t z = std::clamp( static_cast(TileElementGetCornerHeight(surfaceElement, 2)), minHeight, maxHeight); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, -32, 0, 2); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, -32, 0, 2); } } { // bottom-left @@ -379,7 +381,7 @@ namespace OpenRCT2::GameActions int32_t z = std::clamp( static_cast(TileElementGetCornerHeight(surfaceElement, 3)), minHeight, maxHeight); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetBottom() }, z, -32, 32, 1, 3); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetBottom() }, z, -32, 32, 1, 3); } } { // bottom-right @@ -389,7 +391,7 @@ namespace OpenRCT2::GameActions int32_t z = std::clamp( static_cast(TileElementGetCornerHeight(surfaceElement, 0)), minHeight, maxHeight); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetRight(), validRange.GetBottom() }, z, 32, 32, 2, 0); + gameState, isExecuting, { validRange.GetRight(), validRange.GetBottom() }, z, 32, 32, 2, 0); } } { // top-right @@ -399,7 +401,7 @@ namespace OpenRCT2::GameActions int32_t z = std::clamp( static_cast(TileElementGetCornerHeight(surfaceElement, 1)), minHeight, maxHeight); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetRight(), validRange.GetTop() }, z, 32, -32, 3, 1); + gameState, isExecuting, { validRange.GetRight(), validRange.GetTop() }, z, 32, -32, 3, 1); } } @@ -414,7 +416,8 @@ namespace OpenRCT2::GameActions static_cast(TileElementGetCornerHeight(surfaceElement, 3)), minHeight, maxHeight); z2 = std::clamp( static_cast(TileElementGetCornerHeight(surfaceElement, 2)), minHeight, maxHeight); - res.Cost += SmoothLandRowByEdge(isExecuting, { validRange.GetLeft(), y }, z1, z2, -32, 0, 0, 1, 3, 2); + res.Cost += SmoothLandRowByEdge( + gameState, isExecuting, { validRange.GetLeft(), y }, z1, z2, -32, 0, 0, 1, 3, 2); } surfaceElement = MapGetSurfaceElementAt(CoordsXY{ validRange.GetRight(), y }); @@ -424,7 +427,8 @@ namespace OpenRCT2::GameActions static_cast(TileElementGetCornerHeight(surfaceElement, 1)), minHeight, maxHeight); z2 = std::clamp( static_cast(TileElementGetCornerHeight(surfaceElement, 0)), minHeight, maxHeight); - res.Cost += SmoothLandRowByEdge(isExecuting, { validRange.GetRight(), y }, z1, z2, 32, 0, 2, 3, 1, 0); + res.Cost += SmoothLandRowByEdge( + gameState, isExecuting, { validRange.GetRight(), y }, z1, z2, 32, 0, 2, 3, 1, 0); } } @@ -437,7 +441,8 @@ namespace OpenRCT2::GameActions static_cast(TileElementGetCornerHeight(surfaceElement, 1)), minHeight, maxHeight); z2 = std::clamp( static_cast(TileElementGetCornerHeight(surfaceElement, 2)), minHeight, maxHeight); - res.Cost += SmoothLandRowByEdge(isExecuting, { x, validRange.GetTop() }, z1, z2, 0, -32, 0, 3, 1, 2); + res.Cost += SmoothLandRowByEdge( + gameState, isExecuting, { x, validRange.GetTop() }, z1, z2, 0, -32, 0, 3, 1, 2); } surfaceElement = MapGetSurfaceElementAt(CoordsXY{ x, validRange.GetBottom() }); @@ -447,7 +452,8 @@ namespace OpenRCT2::GameActions static_cast(TileElementGetCornerHeight(surfaceElement, 0)), minHeight, maxHeight); z2 = std::clamp( static_cast(TileElementGetCornerHeight(surfaceElement, 3)), minHeight, maxHeight); - res.Cost += SmoothLandRowByEdge(isExecuting, { x, validRange.GetBottom() }, z1, z2, 0, 32, 1, 2, 0, 3); + res.Cost += SmoothLandRowByEdge( + gameState, isExecuting, { x, validRange.GetBottom() }, z1, z2, 0, 32, 1, 2, 0, 3); } } break; @@ -481,13 +487,16 @@ namespace OpenRCT2::GameActions // Smooth the corners int32_t z = MapGetCornerHeight(newBaseZ, newSlope, 2); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, -32, 0, 2); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, -32, 0, 2); z = MapGetCornerHeight(newBaseZ, newSlope, 0); - res.Cost += SmoothLandRowByCorner(isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 32, 2, 0); + res.Cost += SmoothLandRowByCorner( + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 32, 2, 0); z = MapGetCornerHeight(newBaseZ, newSlope, 3); - res.Cost += SmoothLandRowByCorner(isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 32, 1, 3); + res.Cost += SmoothLandRowByCorner( + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 32, 1, 3); z = MapGetCornerHeight(newBaseZ, newSlope, 1); - res.Cost += SmoothLandRowByCorner(isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, -32, 3, 1); + res.Cost += SmoothLandRowByCorner( + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, -32, 3, 1); // Smooth the edges switch (selectionType) @@ -495,54 +504,54 @@ namespace OpenRCT2::GameActions case MAP_SELECT_TYPE_CORNER_0: z = MapGetCornerHeight(newBaseZ, newSlope, 0); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 0, 3, 0); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 0, 3, 0); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, 32, 1, 0); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, 32, 1, 0); z = MapGetCornerHeight(newBaseZ, newSlope, 3); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 0, 0, 3); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 0, 0, 3); z = MapGetCornerHeight(newBaseZ, newSlope, 1); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, -32, 0, 1); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, -32, 0, 1); break; case MAP_SELECT_TYPE_CORNER_1: z = MapGetCornerHeight(newBaseZ, newSlope, 1); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 0, 2, 1); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 0, 2, 1); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, -32, 0, 1); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, -32, 0, 1); z = MapGetCornerHeight(newBaseZ, newSlope, 2); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 0, 1, 2); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 0, 1, 2); z = MapGetCornerHeight(newBaseZ, newSlope, 0); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, 32, 1, 0); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, 32, 1, 0); break; case MAP_SELECT_TYPE_CORNER_2: z = MapGetCornerHeight(newBaseZ, newSlope, 2); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 0, 1, 2); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 0, 1, 2); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, -32, 3, 2); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, -32, 3, 2); z = MapGetCornerHeight(newBaseZ, newSlope, 1); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 0, 2, 1); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 0, 2, 1); z = MapGetCornerHeight(newBaseZ, newSlope, 3); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, 32, 2, 3); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, 32, 2, 3); break; case MAP_SELECT_TYPE_CORNER_3: z = MapGetCornerHeight(newBaseZ, newSlope, 3); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 0, 0, 3); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 0, 0, 3); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, 32, 2, 3); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, 32, 2, 3); z = MapGetCornerHeight(newBaseZ, newSlope, 0); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 0, 3, 0); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 0, 3, 0); z = MapGetCornerHeight(newBaseZ, newSlope, 2); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, -32, 3, 2); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 0, -32, 3, 2); break; } break; @@ -599,29 +608,32 @@ namespace OpenRCT2::GameActions uint8_t z4 = MapGetCornerHeight(newBaseZ, newSlope, c4); // Smooth the edge at the top of the new slope res.Cost += SmoothLandRowByEdge( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z1, z2, stepOffsets[edge].x, + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z1, z2, stepOffsets[edge].x, stepOffsets[edge].y, c3, c4, c1, c2); // Smooth the edge at the bottom of the new slope res.Cost += SmoothLandRowByEdge( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z3, z4, -stepOffsets[edge].x, + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z3, z4, -stepOffsets[edge].x, -stepOffsets[edge].y, c1, c2, c3, c4); // Smooth corners res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z1, -stepOffsets[edge].y, stepOffsets[edge].x, - c2, c1); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z1, -stepOffsets[edge].y, + stepOffsets[edge].x, c2, c1); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z2, stepOffsets[edge].y, -stepOffsets[edge].x, - c1, c2); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z2, stepOffsets[edge].y, + -stepOffsets[edge].x, c1, c2); int32_t z = MapGetCornerHeight(newBaseZ, newSlope, 2); res.Cost += SmoothLandRowByCorner( - isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, -32, 0, 2); + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, -32, 0, 2); z = MapGetCornerHeight(newBaseZ, newSlope, 0); - res.Cost += SmoothLandRowByCorner(isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 32, 2, 0); + res.Cost += SmoothLandRowByCorner( + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, 32, 2, 0); z = MapGetCornerHeight(newBaseZ, newSlope, 3); - res.Cost += SmoothLandRowByCorner(isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 32, 1, 3); + res.Cost += SmoothLandRowByCorner( + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, -32, 32, 1, 3); z = MapGetCornerHeight(newBaseZ, newSlope, 1); - res.Cost += SmoothLandRowByCorner(isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, -32, 3, 1); + res.Cost += SmoothLandRowByCorner( + gameState, isExecuting, { validRange.GetLeft(), validRange.GetTop() }, z, 32, -32, 3, 1); break; } default: @@ -635,13 +647,13 @@ namespace OpenRCT2::GameActions { auto raiseLandAction = LandRaiseAction({ _coords.x, _coords.y }, validRange, selectionType); raiseLandAction.SetFlags(GetFlags()); - result = isExecuting ? ExecuteNested(&raiseLandAction) : QueryNested(&raiseLandAction); + result = isExecuting ? ExecuteNested(&raiseLandAction, gameState) : QueryNested(&raiseLandAction, gameState); } else { auto lowerLandAction = LandLowerAction({ _coords.x, _coords.y }, validRange, selectionType); lowerLandAction.SetFlags(GetFlags()); - result = isExecuting ? ExecuteNested(&lowerLandAction) : QueryNested(&lowerLandAction); + result = isExecuting ? ExecuteNested(&lowerLandAction, gameState) : QueryNested(&lowerLandAction, gameState); } if (result.Error != Status::Ok) { diff --git a/src/openrct2/actions/LandSmoothAction.h b/src/openrct2/actions/LandSmoothAction.h index 419f1b3c48..dab95c84e8 100644 --- a/src/openrct2/actions/LandSmoothAction.h +++ b/src/openrct2/actions/LandSmoothAction.h @@ -35,17 +35,20 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: - Result SmoothLandTile(int32_t direction, bool isExecuting, const CoordsXY& loc, SurfaceElement* surfaceElement) const; + Result SmoothLandTile( + GameState_t& gameState, int32_t direction, bool isExecuting, const CoordsXY& loc, + SurfaceElement* surfaceElement) const; money64 SmoothLandRowByEdge( - bool isExecuting, const CoordsXY& loc, int32_t expectedLandHeight1, int32_t expectedLandHeight2, int32_t stepX, - int32_t stepY, int32_t direction1, int32_t direction2, int32_t checkDirection1, int32_t checkDirection2) const; + GameState_t& gameState, bool isExecuting, const CoordsXY& loc, int32_t expectedLandHeight1, + int32_t expectedLandHeight2, int32_t stepX, int32_t stepY, int32_t direction1, int32_t direction2, + int32_t checkDirection1, int32_t checkDirection2) const; money64 SmoothLandRowByCorner( - bool isExecuting, const CoordsXY& loc, int32_t expectedLandHeight, int32_t stepX, int32_t stepY, int32_t direction, - int32_t checkDirection) const; - Result SmoothLand(bool isExecuting) const; + GameState_t& gameState, bool isExecuting, const CoordsXY& loc, int32_t expectedLandHeight, int32_t stepX, + int32_t stepY, int32_t direction, int32_t checkDirection) const; + Result SmoothLand(GameState_t& gameState, bool isExecuting) const; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.cpp b/src/openrct2/actions/LargeSceneryPlaceAction.cpp index 0f60e61193..ad2e00d4b7 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.cpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.cpp @@ -64,7 +64,7 @@ namespace OpenRCT2::GameActions << DS_TAG(_tertiaryColour); } - Result LargeSceneryPlaceAction::Query() const + Result LargeSceneryPlaceAction::Query(GameState_t& gameState) const { auto res = Result(); res.ErrorTitle = STR_CANT_POSITION_THIS_HERE; @@ -76,8 +76,6 @@ namespace OpenRCT2::GameActions auto resultData = LargeSceneryPlaceActionResult{}; - auto& gameState = getGameState(); - money64 supportsCost = 0; if (_primaryColour >= COLOUR_COUNT) @@ -193,7 +191,7 @@ namespace OpenRCT2::GameActions return res; } - Result LargeSceneryPlaceAction::Execute() const + Result LargeSceneryPlaceAction::Execute(GameState_t& gameState) const { auto res = Result(); res.ErrorTitle = STR_CANT_POSITION_THIS_HERE; diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.h b/src/openrct2/actions/LargeSceneryPlaceAction.h index 86fe27e1de..a9956df988 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.h +++ b/src/openrct2/actions/LargeSceneryPlaceAction.h @@ -47,8 +47,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: bool CheckMapCapacity(std::span tiles, size_t numTiles) const; diff --git a/src/openrct2/actions/LargeSceneryRemoveAction.cpp b/src/openrct2/actions/LargeSceneryRemoveAction.cpp index 286c15a9ba..f7aed19016 100644 --- a/src/openrct2/actions/LargeSceneryRemoveAction.cpp +++ b/src/openrct2/actions/LargeSceneryRemoveAction.cpp @@ -49,7 +49,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc) << DS_TAG(_tileIndex); } - Result LargeSceneryRemoveAction::Query() const + Result LargeSceneryRemoveAction::Query(GameState_t& gameState) const { auto res = Result(); @@ -129,7 +129,7 @@ namespace OpenRCT2::GameActions return res; } - Result LargeSceneryRemoveAction::Execute() const + Result LargeSceneryRemoveAction::Execute(GameState_t& gameState) const { auto res = Result(); diff --git a/src/openrct2/actions/LargeSceneryRemoveAction.h b/src/openrct2/actions/LargeSceneryRemoveAction.h index 0995e92257..eb95d08a3c 100644 --- a/src/openrct2/actions/LargeSceneryRemoveAction.h +++ b/src/openrct2/actions/LargeSceneryRemoveAction.h @@ -28,8 +28,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: TileElement* FindLargeSceneryElement(const CoordsXYZ& pos, int32_t sequenceIndex) const; diff --git a/src/openrct2/actions/LargeScenerySetColourAction.cpp b/src/openrct2/actions/LargeScenerySetColourAction.cpp index 531b6b2360..d4a5a43ef5 100644 --- a/src/openrct2/actions/LargeScenerySetColourAction.cpp +++ b/src/openrct2/actions/LargeScenerySetColourAction.cpp @@ -52,12 +52,12 @@ namespace OpenRCT2::GameActions << DS_TAG(_tertiaryColour); } - Result LargeScenerySetColourAction::Query() const + Result LargeScenerySetColourAction::Query(GameState_t& gameState) const { return QueryExecute(false); } - Result LargeScenerySetColourAction::Execute() const + Result LargeScenerySetColourAction::Execute(GameState_t& gameState) const { return QueryExecute(true); } diff --git a/src/openrct2/actions/LargeScenerySetColourAction.h b/src/openrct2/actions/LargeScenerySetColourAction.h index 199f3c0e2e..5c0af2bc61 100644 --- a/src/openrct2/actions/LargeScenerySetColourAction.h +++ b/src/openrct2/actions/LargeScenerySetColourAction.h @@ -32,8 +32,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: Result QueryExecute(bool isExecuting) const; diff --git a/src/openrct2/actions/LoadOrQuitAction.cpp b/src/openrct2/actions/LoadOrQuitAction.cpp index fe5ce0ac44..b77186a896 100644 --- a/src/openrct2/actions/LoadOrQuitAction.cpp +++ b/src/openrct2/actions/LoadOrQuitAction.cpp @@ -39,12 +39,12 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_mode) << DS_TAG(_savePromptMode); } - Result LoadOrQuitAction::Query() const + Result LoadOrQuitAction::Query(GameState_t& gameState) const { return Result(); } - Result LoadOrQuitAction::Execute() const + Result LoadOrQuitAction::Execute(GameState_t& gameState) const { auto mode = static_cast(_mode); switch (mode) diff --git a/src/openrct2/actions/LoadOrQuitAction.h b/src/openrct2/actions/LoadOrQuitAction.h index 0b3ed06e45..271dac08eb 100644 --- a/src/openrct2/actions/LoadOrQuitAction.h +++ b/src/openrct2/actions/LoadOrQuitAction.h @@ -35,7 +35,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/MapChangeSizeAction.cpp b/src/openrct2/actions/MapChangeSizeAction.cpp index 2181452be5..3480e90951 100644 --- a/src/openrct2/actions/MapChangeSizeAction.cpp +++ b/src/openrct2/actions/MapChangeSizeAction.cpp @@ -43,7 +43,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_shift); } - Result MapChangeSizeAction::Query() const + Result MapChangeSizeAction::Query(GameState_t& gameState) const { if (_targetSize.x > kMaximumMapSizeTechnical || _targetSize.y > kMaximumMapSizeTechnical) { @@ -56,9 +56,8 @@ namespace OpenRCT2::GameActions return Result(); } - Result MapChangeSizeAction::Execute() const + Result MapChangeSizeAction::Execute(GameState_t& gameState) const { - auto& gameState = getGameState(); // Expand map while (_targetSize.x > gameState.mapSize.x) { diff --git a/src/openrct2/actions/MapChangeSizeAction.h b/src/openrct2/actions/MapChangeSizeAction.h index f2817d274f..95bff8bebd 100644 --- a/src/openrct2/actions/MapChangeSizeAction.h +++ b/src/openrct2/actions/MapChangeSizeAction.h @@ -25,8 +25,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: TileCoordsXY _targetSize; diff --git a/src/openrct2/actions/MazePlaceTrackAction.cpp b/src/openrct2/actions/MazePlaceTrackAction.cpp index 24655150a4..af2e511cdf 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.cpp +++ b/src/openrct2/actions/MazePlaceTrackAction.cpp @@ -45,7 +45,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc) << DS_TAG(_rideIndex) << DS_TAG(_mazeEntry); } - Result MazePlaceTrackAction::Query() const + Result MazePlaceTrackAction::Query(GameState_t& gameState) const { auto res = Result(); @@ -65,7 +65,7 @@ namespace OpenRCT2::GameActions res.ErrorMessage = STR_OFF_EDGE_OF_MAP; return res; } - auto& gameState = getGameState(); + if (!MapIsLocationOwned(_loc) && !gameState.cheats.sandboxMode) { res.Error = Status::NotOwned; @@ -142,7 +142,7 @@ namespace OpenRCT2::GameActions return res; } - Result MazePlaceTrackAction::Execute() const + Result MazePlaceTrackAction::Execute(GameState_t& gameState) const { auto res = Result(); diff --git a/src/openrct2/actions/MazePlaceTrackAction.h b/src/openrct2/actions/MazePlaceTrackAction.h index 84f650671b..7d0cb6baf8 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.h +++ b/src/openrct2/actions/MazePlaceTrackAction.h @@ -26,7 +26,7 @@ namespace OpenRCT2::GameActions void AcceptParameters(GameActionParameterVisitor&) final; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/MazeSetTrackAction.cpp b/src/openrct2/actions/MazeSetTrackAction.cpp index dba8c9d744..8a763acf34 100644 --- a/src/openrct2/actions/MazeSetTrackAction.cpp +++ b/src/openrct2/actions/MazeSetTrackAction.cpp @@ -80,7 +80,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc) << DS_TAG(_loc.direction) << DS_TAG(_initialPlacement) << DS_TAG(_rideIndex) << DS_TAG(_mode); } - Result MazeSetTrackAction::Query() const + Result MazeSetTrackAction::Query(GameState_t& gameState) const { auto res = Result(); @@ -100,7 +100,7 @@ namespace OpenRCT2::GameActions res.ErrorMessage = STR_OFF_EDGE_OF_MAP; return res; } - auto& gameState = getGameState(); + if (!MapIsLocationOwned(_loc) && !gameState.cheats.sandboxMode) { res.Error = Status::NotOwned; @@ -188,7 +188,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result MazeSetTrackAction::Execute() const + Result MazeSetTrackAction::Execute(GameState_t& gameState) const { auto res = Result(); diff --git a/src/openrct2/actions/MazeSetTrackAction.h b/src/openrct2/actions/MazeSetTrackAction.h index ad70a9fbc7..72a0f221a1 100644 --- a/src/openrct2/actions/MazeSetTrackAction.h +++ b/src/openrct2/actions/MazeSetTrackAction.h @@ -27,8 +27,8 @@ namespace OpenRCT2::GameActions void AcceptParameters(GameActionParameterVisitor&) final; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: uint8_t MazeGetSegmentBit(const CoordsXY&) const; diff --git a/src/openrct2/actions/NetworkModifyGroupAction.cpp b/src/openrct2/actions/NetworkModifyGroupAction.cpp index 621c2059cd..aefbbe9f54 100644 --- a/src/openrct2/actions/NetworkModifyGroupAction.cpp +++ b/src/openrct2/actions/NetworkModifyGroupAction.cpp @@ -45,12 +45,12 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_type) << DS_TAG(_groupId) << DS_TAG(_name) << DS_TAG(_permissionIndex) << DS_TAG(_permissionState); } - Result NetworkModifyGroupAction::Query() const + Result NetworkModifyGroupAction::Query(GameState_t& gameState) const { return Network::ModifyGroups(GetPlayer(), _type, _groupId, _name, _permissionIndex, _permissionState, false); } - Result NetworkModifyGroupAction::Execute() const + Result NetworkModifyGroupAction::Execute(GameState_t& gameState) const { return Network::ModifyGroups(GetPlayer(), _type, _groupId, _name, _permissionIndex, _permissionState, true); } diff --git a/src/openrct2/actions/NetworkModifyGroupAction.h b/src/openrct2/actions/NetworkModifyGroupAction.h index 7844b406b1..b70296dc94 100644 --- a/src/openrct2/actions/NetworkModifyGroupAction.h +++ b/src/openrct2/actions/NetworkModifyGroupAction.h @@ -51,7 +51,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/ParkEntrancePlaceAction.cpp b/src/openrct2/actions/ParkEntrancePlaceAction.cpp index be281b4fd8..7353caf01e 100644 --- a/src/openrct2/actions/ParkEntrancePlaceAction.cpp +++ b/src/openrct2/actions/ParkEntrancePlaceAction.cpp @@ -55,7 +55,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_entranceType); } - Result ParkEntrancePlaceAction::Query() const + Result ParkEntrancePlaceAction::Query(GameState_t& gameState) const { if (!isInEditorMode() && !getGameState().cheats.sandboxMode) { @@ -78,7 +78,6 @@ namespace OpenRCT2::GameActions return Result(Status::NoFreeElements, STR_CANT_BUILD_THIS_HERE, STR_ERR_LANDSCAPE_DATA_AREA_FULL); } - const auto& gameState = getGameState(); if (gameState.park.entrances.size() >= OpenRCT2::Limits::kMaxParkEntrances) { return Result(Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_ERR_TOO_MANY_PARK_ENTRANCES); @@ -116,7 +115,7 @@ namespace OpenRCT2::GameActions return res; } - Result ParkEntrancePlaceAction::Execute() const + Result ParkEntrancePlaceAction::Execute(GameState_t& gameState) const { auto res = Result(); res.Expenditure = ExpenditureType::landPurchase; diff --git a/src/openrct2/actions/ParkEntrancePlaceAction.h b/src/openrct2/actions/ParkEntrancePlaceAction.h index 319d14b8cf..15b14bd881 100644 --- a/src/openrct2/actions/ParkEntrancePlaceAction.h +++ b/src/openrct2/actions/ParkEntrancePlaceAction.h @@ -29,8 +29,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: bool CheckMapCapacity(int16_t numTiles) const; diff --git a/src/openrct2/actions/ParkEntranceRemoveAction.cpp b/src/openrct2/actions/ParkEntranceRemoveAction.cpp index aab588bc51..e3b76272fd 100644 --- a/src/openrct2/actions/ParkEntranceRemoveAction.cpp +++ b/src/openrct2/actions/ParkEntranceRemoveAction.cpp @@ -42,7 +42,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc); } - Result ParkEntranceRemoveAction::Query() const + Result ParkEntranceRemoveAction::Query(GameState_t& gameState) const { if (!isInEditorMode() && !getGameState().cheats.sandboxMode) { @@ -66,7 +66,7 @@ namespace OpenRCT2::GameActions return res; } - Result ParkEntranceRemoveAction::Execute() const + Result ParkEntranceRemoveAction::Execute(GameState_t& gameState) const { auto res = Result(); res.Expenditure = ExpenditureType::landPurchase; diff --git a/src/openrct2/actions/ParkEntranceRemoveAction.h b/src/openrct2/actions/ParkEntranceRemoveAction.h index 93a1743ad7..56c5a9e7e0 100644 --- a/src/openrct2/actions/ParkEntranceRemoveAction.h +++ b/src/openrct2/actions/ParkEntranceRemoveAction.h @@ -27,8 +27,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: void ParkEntranceRemoveSegment(const CoordsXYZ& loc) const; diff --git a/src/openrct2/actions/ParkMarketingAction.cpp b/src/openrct2/actions/ParkMarketingAction.cpp index 734492a63b..44c60c2da6 100644 --- a/src/openrct2/actions/ParkMarketingAction.cpp +++ b/src/openrct2/actions/ParkMarketingAction.cpp @@ -48,7 +48,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_type) << DS_TAG(_item) << DS_TAG(_numWeeks); } - Result ParkMarketingAction::Query() const + Result ParkMarketingAction::Query(GameState_t& gameState) const { if (static_cast(_type) >= std::size(AdvertisingCampaignPricePerWeek) || _numWeeks >= 256) { @@ -63,7 +63,7 @@ namespace OpenRCT2::GameActions return CreateResult(); } - Result ParkMarketingAction::Execute() const + Result ParkMarketingAction::Execute(GameState_t& gameState) const { MarketingCampaign campaign{}; campaign.Type = _type; diff --git a/src/openrct2/actions/ParkMarketingAction.h b/src/openrct2/actions/ParkMarketingAction.h index ad473f8fda..996f836c91 100644 --- a/src/openrct2/actions/ParkMarketingAction.h +++ b/src/openrct2/actions/ParkMarketingAction.h @@ -29,8 +29,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: Result CreateResult() const; diff --git a/src/openrct2/actions/ParkSetDateAction.cpp b/src/openrct2/actions/ParkSetDateAction.cpp index 097a2800ca..583ffde866 100644 --- a/src/openrct2/actions/ParkSetDateAction.cpp +++ b/src/openrct2/actions/ParkSetDateAction.cpp @@ -45,7 +45,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_year) << DS_TAG(_month) << DS_TAG(_day); } - Result ParkSetDateAction::Query() const + Result ParkSetDateAction::Query(GameState_t& gameState) const { if (_year < 0 || _year >= kMaxYear) { @@ -66,9 +66,8 @@ namespace OpenRCT2::GameActions return Result(); } - Result ParkSetDateAction::Execute() const + Result ParkSetDateAction::Execute(GameState_t& gameState) const { - auto& gameState = getGameState(); gameState.date = Date::FromYMD(_year, _month, _day); return Result(); } diff --git a/src/openrct2/actions/ParkSetDateAction.h b/src/openrct2/actions/ParkSetDateAction.h index 05a38d81d9..bc9836b7e8 100644 --- a/src/openrct2/actions/ParkSetDateAction.h +++ b/src/openrct2/actions/ParkSetDateAction.h @@ -29,7 +29,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/ParkSetEntranceFeeAction.cpp b/src/openrct2/actions/ParkSetEntranceFeeAction.cpp index 25f95f8db8..26cd75ebda 100644 --- a/src/openrct2/actions/ParkSetEntranceFeeAction.cpp +++ b/src/openrct2/actions/ParkSetEntranceFeeAction.cpp @@ -41,7 +41,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_fee); } - Result ParkSetEntranceFeeAction::Query() const + Result ParkSetEntranceFeeAction::Query(GameState_t& gameState) const { if ((getGameState().park.flags & PARK_FLAGS_NO_MONEY) != 0) { @@ -62,7 +62,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result ParkSetEntranceFeeAction::Execute() const + Result ParkSetEntranceFeeAction::Execute(GameState_t& gameState) const { getGameState().park.entranceFee = _fee; diff --git a/src/openrct2/actions/ParkSetEntranceFeeAction.h b/src/openrct2/actions/ParkSetEntranceFeeAction.h index 41ffddb644..748b826280 100644 --- a/src/openrct2/actions/ParkSetEntranceFeeAction.h +++ b/src/openrct2/actions/ParkSetEntranceFeeAction.h @@ -27,7 +27,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/ParkSetLoanAction.cpp b/src/openrct2/actions/ParkSetLoanAction.cpp index 0c6b23b386..c32654d84e 100644 --- a/src/openrct2/actions/ParkSetLoanAction.cpp +++ b/src/openrct2/actions/ParkSetLoanAction.cpp @@ -40,7 +40,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_value); } - Result ParkSetLoanAction::Query() const + Result ParkSetLoanAction::Query(GameState_t& gameState) const { auto& park = getGameState().park; if (_value > park.bankLoan && _value > park.maxBankLoan) @@ -61,7 +61,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result ParkSetLoanAction::Execute() const + Result ParkSetLoanAction::Execute(GameState_t& gameState) const { auto& park = getGameState().park; diff --git a/src/openrct2/actions/ParkSetLoanAction.h b/src/openrct2/actions/ParkSetLoanAction.h index 7421d7bcdc..6bdd27c49c 100644 --- a/src/openrct2/actions/ParkSetLoanAction.h +++ b/src/openrct2/actions/ParkSetLoanAction.h @@ -27,7 +27,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/ParkSetNameAction.cpp b/src/openrct2/actions/ParkSetNameAction.cpp index 9241016125..ea47f52c85 100644 --- a/src/openrct2/actions/ParkSetNameAction.cpp +++ b/src/openrct2/actions/ParkSetNameAction.cpp @@ -43,7 +43,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_name); } - Result ParkSetNameAction::Query() const + Result ParkSetNameAction::Query(GameState_t& gameState) const { if (_name.empty()) { @@ -53,7 +53,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result ParkSetNameAction::Execute() const + Result ParkSetNameAction::Execute(GameState_t& gameState) const { // Do a no-op if new name is the same as the current name is the same auto& park = getGameState().park; diff --git a/src/openrct2/actions/ParkSetNameAction.h b/src/openrct2/actions/ParkSetNameAction.h index fe7ea7515f..1c4682f54a 100644 --- a/src/openrct2/actions/ParkSetNameAction.h +++ b/src/openrct2/actions/ParkSetNameAction.h @@ -27,7 +27,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/ParkSetParameterAction.cpp b/src/openrct2/actions/ParkSetParameterAction.cpp index 1076814e6e..2fd80bc9eb 100644 --- a/src/openrct2/actions/ParkSetParameterAction.cpp +++ b/src/openrct2/actions/ParkSetParameterAction.cpp @@ -41,7 +41,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_parameter) << DS_TAG(_value); } - Result ParkSetParameterAction::Query() const + Result ParkSetParameterAction::Query(GameState_t& gameState) const { if (_parameter >= ParkParameter::Count) { @@ -54,7 +54,7 @@ namespace OpenRCT2::GameActions return res; } - Result ParkSetParameterAction::Execute() const + Result ParkSetParameterAction::Execute(GameState_t& gameState) const { auto& park = getGameState().park; auto* windowMgr = Ui::GetWindowManager(); diff --git a/src/openrct2/actions/ParkSetParameterAction.h b/src/openrct2/actions/ParkSetParameterAction.h index 6a229d8656..162a745275 100644 --- a/src/openrct2/actions/ParkSetParameterAction.h +++ b/src/openrct2/actions/ParkSetParameterAction.h @@ -43,7 +43,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/ParkSetResearchFundingAction.cpp b/src/openrct2/actions/ParkSetResearchFundingAction.cpp index 90020778b1..fd2a3e0442 100644 --- a/src/openrct2/actions/ParkSetResearchFundingAction.cpp +++ b/src/openrct2/actions/ParkSetResearchFundingAction.cpp @@ -43,7 +43,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_priorities) << DS_TAG(_fundingAmount); } - Result ParkSetResearchFundingAction::Query() const + Result ParkSetResearchFundingAction::Query(GameState_t& gameState) const { if (_fundingAmount >= RESEARCH_FUNDING_COUNT) { @@ -53,9 +53,8 @@ namespace OpenRCT2::GameActions return Result(); } - Result ParkSetResearchFundingAction::Execute() const + Result ParkSetResearchFundingAction::Execute(GameState_t& gameState) const { - auto& gameState = getGameState(); gameState.researchPriorities = _priorities; gameState.researchFundingLevel = _fundingAmount; diff --git a/src/openrct2/actions/ParkSetResearchFundingAction.h b/src/openrct2/actions/ParkSetResearchFundingAction.h index 3b87a25ffc..7650ada7d8 100644 --- a/src/openrct2/actions/ParkSetResearchFundingAction.h +++ b/src/openrct2/actions/ParkSetResearchFundingAction.h @@ -29,7 +29,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/PauseToggleAction.cpp b/src/openrct2/actions/PauseToggleAction.cpp index 0e1646c91d..1e59ec4eb9 100644 --- a/src/openrct2/actions/PauseToggleAction.cpp +++ b/src/openrct2/actions/PauseToggleAction.cpp @@ -16,12 +16,12 @@ namespace OpenRCT2::GameActions return GameAction::GetActionFlags() | Flags::AllowWhilePaused | Flags::IgnoreForReplays; } - Result PauseToggleAction::Query() const + Result PauseToggleAction::Query(GameState_t& gameState) const { return Result(); } - Result PauseToggleAction::Execute() const + Result PauseToggleAction::Execute(GameState_t& gameState) const { PauseToggle(); return Result(); diff --git a/src/openrct2/actions/PauseToggleAction.h b/src/openrct2/actions/PauseToggleAction.h index 2061669f3f..25dc7cb78a 100644 --- a/src/openrct2/actions/PauseToggleAction.h +++ b/src/openrct2/actions/PauseToggleAction.h @@ -20,8 +20,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; // clang-format on } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/PeepPickupAction.cpp b/src/openrct2/actions/PeepPickupAction.cpp index c30efbbe7a..10143d25d1 100644 --- a/src/openrct2/actions/PeepPickupAction.cpp +++ b/src/openrct2/actions/PeepPickupAction.cpp @@ -46,7 +46,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_type) << DS_TAG(_entityId) << DS_TAG(_loc) << DS_TAG(_owner); } - Result PeepPickupAction::Query() const + Result PeepPickupAction::Query(GameState_t& gameState) const { if (_entityId.ToUnderlying() >= kMaxEntities || _entityId.IsNull()) { @@ -84,7 +84,7 @@ namespace OpenRCT2::GameActions PeepPickupAction existingPickupAction{ PeepPickupType::Cancel, existing->Id, { Network::GetPickupPeepOldX(_owner), 0, 0 }, _owner }; - auto result = QueryNested(&existingPickupAction); + auto result = QueryNested(&existingPickupAction, gameState); if (existing == peep) { @@ -115,7 +115,7 @@ namespace OpenRCT2::GameActions return res; } - Result PeepPickupAction::Execute() const + Result PeepPickupAction::Execute(GameState_t& gameState) const { Peep* const peep = getGameState().entities.TryGetEntity(_entityId); if (peep == nullptr) @@ -139,7 +139,7 @@ namespace OpenRCT2::GameActions PeepPickupAction existingPickupAction{ PeepPickupType::Cancel, existing->Id, { Network::GetPickupPeepOldX(_owner), 0, 0 }, _owner }; - auto result = ExecuteNested(&existingPickupAction); + auto result = ExecuteNested(&existingPickupAction, gameState); if (existing == peep) { diff --git a/src/openrct2/actions/PeepPickupAction.h b/src/openrct2/actions/PeepPickupAction.h index 600080006c..90dd05b752 100644 --- a/src/openrct2/actions/PeepPickupAction.h +++ b/src/openrct2/actions/PeepPickupAction.h @@ -39,8 +39,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: void CancelConcurrentPickups(Peep* pickedPeep) const; diff --git a/src/openrct2/actions/PeepSpawnPlaceAction.cpp b/src/openrct2/actions/PeepSpawnPlaceAction.cpp index 27a6f2eada..79777bf968 100644 --- a/src/openrct2/actions/PeepSpawnPlaceAction.cpp +++ b/src/openrct2/actions/PeepSpawnPlaceAction.cpp @@ -44,7 +44,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_location.x) << DS_TAG(_location.y) << DS_TAG(_location.z) << DS_TAG(_location.direction); } - Result PeepSpawnPlaceAction::Query() const + Result PeepSpawnPlaceAction::Query(GameState_t& gameState) const { if (!isInEditorMode() && !getGameState().cheats.sandboxMode) { @@ -84,7 +84,7 @@ namespace OpenRCT2::GameActions return res; } - Result PeepSpawnPlaceAction::Execute() const + Result PeepSpawnPlaceAction::Execute(GameState_t& gameState) const { auto res = Result(); res.Expenditure = ExpenditureType::landPurchase; @@ -100,7 +100,6 @@ namespace OpenRCT2::GameActions spawn.z = _location.z; spawn.direction = _location.direction; - auto& gameState = getGameState(); // When attempting to place a peep spawn on a tile that already contains it, // remove that peep spawn instead. if (!gameState.peepSpawns.empty()) diff --git a/src/openrct2/actions/PeepSpawnPlaceAction.h b/src/openrct2/actions/PeepSpawnPlaceAction.h index 2b4f338577..cba9dec74b 100644 --- a/src/openrct2/actions/PeepSpawnPlaceAction.h +++ b/src/openrct2/actions/PeepSpawnPlaceAction.h @@ -27,7 +27,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/PlayerKickAction.cpp b/src/openrct2/actions/PlayerKickAction.cpp index d5b1f712c3..7d22599eae 100644 --- a/src/openrct2/actions/PlayerKickAction.cpp +++ b/src/openrct2/actions/PlayerKickAction.cpp @@ -34,12 +34,12 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_playerId); } - Result PlayerKickAction::Query() const + Result PlayerKickAction::Query(GameState_t& gameState) const { return Network::KickPlayer(_playerId, false); } - Result PlayerKickAction::Execute() const + Result PlayerKickAction::Execute(GameState_t& gameState) const { return Network::KickPlayer(_playerId, true); } diff --git a/src/openrct2/actions/PlayerKickAction.h b/src/openrct2/actions/PlayerKickAction.h index a23ac0af3c..9aba3822e3 100644 --- a/src/openrct2/actions/PlayerKickAction.h +++ b/src/openrct2/actions/PlayerKickAction.h @@ -28,7 +28,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/PlayerSetGroupAction.cpp b/src/openrct2/actions/PlayerSetGroupAction.cpp index 12ed111af5..1b6029e4e5 100644 --- a/src/openrct2/actions/PlayerSetGroupAction.cpp +++ b/src/openrct2/actions/PlayerSetGroupAction.cpp @@ -36,12 +36,12 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_playerId) << DS_TAG(_groupId); } - Result PlayerSetGroupAction::Query() const + Result PlayerSetGroupAction::Query(GameState_t& gameState) const { return Network::SetPlayerGroup(GetPlayer(), _playerId, _groupId, false); } - Result PlayerSetGroupAction::Execute() const + Result PlayerSetGroupAction::Execute(GameState_t& gameState) const { return Network::SetPlayerGroup(GetPlayer(), _playerId, _groupId, true); } diff --git a/src/openrct2/actions/PlayerSetGroupAction.h b/src/openrct2/actions/PlayerSetGroupAction.h index 574d9d1882..c4adba0eb4 100644 --- a/src/openrct2/actions/PlayerSetGroupAction.h +++ b/src/openrct2/actions/PlayerSetGroupAction.h @@ -28,7 +28,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/RideCreateAction.cpp b/src/openrct2/actions/RideCreateAction.cpp index e01ebcff33..f8799dc07c 100644 --- a/src/openrct2/actions/RideCreateAction.cpp +++ b/src/openrct2/actions/RideCreateAction.cpp @@ -73,7 +73,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_rideType) << DS_TAG(_subType) << DS_TAG(_entranceObjectIndex) << DS_TAG(_colour1) << DS_TAG(_colour2); } - Result RideCreateAction::Query() const + Result RideCreateAction::Query(GameState_t& gameState) const { auto rideIndex = GetNextFreeRideId(); if (rideIndex.IsNull()) @@ -121,7 +121,7 @@ namespace OpenRCT2::GameActions return res; } - Result RideCreateAction::Execute() const + Result RideCreateAction::Execute(GameState_t& gameState) const { auto res = Result(); @@ -154,7 +154,6 @@ namespace OpenRCT2::GameActions ride->status = RideStatus::closed; ride->numTrains = 1; - auto& gameState = getGameState(); if (gameState.cheats.disableTrainLengthLimit) { // Reduce amount of proposed trains to prevent 32 trains from always spawning when limits are disabled diff --git a/src/openrct2/actions/RideCreateAction.h b/src/openrct2/actions/RideCreateAction.h index f75a1a0bf9..fd881d9816 100644 --- a/src/openrct2/actions/RideCreateAction.h +++ b/src/openrct2/actions/RideCreateAction.h @@ -35,7 +35,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/RideDemolishAction.cpp b/src/openrct2/actions/RideDemolishAction.cpp index 15b10f7fb9..6c605d37e2 100644 --- a/src/openrct2/actions/RideDemolishAction.cpp +++ b/src/openrct2/actions/RideDemolishAction.cpp @@ -55,7 +55,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_rideIndex) << DS_TAG(_modifyType); } - Result RideDemolishAction::Query() const + Result RideDemolishAction::Query(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) @@ -100,7 +100,7 @@ namespace OpenRCT2::GameActions return result; } - Result RideDemolishAction::Execute() const + Result RideDemolishAction::Execute(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) @@ -112,18 +112,18 @@ namespace OpenRCT2::GameActions switch (_modifyType) { case RideModifyType::demolish: - return DemolishRide(*ride); + return DemolishRide(gameState, *ride); case RideModifyType::renew: - return RefurbishRide(*ride); + return RefurbishRide(gameState, *ride); default: LOG_ERROR("Unknown ride demolish type %d", _modifyType); return Result(Status::InvalidParameters, STR_CANT_DO_THIS, STR_ERR_VALUE_OUT_OF_RANGE); } } - Result RideDemolishAction::DemolishRide(Ride& ride) const + Result RideDemolishAction::DemolishRide(GameState_t& gameState, Ride& ride) const { - money64 refundPrice = DemolishTracks(); + money64 refundPrice = DemolishTracks(gameState); RideClearForConstruction(ride); ride.removePeeps(); @@ -166,10 +166,9 @@ namespace OpenRCT2::GameActions windowMgr->CloseByClass(WindowClass::NewCampaign); // Refresh windows that display the ride name - auto windowManager = OpenRCT2::Ui::GetWindowManager(); - windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_CAMPAIGN_RIDE_LIST)); - windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_RIDE_LIST)); - windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_GUEST_LIST)); + windowMgr->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_CAMPAIGN_RIDE_LIST)); + windowMgr->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_RIDE_LIST)); + windowMgr->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_GUEST_LIST)); ScrollingTextInvalidate(); GfxInvalidateScreen(); @@ -177,12 +176,12 @@ namespace OpenRCT2::GameActions return res; } - money64 RideDemolishAction::MazeRemoveTrack(const CoordsXYZD& coords) const + money64 RideDemolishAction::MazeRemoveTrack(GameState_t& gameState, const CoordsXYZD& coords) const { auto setMazeTrack = MazeSetTrackAction(coords, false, _rideIndex, GC_SET_MAZE_TRACK_FILL); setMazeTrack.SetFlags(GetFlags()); - auto execRes = ExecuteNested(&setMazeTrack); + auto execRes = ExecuteNested(&setMazeTrack, gameState); if (execRes.Error == Status::Ok) { return execRes.Cost; @@ -191,13 +190,12 @@ namespace OpenRCT2::GameActions return kMoney64Undefined; } - money64 RideDemolishAction::DemolishTracks() const + money64 RideDemolishAction::DemolishTracks(GameState_t& gameState) const { money64 refundPrice = 0; uint8_t oldpaused = gGamePaused; gGamePaused = 0; - auto& gameState = getGameState(); for (TileCoordsXY tilePos = {}; tilePos.x < gameState.mapSize.x; ++tilePos.x) { @@ -230,7 +228,7 @@ namespace OpenRCT2::GameActions auto trackRemoveAction = TrackRemoveAction(type, trackElement->GetSequenceIndex(), location); trackRemoveAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND); - auto removRes = ExecuteNested(&trackRemoveAction); + auto removRes = ExecuteNested(&trackRemoveAction, gameState); if (removRes.Error != Status::Ok) { TileElementRemove(tileElement); @@ -251,7 +249,7 @@ namespace OpenRCT2::GameActions for (Direction dir : kAllDirections) { const CoordsXYZ off = { kDirOffsets[dir], 0 }; - money64 removePrice = MazeRemoveTrack({ location + off, dir }); + money64 removePrice = MazeRemoveTrack(gameState, { location + off, dir }); if (removePrice != kMoney64Undefined) { refundPrice += removePrice; @@ -269,7 +267,7 @@ namespace OpenRCT2::GameActions return refundPrice; } - Result RideDemolishAction::RefurbishRide(Ride& ride) const + Result RideDemolishAction::RefurbishRide(GameState_t& gameState, Ride& ride) const { auto res = Result(); res.Expenditure = ExpenditureType::rideConstruction; diff --git a/src/openrct2/actions/RideDemolishAction.h b/src/openrct2/actions/RideDemolishAction.h index 9368435302..fcd5983806 100644 --- a/src/openrct2/actions/RideDemolishAction.h +++ b/src/openrct2/actions/RideDemolishAction.h @@ -34,14 +34,14 @@ namespace OpenRCT2::GameActions uint32_t GetCooldownTime() const final; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: - Result DemolishRide(Ride& ride) const; - money64 MazeRemoveTrack(const CoordsXYZD& coords) const; - money64 DemolishTracks() const; - Result RefurbishRide(Ride& ride) const; + Result DemolishRide(GameState_t& gameState, Ride& ride) const; + money64 MazeRemoveTrack(GameState_t& gameState, const CoordsXYZD& coords) const; + money64 DemolishTracks(GameState_t& gameState) const; + Result RefurbishRide(GameState_t& gameState, Ride& ride) const; money64 GetRefurbishPrice(const Ride& ride) const; money64 GetRefundPrice(const Ride& ride) const; }; diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp index 8b930bffd8..3f8c92435c 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp @@ -54,7 +54,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc) << DS_TAG(_direction) << DS_TAG(_rideIndex) << DS_TAG(_stationNum) << DS_TAG(_isExit); } - Result RideEntranceExitPlaceAction::Query() const + Result RideEntranceExitPlaceAction::Query(GameState_t& gameState) const { const auto errorTitle = _isExit ? STR_CANT_BUILD_MOVE_EXIT_FOR_THIS_RIDE_ATTRACTION : STR_CANT_BUILD_MOVE_ENTRANCE_FOR_THIS_RIDE_ATTRACTION; @@ -91,7 +91,7 @@ namespace OpenRCT2::GameActions location.ToCoordsXY(), _rideIndex, _stationNum, _isExit); rideEntranceExitRemove.SetFlags(GetFlags()); - auto result = QueryNested(&rideEntranceExitRemove); + auto result = QueryNested(&rideEntranceExitRemove, gameState); if (result.Error != Status::Ok) { result.ErrorTitle = errorTitle; @@ -140,7 +140,7 @@ namespace OpenRCT2::GameActions return res; } - Result RideEntranceExitPlaceAction::Execute() const + Result RideEntranceExitPlaceAction::Execute(GameState_t& gameState) const { // 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 @@ -167,7 +167,7 @@ namespace OpenRCT2::GameActions location.ToCoordsXY(), _rideIndex, _stationNum, _isExit); rideEntranceExitRemove.SetFlags(GetFlags()); - auto result = ExecuteNested(&rideEntranceExitRemove); + auto result = ExecuteNested(&rideEntranceExitRemove, gameState); if (result.Error != Status::Ok) { result.ErrorTitle = errorTitle; diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.h b/src/openrct2/actions/RideEntranceExitPlaceAction.h index 7078a95794..a0b2be59ad 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.h +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.h @@ -33,8 +33,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; static Result TrackPlaceQuery(const CoordsXYZ& loc, const bool isExit); }; diff --git a/src/openrct2/actions/RideEntranceExitRemoveAction.cpp b/src/openrct2/actions/RideEntranceExitRemoveAction.cpp index b50328e488..686daf2016 100644 --- a/src/openrct2/actions/RideEntranceExitRemoveAction.cpp +++ b/src/openrct2/actions/RideEntranceExitRemoveAction.cpp @@ -67,7 +67,7 @@ namespace OpenRCT2::GameActions return nullptr; } - Result RideEntranceExitRemoveAction::Query() const + Result RideEntranceExitRemoveAction::Query(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) @@ -110,7 +110,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result RideEntranceExitRemoveAction::Execute() const + Result RideEntranceExitRemoveAction::Execute(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) diff --git a/src/openrct2/actions/RideEntranceExitRemoveAction.h b/src/openrct2/actions/RideEntranceExitRemoveAction.h index cb554a1aab..cb955f86ea 100644 --- a/src/openrct2/actions/RideEntranceExitRemoveAction.h +++ b/src/openrct2/actions/RideEntranceExitRemoveAction.h @@ -30,7 +30,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/RideFreezeRatingAction.cpp b/src/openrct2/actions/RideFreezeRatingAction.cpp index 0bd5d82430..cccf5f6fc3 100644 --- a/src/openrct2/actions/RideFreezeRatingAction.cpp +++ b/src/openrct2/actions/RideFreezeRatingAction.cpp @@ -34,7 +34,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_rideIndex) << DS_TAG(_type) << DS_TAG(_value); } - Result RideFreezeRatingAction::Query() const + Result RideFreezeRatingAction::Query(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) @@ -52,7 +52,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result RideFreezeRatingAction::Execute() const + Result RideFreezeRatingAction::Execute(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); diff --git a/src/openrct2/actions/RideFreezeRatingAction.h b/src/openrct2/actions/RideFreezeRatingAction.h index 4fd1208f23..adf90b74b3 100644 --- a/src/openrct2/actions/RideFreezeRatingAction.h +++ b/src/openrct2/actions/RideFreezeRatingAction.h @@ -34,7 +34,7 @@ namespace OpenRCT2::GameActions void AcceptParameters(GameActionParameterVisitor&) final; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/RideSetAppearanceAction.cpp b/src/openrct2/actions/RideSetAppearanceAction.cpp index c88ce64a07..7e78860bfc 100644 --- a/src/openrct2/actions/RideSetAppearanceAction.cpp +++ b/src/openrct2/actions/RideSetAppearanceAction.cpp @@ -50,7 +50,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_rideIndex) << DS_TAG(_type) << DS_TAG(_value) << DS_TAG(_index); } - GameActions::Result RideSetAppearanceAction::Query() const + GameActions::Result RideSetAppearanceAction::Query(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) @@ -95,7 +95,7 @@ namespace OpenRCT2::GameActions return GameActions::Result(); } - GameActions::Result RideSetAppearanceAction::Execute() const + GameActions::Result RideSetAppearanceAction::Execute(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) diff --git a/src/openrct2/actions/RideSetAppearanceAction.h b/src/openrct2/actions/RideSetAppearanceAction.h index a86203ef51..58f8055ff8 100644 --- a/src/openrct2/actions/RideSetAppearanceAction.h +++ b/src/openrct2/actions/RideSetAppearanceAction.h @@ -44,7 +44,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/RideSetColourSchemeAction.cpp b/src/openrct2/actions/RideSetColourSchemeAction.cpp index 5e31fad0fb..01b1bcd7c8 100644 --- a/src/openrct2/actions/RideSetColourSchemeAction.cpp +++ b/src/openrct2/actions/RideSetColourSchemeAction.cpp @@ -47,7 +47,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc) << DS_TAG(_trackType) << DS_TAG(_newColourScheme); } - Result RideSetColourSchemeAction::Query() const + Result RideSetColourSchemeAction::Query(GameState_t& gameState) const { if (!LocationValid(_loc)) { @@ -70,7 +70,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result RideSetColourSchemeAction::Execute() const + Result RideSetColourSchemeAction::Execute(GameState_t& gameState) const { Result res = Result(); res.Expenditure = ExpenditureType::rideConstruction; diff --git a/src/openrct2/actions/RideSetColourSchemeAction.h b/src/openrct2/actions/RideSetColourSchemeAction.h index c15a7a3e99..398effee96 100644 --- a/src/openrct2/actions/RideSetColourSchemeAction.h +++ b/src/openrct2/actions/RideSetColourSchemeAction.h @@ -29,7 +29,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/RideSetNameAction.cpp b/src/openrct2/actions/RideSetNameAction.cpp index fc6fc27f61..37b728114d 100644 --- a/src/openrct2/actions/RideSetNameAction.cpp +++ b/src/openrct2/actions/RideSetNameAction.cpp @@ -46,7 +46,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_rideIndex) << DS_TAG(_name); } - Result RideSetNameAction::Query() const + Result RideSetNameAction::Query(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) @@ -63,7 +63,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result RideSetNameAction::Execute() const + Result RideSetNameAction::Execute(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) diff --git a/src/openrct2/actions/RideSetNameAction.h b/src/openrct2/actions/RideSetNameAction.h index 81587f9d37..4a4c14fa31 100644 --- a/src/openrct2/actions/RideSetNameAction.h +++ b/src/openrct2/actions/RideSetNameAction.h @@ -28,7 +28,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/RideSetPriceAction.cpp b/src/openrct2/actions/RideSetPriceAction.cpp index ca60740157..c9fb948bec 100644 --- a/src/openrct2/actions/RideSetPriceAction.cpp +++ b/src/openrct2/actions/RideSetPriceAction.cpp @@ -50,7 +50,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_rideIndex) << DS_TAG(_price) << DS_TAG(_primaryPrice); } - Result RideSetPriceAction::Query() const + Result RideSetPriceAction::Query(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) @@ -75,7 +75,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result RideSetPriceAction::Execute() const + Result RideSetPriceAction::Execute(GameState_t& gameState) const { Result res = Result(); res.Expenditure = ExpenditureType::parkRideTickets; diff --git a/src/openrct2/actions/RideSetPriceAction.h b/src/openrct2/actions/RideSetPriceAction.h index 8029eab0b7..6a73bef276 100644 --- a/src/openrct2/actions/RideSetPriceAction.h +++ b/src/openrct2/actions/RideSetPriceAction.h @@ -29,8 +29,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: void RideSetCommonPrice(ShopItem shopItem) const; diff --git a/src/openrct2/actions/RideSetSettingAction.cpp b/src/openrct2/actions/RideSetSettingAction.cpp index 0e9760c14b..0ce7b0c4fd 100644 --- a/src/openrct2/actions/RideSetSettingAction.cpp +++ b/src/openrct2/actions/RideSetSettingAction.cpp @@ -46,7 +46,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_rideIndex) << DS_TAG(_setting) << DS_TAG(_value); } - Result RideSetSettingAction::Query() const + Result RideSetSettingAction::Query(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) @@ -153,7 +153,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result RideSetSettingAction::Execute() const + Result RideSetSettingAction::Execute(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) diff --git a/src/openrct2/actions/RideSetSettingAction.h b/src/openrct2/actions/RideSetSettingAction.h index 5db87c1f07..55e2c74e42 100644 --- a/src/openrct2/actions/RideSetSettingAction.h +++ b/src/openrct2/actions/RideSetSettingAction.h @@ -44,8 +44,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: bool RideIsModeValid(const Ride& ride) const; diff --git a/src/openrct2/actions/RideSetStatusAction.cpp b/src/openrct2/actions/RideSetStatusAction.cpp index 43e2bfc685..48b3bc049f 100644 --- a/src/openrct2/actions/RideSetStatusAction.cpp +++ b/src/openrct2/actions/RideSetStatusAction.cpp @@ -53,7 +53,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_rideIndex) << DS_TAG(_status); } - Result RideSetStatusAction::Query() const + Result RideSetStatusAction::Query(GameState_t& gameState) const { Result res = Result(); @@ -116,7 +116,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result RideSetStatusAction::Execute() const + Result RideSetStatusAction::Execute(GameState_t& gameState) const { Result res = Result(); res.Expenditure = ExpenditureType::rideRunningCosts; diff --git a/src/openrct2/actions/RideSetStatusAction.h b/src/openrct2/actions/RideSetStatusAction.h index e5087c0de5..78cf3a046f 100644 --- a/src/openrct2/actions/RideSetStatusAction.h +++ b/src/openrct2/actions/RideSetStatusAction.h @@ -28,7 +28,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/RideSetVehicleAction.cpp b/src/openrct2/actions/RideSetVehicleAction.cpp index 61953c884c..eca7b7c0cb 100644 --- a/src/openrct2/actions/RideSetVehicleAction.cpp +++ b/src/openrct2/actions/RideSetVehicleAction.cpp @@ -61,7 +61,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_rideIndex) << DS_TAG(_type) << DS_TAG(_value) << DS_TAG(_colour); } - Result RideSetVehicleAction::Query() const + Result RideSetVehicleAction::Query(GameState_t& gameState) const { if (_type >= RideSetVehicleType::Count) { @@ -124,7 +124,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result RideSetVehicleAction::Execute() const + Result RideSetVehicleAction::Execute(GameState_t& gameState) const { auto errTitle = kSetVehicleTypeErrorTitle[EnumValue(_type)]; auto ride = GetRide(_rideIndex); diff --git a/src/openrct2/actions/RideSetVehicleAction.h b/src/openrct2/actions/RideSetVehicleAction.h index 778d8db877..625f9b7741 100644 --- a/src/openrct2/actions/RideSetVehicleAction.h +++ b/src/openrct2/actions/RideSetVehicleAction.h @@ -39,8 +39,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: bool RideIsVehicleTypeValid(const Ride& ride) const; diff --git a/src/openrct2/actions/ScenarioSetSettingAction.cpp b/src/openrct2/actions/ScenarioSetSettingAction.cpp index 17314ba671..b6b7746d22 100644 --- a/src/openrct2/actions/ScenarioSetSettingAction.cpp +++ b/src/openrct2/actions/ScenarioSetSettingAction.cpp @@ -33,7 +33,7 @@ namespace OpenRCT2::GameActions visitor.Visit("value", _value); } - Result ScenarioSetSettingAction::Query() const + Result ScenarioSetSettingAction::Query(GameState_t& gameState) const { if (_setting >= ScenarioSetSetting::Count) { @@ -44,9 +44,8 @@ namespace OpenRCT2::GameActions return Result(); } - Result ScenarioSetSettingAction::Execute() const + Result ScenarioSetSettingAction::Execute(GameState_t& gameState) const { - auto& gameState = getGameState(); auto* windowMgr = Ui::GetWindowManager(); switch (_setting) diff --git a/src/openrct2/actions/ScenarioSetSettingAction.h b/src/openrct2/actions/ScenarioSetSettingAction.h index 3becef7591..a06e24cfac 100644 --- a/src/openrct2/actions/ScenarioSetSettingAction.h +++ b/src/openrct2/actions/ScenarioSetSettingAction.h @@ -63,7 +63,7 @@ namespace OpenRCT2::GameActions } void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/ScenerySetRestrictedAction.cpp b/src/openrct2/actions/ScenerySetRestrictedAction.cpp index 2270091068..f2d2fc2d30 100644 --- a/src/openrct2/actions/ScenerySetRestrictedAction.cpp +++ b/src/openrct2/actions/ScenerySetRestrictedAction.cpp @@ -34,7 +34,7 @@ namespace OpenRCT2::GameActions return GameAction::GetActionFlags() | Flags::AllowWhilePaused; } - Result ScenerySetRestrictedAction::Query() const + Result ScenerySetRestrictedAction::Query(GameState_t& gameState) const { if (!ObjectTypeCanBeRestricted(_objectType)) { @@ -49,7 +49,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result ScenerySetRestrictedAction::Execute() const + Result ScenerySetRestrictedAction::Execute(GameState_t& gameState) const { auto sceneryType = GetSceneryTypeFromObjectType(_objectType); SetSceneryItemRestricted({ sceneryType, _objectIndex }, _isRestricted); diff --git a/src/openrct2/actions/ScenerySetRestrictedAction.h b/src/openrct2/actions/ScenerySetRestrictedAction.h index cbaec7bb53..32e227090f 100644 --- a/src/openrct2/actions/ScenerySetRestrictedAction.h +++ b/src/openrct2/actions/ScenerySetRestrictedAction.h @@ -27,7 +27,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/SignSetNameAction.cpp b/src/openrct2/actions/SignSetNameAction.cpp index f86b902597..247bcbe35a 100644 --- a/src/openrct2/actions/SignSetNameAction.cpp +++ b/src/openrct2/actions/SignSetNameAction.cpp @@ -44,7 +44,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_bannerIndex) << DS_TAG(_name); } - Result SignSetNameAction::Query() const + Result SignSetNameAction::Query(GameState_t& gameState) const { auto banner = GetBanner(_bannerIndex); if (banner == nullptr) @@ -75,7 +75,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result SignSetNameAction::Execute() const + Result SignSetNameAction::Execute(GameState_t& gameState) const { auto banner = GetBanner(_bannerIndex); if (banner == nullptr) diff --git a/src/openrct2/actions/SignSetNameAction.h b/src/openrct2/actions/SignSetNameAction.h index 3723d8e727..1114f47d3d 100644 --- a/src/openrct2/actions/SignSetNameAction.h +++ b/src/openrct2/actions/SignSetNameAction.h @@ -28,7 +28,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/SignSetStyleAction.cpp b/src/openrct2/actions/SignSetStyleAction.cpp index 96cd91149c..088f25b2a5 100644 --- a/src/openrct2/actions/SignSetStyleAction.cpp +++ b/src/openrct2/actions/SignSetStyleAction.cpp @@ -50,7 +50,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_bannerIndex) << DS_TAG(_mainColour) << DS_TAG(_textColour) << DS_TAG(_isLarge); } - Result SignSetStyleAction::Query() const + Result SignSetStyleAction::Query(GameState_t& gameState) const { auto banner = GetBanner(_bannerIndex); if (banner == nullptr) @@ -102,7 +102,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result SignSetStyleAction::Execute() const + Result SignSetStyleAction::Execute(GameState_t& gameState) const { auto banner = GetBanner(_bannerIndex); if (banner == nullptr) diff --git a/src/openrct2/actions/SignSetStyleAction.h b/src/openrct2/actions/SignSetStyleAction.h index 4c1b67d798..9626bc7baf 100644 --- a/src/openrct2/actions/SignSetStyleAction.h +++ b/src/openrct2/actions/SignSetStyleAction.h @@ -30,7 +30,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/SmallSceneryPlaceAction.cpp index 54ef9fa025..12ae16e987 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.cpp @@ -78,7 +78,7 @@ namespace OpenRCT2::GameActions << DS_TAG(_secondaryColour) << DS_TAG(_tertiaryColour); } - Result SmallSceneryPlaceAction::Query() const + Result SmallSceneryPlaceAction::Query(GameState_t& gameState) const { bool isOnWater = false; bool supportsRequired = false; @@ -170,7 +170,6 @@ namespace OpenRCT2::GameActions targetHeight = surfaceHeight; } - auto& gameState = getGameState(); if (gLegacyScene != LegacyScene::scenarioEditor && !gameState.cheats.sandboxMode && !MapIsLocationOwned({ _loc.x, _loc.y, targetHeight })) { @@ -285,7 +284,7 @@ namespace OpenRCT2::GameActions return res; } - Result SmallSceneryPlaceAction::Execute() const + Result SmallSceneryPlaceAction::Execute(GameState_t& gameState) const { bool supportsRequired = false; if (_loc.z != 0) diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.h b/src/openrct2/actions/SmallSceneryPlaceAction.h index 882fa4fbc4..e943433759 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.h +++ b/src/openrct2/actions/SmallSceneryPlaceAction.h @@ -42,7 +42,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.cpp b/src/openrct2/actions/SmallSceneryRemoveAction.cpp index 0a8546559f..0ffa5cba6e 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.cpp +++ b/src/openrct2/actions/SmallSceneryRemoveAction.cpp @@ -55,7 +55,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc) << DS_TAG(_quadrant) << DS_TAG(_sceneryType); } - Result SmallSceneryRemoveAction::Query() const + Result SmallSceneryRemoveAction::Query(GameState_t& gameState) const { Result res = Result(); @@ -110,7 +110,7 @@ namespace OpenRCT2::GameActions return res; } - Result SmallSceneryRemoveAction::Execute() const + Result SmallSceneryRemoveAction::Execute(GameState_t& gameState) const { Result res = Result(); diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.h b/src/openrct2/actions/SmallSceneryRemoveAction.h index 13a482e59a..a75ce17e6e 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.h +++ b/src/openrct2/actions/SmallSceneryRemoveAction.h @@ -29,8 +29,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: TileElement* FindSceneryElement() const; diff --git a/src/openrct2/actions/SmallScenerySetColourAction.cpp b/src/openrct2/actions/SmallScenerySetColourAction.cpp index ba7638f564..28ed907fa0 100644 --- a/src/openrct2/actions/SmallScenerySetColourAction.cpp +++ b/src/openrct2/actions/SmallScenerySetColourAction.cpp @@ -59,12 +59,12 @@ namespace OpenRCT2::GameActions << DS_TAG(_secondaryColour) << DS_TAG(_tertiaryColour); } - Result SmallScenerySetColourAction::Query() const + Result SmallScenerySetColourAction::Query(GameState_t& gameState) const { return QueryExecute(false); } - Result SmallScenerySetColourAction::Execute() const + Result SmallScenerySetColourAction::Execute(GameState_t& gameState) const { return QueryExecute(true); } diff --git a/src/openrct2/actions/SmallScenerySetColourAction.h b/src/openrct2/actions/SmallScenerySetColourAction.h index 123e4b74a5..1b1e76ca0c 100644 --- a/src/openrct2/actions/SmallScenerySetColourAction.h +++ b/src/openrct2/actions/SmallScenerySetColourAction.h @@ -34,8 +34,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: Result QueryExecute(bool isExecuting) const; diff --git a/src/openrct2/actions/StaffFireAction.cpp b/src/openrct2/actions/StaffFireAction.cpp index ddf9f7b7f0..7d8767a556 100644 --- a/src/openrct2/actions/StaffFireAction.cpp +++ b/src/openrct2/actions/StaffFireAction.cpp @@ -38,7 +38,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_spriteId); } - Result StaffFireAction::Query() const + Result StaffFireAction::Query(GameState_t& gameState) const { if (_spriteId.ToUnderlying() >= kMaxEntities || _spriteId.IsNull()) { @@ -65,7 +65,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result StaffFireAction::Execute() const + Result StaffFireAction::Execute(GameState_t& gameState) const { auto staff = getGameState().entities.TryGetEntity(_spriteId); if (staff == nullptr) diff --git a/src/openrct2/actions/StaffFireAction.h b/src/openrct2/actions/StaffFireAction.h index 70fb105dc6..b1ba498729 100644 --- a/src/openrct2/actions/StaffFireAction.h +++ b/src/openrct2/actions/StaffFireAction.h @@ -27,7 +27,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/StaffHireNewAction.cpp b/src/openrct2/actions/StaffHireNewAction.cpp index cad7bdbaa7..0f551418ba 100644 --- a/src/openrct2/actions/StaffHireNewAction.cpp +++ b/src/openrct2/actions/StaffHireNewAction.cpp @@ -62,12 +62,12 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_autoPosition) << DS_TAG(_staffType) << DS_TAG(_costumeIndex) << DS_TAG(_staffOrders); } - Result StaffHireNewAction::Query() const + Result StaffHireNewAction::Query(GameState_t& gameState) const { return QueryExecute(false); } - Result StaffHireNewAction::Execute() const + Result StaffHireNewAction::Execute(GameState_t& gameState) const { return QueryExecute(true); } diff --git a/src/openrct2/actions/StaffHireNewAction.h b/src/openrct2/actions/StaffHireNewAction.h index 0a69ad2016..3a04be0c92 100644 --- a/src/openrct2/actions/StaffHireNewAction.h +++ b/src/openrct2/actions/StaffHireNewAction.h @@ -36,8 +36,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: Result QueryExecute(bool execute) const; diff --git a/src/openrct2/actions/StaffSetColourAction.cpp b/src/openrct2/actions/StaffSetColourAction.cpp index 3400462ed9..a7d8ae0f37 100644 --- a/src/openrct2/actions/StaffSetColourAction.cpp +++ b/src/openrct2/actions/StaffSetColourAction.cpp @@ -44,7 +44,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_staffType) << DS_TAG(_colour); } - Result StaffSetColourAction::Query() const + Result StaffSetColourAction::Query(GameState_t& gameState) const { auto staffType = static_cast(_staffType); if (staffType != StaffType::Handyman && staffType != StaffType::Mechanic && staffType != StaffType::Security) @@ -55,7 +55,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result StaffSetColourAction::Execute() const + Result StaffSetColourAction::Execute(GameState_t& gameState) const { // Update global uniform colour property auto res = StaffSetColour(static_cast(_staffType), _colour); diff --git a/src/openrct2/actions/StaffSetColourAction.h b/src/openrct2/actions/StaffSetColourAction.h index 27646bb878..22dce4465b 100644 --- a/src/openrct2/actions/StaffSetColourAction.h +++ b/src/openrct2/actions/StaffSetColourAction.h @@ -29,7 +29,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/StaffSetCostumeAction.cpp b/src/openrct2/actions/StaffSetCostumeAction.cpp index ff3b73553e..7130f1faf8 100644 --- a/src/openrct2/actions/StaffSetCostumeAction.cpp +++ b/src/openrct2/actions/StaffSetCostumeAction.cpp @@ -45,7 +45,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_spriteIndex) << DS_TAG(_costume); } - Result StaffSetCostumeAction::Query() const + Result StaffSetCostumeAction::Query(GameState_t& gameState) const { if (_spriteIndex.ToUnderlying() >= kMaxEntities || _spriteIndex.IsNull()) { @@ -72,7 +72,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result StaffSetCostumeAction::Execute() const + Result StaffSetCostumeAction::Execute(GameState_t& gameState) const { auto* staff = getGameState().entities.TryGetEntity(_spriteIndex); if (staff == nullptr) diff --git a/src/openrct2/actions/StaffSetCostumeAction.h b/src/openrct2/actions/StaffSetCostumeAction.h index 06f1431e33..9e544031ef 100644 --- a/src/openrct2/actions/StaffSetCostumeAction.h +++ b/src/openrct2/actions/StaffSetCostumeAction.h @@ -29,7 +29,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/StaffSetNameAction.cpp b/src/openrct2/actions/StaffSetNameAction.cpp index a44e75ea33..d199dc56ec 100644 --- a/src/openrct2/actions/StaffSetNameAction.cpp +++ b/src/openrct2/actions/StaffSetNameAction.cpp @@ -47,7 +47,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_spriteIndex) << DS_TAG(_name); } - Result StaffSetNameAction::Query() const + Result StaffSetNameAction::Query(GameState_t& gameState) const { if (_spriteIndex.ToUnderlying() >= kMaxEntities || _spriteIndex.IsNull()) { @@ -65,7 +65,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result StaffSetNameAction::Execute() const + Result StaffSetNameAction::Execute(GameState_t& gameState) const { auto staff = getGameState().entities.TryGetEntity(_spriteIndex); if (staff == nullptr) diff --git a/src/openrct2/actions/StaffSetNameAction.h b/src/openrct2/actions/StaffSetNameAction.h index d46e835f61..20afb79391 100644 --- a/src/openrct2/actions/StaffSetNameAction.h +++ b/src/openrct2/actions/StaffSetNameAction.h @@ -27,7 +27,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/StaffSetOrdersAction.cpp b/src/openrct2/actions/StaffSetOrdersAction.cpp index a6761bd853..6330bbfe67 100644 --- a/src/openrct2/actions/StaffSetOrdersAction.cpp +++ b/src/openrct2/actions/StaffSetOrdersAction.cpp @@ -44,7 +44,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_spriteIndex) << DS_TAG(_ordersId); } - Result StaffSetOrdersAction::Query() const + Result StaffSetOrdersAction::Query(GameState_t& gameState) const { if (_spriteIndex.ToUnderlying() >= kMaxEntities || _spriteIndex.IsNull()) { @@ -63,7 +63,7 @@ namespace OpenRCT2::GameActions return Result(); } - Result StaffSetOrdersAction::Execute() const + Result StaffSetOrdersAction::Execute(GameState_t& gameState) const { auto* staff = getGameState().entities.TryGetEntity(_spriteIndex); if (staff == nullptr) diff --git a/src/openrct2/actions/StaffSetOrdersAction.h b/src/openrct2/actions/StaffSetOrdersAction.h index 3c5db943a9..08aabd7e1f 100644 --- a/src/openrct2/actions/StaffSetOrdersAction.h +++ b/src/openrct2/actions/StaffSetOrdersAction.h @@ -28,7 +28,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.cpp b/src/openrct2/actions/StaffSetPatrolAreaAction.cpp index d1de929fc2..a366f8816a 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.cpp +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.cpp @@ -45,12 +45,12 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_spriteId) << DS_TAG(_range) << DS_TAG(_mode); } - Result StaffSetPatrolAreaAction::Query() const + Result StaffSetPatrolAreaAction::Query(GameState_t& gameState) const { return QueryExecute(false); } - Result StaffSetPatrolAreaAction::Execute() const + Result StaffSetPatrolAreaAction::Execute(GameState_t& gameState) const { return QueryExecute(true); } diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.h b/src/openrct2/actions/StaffSetPatrolAreaAction.h index 389ce79abb..5c2b89757b 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.h +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.h @@ -37,7 +37,7 @@ namespace OpenRCT2::GameActions void AcceptParameters(GameActionParameterVisitor&) final; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/SurfaceSetStyleAction.cpp b/src/openrct2/actions/SurfaceSetStyleAction.cpp index 5c359ba6e8..4c3a198889 100644 --- a/src/openrct2/actions/SurfaceSetStyleAction.cpp +++ b/src/openrct2/actions/SurfaceSetStyleAction.cpp @@ -45,7 +45,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_range) << DS_TAG(_surfaceStyle) << DS_TAG(_edgeStyle); } - Result SurfaceSetStyleAction::Query() const + Result SurfaceSetStyleAction::Query(GameState_t& gameState) const { auto res = Result(); res.ErrorTitle = STR_CANT_CHANGE_LAND_TYPE; @@ -84,8 +84,6 @@ namespace OpenRCT2::GameActions res.Position.y = yMid; res.Position.z = heightMid; - auto& gameState = getGameState(); - // Do nothing if not in editor, sandbox mode or landscaping is forbidden if (gLegacyScene != LegacyScene::scenarioEditor && !gameState.cheats.sandboxMode && (gameState.park.flags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES)) @@ -145,7 +143,7 @@ namespace OpenRCT2::GameActions return res; } - Result SurfaceSetStyleAction::Execute() const + Result SurfaceSetStyleAction::Execute(GameState_t& gameState) const { auto res = Result(); res.ErrorTitle = STR_CANT_CHANGE_LAND_TYPE; diff --git a/src/openrct2/actions/SurfaceSetStyleAction.h b/src/openrct2/actions/SurfaceSetStyleAction.h index 503bb3eec2..1017dcd79c 100644 --- a/src/openrct2/actions/SurfaceSetStyleAction.h +++ b/src/openrct2/actions/SurfaceSetStyleAction.h @@ -27,7 +27,7 @@ namespace OpenRCT2::GameActions void AcceptParameters(GameActionParameterVisitor&) final; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/TileModifyAction.cpp b/src/openrct2/actions/TileModifyAction.cpp index 496dca62eb..fe793ca314 100644 --- a/src/openrct2/actions/TileModifyAction.cpp +++ b/src/openrct2/actions/TileModifyAction.cpp @@ -49,12 +49,12 @@ namespace OpenRCT2::GameActions << DS_TAG(_pasteBanner); } - Result TileModifyAction::Query() const + Result TileModifyAction::Query(GameState_t& gameState) const { return QueryExecute(false); } - Result TileModifyAction::Execute() const + Result TileModifyAction::Execute(GameState_t& gameState) const { return QueryExecute(true); } diff --git a/src/openrct2/actions/TileModifyAction.h b/src/openrct2/actions/TileModifyAction.h index 38e3c0d77d..a91e61f212 100644 --- a/src/openrct2/actions/TileModifyAction.h +++ b/src/openrct2/actions/TileModifyAction.h @@ -65,8 +65,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: Result QueryExecute(bool isExecuting) const; diff --git a/src/openrct2/actions/TrackDesignAction.cpp b/src/openrct2/actions/TrackDesignAction.cpp index 2caa02d2fa..d6aeb0d55a 100644 --- a/src/openrct2/actions/TrackDesignAction.cpp +++ b/src/openrct2/actions/TrackDesignAction.cpp @@ -52,7 +52,7 @@ namespace OpenRCT2::GameActions _td.Serialise(stream); } - Result TrackDesignAction::Query() const + Result TrackDesignAction::Query(GameState_t& gameState) const { auto res = Result(); res.Position.x = _loc.x + 16; @@ -65,7 +65,6 @@ namespace OpenRCT2::GameActions return Result(Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_OFF_EDGE_OF_MAP); } - auto& gameState = getGameState(); auto& objManager = GetContext()->GetObjectManager(); auto entryIndex = objManager.GetLoadedObjectEntryIndex(_td.trackAndVehicle.vehicleObject); if (entryIndex == kObjectEntryIndexNull) @@ -81,7 +80,7 @@ namespace OpenRCT2::GameActions // Colours do not matter as will be overwritten auto rideCreateAction = RideCreateAction(_td.trackAndVehicle.rtdIndex, entryIndex, 0, 0, gameState.lastEntranceStyle); rideCreateAction.SetFlags(GetFlags()); - auto r = ExecuteNested(&rideCreateAction); + auto r = ExecuteNested(&rideCreateAction, gameState); if (r.Error != Status::Ok) { return Result(Status::NoFreeElements, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, kStringIdNone); @@ -113,7 +112,7 @@ namespace OpenRCT2::GameActions auto gameAction = RideDemolishAction(ride->id, RideModifyType::demolish); gameAction.SetFlags(GetFlags()); - ExecuteNested(&gameAction); + ExecuteNested(&gameAction, gameState); if (queryRes.Error != Status::Ok) { @@ -130,7 +129,7 @@ namespace OpenRCT2::GameActions return res; } - Result TrackDesignAction::Execute() const + Result TrackDesignAction::Execute(GameState_t& gameState) const { auto res = Result(); res.Position.x = _loc.x + 16; @@ -138,7 +137,6 @@ namespace OpenRCT2::GameActions res.Position.z = _loc.z; res.Expenditure = ExpenditureType::rideConstruction; - auto& gameState = getGameState(); auto& objManager = GetContext()->GetObjectManager(); auto entryIndex = objManager.GetLoadedObjectEntryIndex(_td.trackAndVehicle.vehicleObject); if (entryIndex != kObjectEntryIndexNull) @@ -154,7 +152,7 @@ namespace OpenRCT2::GameActions // Colours do not matter as will be overwritten auto rideCreateAction = RideCreateAction(_td.trackAndVehicle.rtdIndex, entryIndex, 0, 0, gameState.lastEntranceStyle); rideCreateAction.SetFlags(GetFlags()); - auto r = ExecuteNested(&rideCreateAction); + auto r = ExecuteNested(&rideCreateAction, gameState); if (r.Error != Status::Ok) { return Result(Status::NoFreeElements, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, kStringIdNone); @@ -184,7 +182,7 @@ namespace OpenRCT2::GameActions { auto gameAction = RideDemolishAction(ride->id, RideModifyType::demolish); gameAction.SetFlags(GetFlags()); - ExecuteNested(&gameAction); + ExecuteNested(&gameAction, gameState); res.Error = queryRes.Error; res.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; @@ -202,7 +200,7 @@ namespace OpenRCT2::GameActions { auto gameAction = RideDemolishAction(ride->id, RideModifyType::demolish); gameAction.SetFlags(GetFlags()); - ExecuteNested(&gameAction); + ExecuteNested(&gameAction, gameState); res.Error = execRes.Error; res.ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; @@ -217,17 +215,17 @@ namespace OpenRCT2::GameActions auto colour = RideGetUnusedPresetVehicleColour(entryIndex); auto rideSetVehicleAction = GameActions::RideSetVehicleAction( ride->id, GameActions::RideSetVehicleType::RideEntry, entryIndex, colour); - ExecuteNested(&rideSetVehicleAction); + ExecuteNested(&rideSetVehicleAction, gameState); } SetOperatingSettingNested(ride->id, RideSetSetting::Mode, static_cast(_td.operation.rideMode), flags); auto rideSetVehicleAction2 = GameActions::RideSetVehicleAction( ride->id, GameActions::RideSetVehicleType::NumTrains, _td.trackAndVehicle.numberOfTrains); - ExecuteNested(&rideSetVehicleAction2); + ExecuteNested(&rideSetVehicleAction2, gameState); auto rideSetVehicleAction3 = GameActions::RideSetVehicleAction( ride->id, GameActions::RideSetVehicleType::NumCarsPerTrain, _td.trackAndVehicle.numberOfCarsPerTrain); - ExecuteNested(&rideSetVehicleAction3); + ExecuteNested(&rideSetVehicleAction3, gameState); SetOperatingSettingNested(ride->id, RideSetSetting::Departure, _td.operation.departFlags, flags); SetOperatingSettingNested(ride->id, RideSetSetting::MinWaitingTime, _td.operation.minWaitingTime, flags); @@ -266,7 +264,7 @@ namespace OpenRCT2::GameActions auto name = count == 1 ? _td.gameStateData.name : (_td.gameStateData.name + " " + std::to_string(count)); auto gameAction = RideSetNameAction(ride->id, name); gameAction.SetFlags(GetFlags()); - r = ExecuteNested(&gameAction); + r = ExecuteNested(&gameAction, gameState); } res.Cost = execRes.Cost; res.SetData(RideId{ ride->id }); diff --git a/src/openrct2/actions/TrackDesignAction.h b/src/openrct2/actions/TrackDesignAction.h index 19f48402ac..aa68836a7b 100644 --- a/src/openrct2/actions/TrackDesignAction.h +++ b/src/openrct2/actions/TrackDesignAction.h @@ -30,7 +30,7 @@ namespace OpenRCT2::GameActions void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index e97ef290d9..81e8338940 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -77,7 +77,7 @@ namespace OpenRCT2::GameActions << DS_TAG(_colour) << DS_TAG(_seatRotation) << DS_TAG(_trackPlaceFlags.holder); } - Result TrackPlaceAction::Query() const + Result TrackPlaceAction::Query(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) @@ -99,7 +99,6 @@ namespace OpenRCT2::GameActions Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_ERR_VALUE_OUT_OF_RANGE); } - auto& gameState = getGameState(); if (_rideType != ride->type && !gameState.cheats.allowArbitraryRideTypeChanges) { return Result(Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, kStringIdNone); @@ -408,7 +407,7 @@ namespace OpenRCT2::GameActions return res; } - Result TrackPlaceAction::Execute() const + Result TrackPlaceAction::Execute(GameState_t& gameState) const { auto ride = GetRide(_rideIndex); if (ride == nullptr) @@ -487,7 +486,6 @@ namespace OpenRCT2::GameActions } } - auto& gameState = getGameState(); if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && !gameState.cheats.disableClearanceChecks) { FootpathRemoveLitter(mapLoc); @@ -697,7 +695,7 @@ namespace OpenRCT2::GameActions auto rideSetSetting = GameActions::RideSetSettingAction( ride->id, GameActions::RideSetSetting::Mode, static_cast(newMode)); - ExecuteNested(&rideSetSetting); + ExecuteNested(&rideSetSetting, gameState); break; } default: diff --git a/src/openrct2/actions/TrackPlaceAction.h b/src/openrct2/actions/TrackPlaceAction.h index d74943670e..b01472e051 100644 --- a/src/openrct2/actions/TrackPlaceAction.h +++ b/src/openrct2/actions/TrackPlaceAction.h @@ -43,8 +43,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const final; void Serialise(DataSerialiser& stream) override; - GameActions::Result Query() const override; - GameActions::Result Execute() const override; + GameActions::Result Query(GameState_t& gameState) const override; + GameActions::Result Execute(GameState_t& gameState) const override; private: bool CheckMapCapacity(int16_t numTiles) const; diff --git a/src/openrct2/actions/TrackRemoveAction.cpp b/src/openrct2/actions/TrackRemoveAction.cpp index 3945f706ec..6c3b26247e 100644 --- a/src/openrct2/actions/TrackRemoveAction.cpp +++ b/src/openrct2/actions/TrackRemoveAction.cpp @@ -65,7 +65,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_trackType) << DS_TAG(_sequence) << DS_TAG(_origin); } - Result TrackRemoveAction::Query() const + Result TrackRemoveAction::Query(GameState_t& gameState) const { auto res = Result(); res.Position.x = _origin.x + 16; @@ -249,7 +249,7 @@ namespace OpenRCT2::GameActions return res; } - Result TrackRemoveAction::Execute() const + Result TrackRemoveAction::Execute(GameState_t& gameState) const { auto res = Result(); res.Position.x = _origin.x + 16; @@ -461,7 +461,7 @@ namespace OpenRCT2::GameActions auto rideSetSetting = GameActions::RideSetSettingAction( ride->id, GameActions::RideSetSetting::Mode, static_cast(newMode)); - ExecuteNested(&rideSetSetting); + ExecuteNested(&rideSetSetting, gameState); } break; diff --git a/src/openrct2/actions/TrackRemoveAction.h b/src/openrct2/actions/TrackRemoveAction.h index c784bbbb87..cdcf3ce97d 100644 --- a/src/openrct2/actions/TrackRemoveAction.h +++ b/src/openrct2/actions/TrackRemoveAction.h @@ -29,7 +29,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const final; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/TrackSetBrakeSpeedAction.cpp b/src/openrct2/actions/TrackSetBrakeSpeedAction.cpp index 61539c0bfa..f50530a881 100644 --- a/src/openrct2/actions/TrackSetBrakeSpeedAction.cpp +++ b/src/openrct2/actions/TrackSetBrakeSpeedAction.cpp @@ -43,12 +43,12 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc) << DS_TAG(_trackType) << DS_TAG(_brakeSpeed); } - Result TrackSetBrakeSpeedAction::Query() const + Result TrackSetBrakeSpeedAction::Query(GameState_t& gameState) const { return QueryExecute(false); } - Result TrackSetBrakeSpeedAction::Execute() const + Result TrackSetBrakeSpeedAction::Execute(GameState_t& gameState) const { return QueryExecute(true); } diff --git a/src/openrct2/actions/TrackSetBrakeSpeedAction.h b/src/openrct2/actions/TrackSetBrakeSpeedAction.h index 473523e981..05740afe0f 100644 --- a/src/openrct2/actions/TrackSetBrakeSpeedAction.h +++ b/src/openrct2/actions/TrackSetBrakeSpeedAction.h @@ -29,8 +29,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const final; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: Result QueryExecute(bool isExecuting) const; diff --git a/src/openrct2/actions/WallPlaceAction.cpp b/src/openrct2/actions/WallPlaceAction.cpp index 681373b398..68ebf70c47 100644 --- a/src/openrct2/actions/WallPlaceAction.cpp +++ b/src/openrct2/actions/WallPlaceAction.cpp @@ -71,7 +71,7 @@ namespace OpenRCT2::GameActions << DS_TAG(_tertiaryColour); } - Result WallPlaceAction::Query() const + Result WallPlaceAction::Query(GameState_t& gameState) const { auto res = Result(); res.ErrorTitle = STR_CANT_BUILD_THIS_HERE; @@ -91,7 +91,6 @@ namespace OpenRCT2::GameActions return Result(Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_OFF_EDGE_OF_MAP); } - auto& gameState = getGameState(); auto mapSizeMax = GetMapSizeMaxXY(); if (gLegacyScene != LegacyScene::scenarioEditor && !(GetFlags() & GAME_COMMAND_FLAG_TRACK_DESIGN) && !gameState.cheats.sandboxMode) @@ -274,11 +273,9 @@ namespace OpenRCT2::GameActions return res; } - Result WallPlaceAction::Execute() const + Result WallPlaceAction::Execute(GameState_t& gameState) const { auto res = Result(); - auto& gameState = getGameState(); - res.ErrorTitle = STR_CANT_BUILD_THIS_HERE; res.Position = _loc; diff --git a/src/openrct2/actions/WallPlaceAction.h b/src/openrct2/actions/WallPlaceAction.h index 308cb76e07..94f9f031d0 100644 --- a/src/openrct2/actions/WallPlaceAction.h +++ b/src/openrct2/actions/WallPlaceAction.h @@ -49,8 +49,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const final; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: /** diff --git a/src/openrct2/actions/WallRemoveAction.cpp b/src/openrct2/actions/WallRemoveAction.cpp index b5c929dd5d..77686514ee 100644 --- a/src/openrct2/actions/WallRemoveAction.cpp +++ b/src/openrct2/actions/WallRemoveAction.cpp @@ -39,7 +39,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc); } - Result WallRemoveAction::Query() const + Result WallRemoveAction::Query(GameState_t& gameState) const { Result res = Result(); res.Cost = 0; @@ -67,7 +67,7 @@ namespace OpenRCT2::GameActions return res; } - Result WallRemoveAction::Execute() const + Result WallRemoveAction::Execute(GameState_t& gameState) const { Result res = Result(); res.Cost = 0; diff --git a/src/openrct2/actions/WallRemoveAction.h b/src/openrct2/actions/WallRemoveAction.h index e101e114db..51fa65c13b 100644 --- a/src/openrct2/actions/WallRemoveAction.h +++ b/src/openrct2/actions/WallRemoveAction.h @@ -24,8 +24,8 @@ namespace OpenRCT2::GameActions void AcceptParameters(GameActionParameterVisitor&) final; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: TileElement* GetFirstWallElementAt(const CoordsXYZD& location, bool isGhost) const; diff --git a/src/openrct2/actions/WallSetColourAction.cpp b/src/openrct2/actions/WallSetColourAction.cpp index 43ffcf21f4..216177082d 100644 --- a/src/openrct2/actions/WallSetColourAction.cpp +++ b/src/openrct2/actions/WallSetColourAction.cpp @@ -52,7 +52,7 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_loc) << DS_TAG(_primaryColour) << DS_TAG(_secondaryColour) << DS_TAG(_tertiaryColour); } - Result WallSetColourAction::Query() const + Result WallSetColourAction::Query(GameState_t& gameState) const { auto res = Result(); res.ErrorTitle = STR_CANT_REPAINT_THIS; @@ -116,7 +116,7 @@ namespace OpenRCT2::GameActions return res; } - Result WallSetColourAction::Execute() const + Result WallSetColourAction::Execute(GameState_t& gameState) const { auto res = Result(); res.ErrorTitle = STR_CANT_REPAINT_THIS; diff --git a/src/openrct2/actions/WallSetColourAction.h b/src/openrct2/actions/WallSetColourAction.h index e7750616f6..8aceb414be 100644 --- a/src/openrct2/actions/WallSetColourAction.h +++ b/src/openrct2/actions/WallSetColourAction.h @@ -30,7 +30,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/WaterLowerAction.cpp b/src/openrct2/actions/WaterLowerAction.cpp index a267ae0c0e..1fd96a93c8 100644 --- a/src/openrct2/actions/WaterLowerAction.cpp +++ b/src/openrct2/actions/WaterLowerAction.cpp @@ -41,17 +41,17 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_range); } - Result WaterLowerAction::Query() const + Result WaterLowerAction::Query(GameState_t& gameState) const { - return QueryExecute(false); + return QueryExecute(gameState, false); } - Result WaterLowerAction::Execute() const + Result WaterLowerAction::Execute(GameState_t& gameState) const { - return QueryExecute(true); + return QueryExecute(gameState, true); } - Result WaterLowerAction::QueryExecute(bool isExecuting) const + Result WaterLowerAction::QueryExecute(GameState_t& gameState, bool isExecuting) const { auto res = Result(); @@ -67,7 +67,7 @@ namespace OpenRCT2::GameActions res.Position.z = z; res.Expenditure = ExpenditureType::landscaping; - uint8_t minHeight = GetLowestHeight(validRange); + uint8_t minHeight = GetLowestHeight(gameState, validRange); bool hasChanged = false; bool withinOwnership = false; for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) @@ -100,7 +100,8 @@ namespace OpenRCT2::GameActions height -= 2; auto waterSetHeightAction = WaterSetHeightAction({ x, y }, height); waterSetHeightAction.SetFlags(GetFlags()); - auto result = isExecuting ? ExecuteNested(&waterSetHeightAction) : QueryNested(&waterSetHeightAction); + auto result = isExecuting ? ExecuteNested(&waterSetHeightAction, gameState) + : QueryNested(&waterSetHeightAction, gameState); if (result.Error == Status::Ok) { res.Cost += result.Cost; @@ -130,7 +131,7 @@ namespace OpenRCT2::GameActions return res; } - uint8_t WaterLowerAction::GetLowestHeight(const MapRange& validRange) const + uint8_t WaterLowerAction::GetLowestHeight(const GameState_t& gameState, const MapRange& validRange) const { // The lowest height to lower the water to is the highest water level in the selection uint8_t minHeight{ 0 }; diff --git a/src/openrct2/actions/WaterLowerAction.h b/src/openrct2/actions/WaterLowerAction.h index a0aba9c33f..2dcafd1529 100644 --- a/src/openrct2/actions/WaterLowerAction.h +++ b/src/openrct2/actions/WaterLowerAction.h @@ -27,11 +27,11 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: - Result QueryExecute(bool isExecuting) const; - uint8_t GetLowestHeight(const MapRange& validRange) const; + Result QueryExecute(GameState_t& gameState, bool isExecuting) const; + uint8_t GetLowestHeight(const GameState_t& gameState, const MapRange& validRange) const; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/WaterRaiseAction.cpp b/src/openrct2/actions/WaterRaiseAction.cpp index 9ffafe6eac..489850e8d9 100644 --- a/src/openrct2/actions/WaterRaiseAction.cpp +++ b/src/openrct2/actions/WaterRaiseAction.cpp @@ -41,17 +41,17 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_range); } - Result WaterRaiseAction::Query() const + Result WaterRaiseAction::Query(GameState_t& gameState) const { - return QueryExecute(false); + return QueryExecute(gameState, false); } - Result WaterRaiseAction::Execute() const + Result WaterRaiseAction::Execute(GameState_t& gameState) const { - return QueryExecute(true); + return QueryExecute(gameState, true); } - Result WaterRaiseAction::QueryExecute(bool isExecuting) const + Result WaterRaiseAction::QueryExecute(GameState_t& gameState, bool isExecuting) const { auto res = Result(); @@ -67,7 +67,7 @@ namespace OpenRCT2::GameActions res.Position.z = z; res.Expenditure = ExpenditureType::landscaping; - auto maxHeight = GetHighestHeight(validRange) / kCoordsZStep; + auto maxHeight = GetHighestHeight(gameState, validRange) / kCoordsZStep; bool hasChanged = false; bool withinOwnership = false; for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) @@ -114,7 +114,8 @@ namespace OpenRCT2::GameActions } auto waterSetHeightAction = WaterSetHeightAction({ x, y }, height); waterSetHeightAction.SetFlags(GetFlags()); - auto result = isExecuting ? ExecuteNested(&waterSetHeightAction) : QueryNested(&waterSetHeightAction); + auto result = isExecuting ? ExecuteNested(&waterSetHeightAction, gameState) + : QueryNested(&waterSetHeightAction, gameState); if (result.Error == Status::Ok) { res.Cost += result.Cost; @@ -143,7 +144,7 @@ namespace OpenRCT2::GameActions return res; } - uint16_t WaterRaiseAction::GetHighestHeight(const MapRange& validRange) const + uint16_t WaterRaiseAction::GetHighestHeight(const GameState_t& gameState, const MapRange& validRange) const { // The highest height to raise the water to is the lowest water level in the selection uint16_t maxHeight = 255 * kCoordsZStep; diff --git a/src/openrct2/actions/WaterRaiseAction.h b/src/openrct2/actions/WaterRaiseAction.h index c8f1a2d20d..3e2313e9f2 100644 --- a/src/openrct2/actions/WaterRaiseAction.h +++ b/src/openrct2/actions/WaterRaiseAction.h @@ -27,11 +27,11 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: - Result QueryExecute(bool isExecuting) const; - uint16_t GetHighestHeight(const MapRange& validRange) const; + Result QueryExecute(GameState_t& gameState, bool isExecuting) const; + uint16_t GetHighestHeight(const GameState_t& gameState, const MapRange& validRange) const; }; } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/WaterSetHeightAction.cpp b/src/openrct2/actions/WaterSetHeightAction.cpp index 9e564c25e0..f894b97db8 100644 --- a/src/openrct2/actions/WaterSetHeightAction.cpp +++ b/src/openrct2/actions/WaterSetHeightAction.cpp @@ -46,13 +46,12 @@ namespace OpenRCT2::GameActions stream << DS_TAG(_coords) << DS_TAG(_height); } - Result WaterSetHeightAction::Query() const + Result WaterSetHeightAction::Query(GameState_t& gameState) const { auto res = Result(); res.Expenditure = ExpenditureType::landscaping; res.Position = { _coords, _height * kCoordsZStep }; - auto& gameState = getGameState(); if (gLegacyScene != LegacyScene::scenarioEditor && !gameState.cheats.sandboxMode && gameState.park.flags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES) { @@ -112,7 +111,7 @@ namespace OpenRCT2::GameActions return res; } - Result WaterSetHeightAction::Execute() const + Result WaterSetHeightAction::Execute(GameState_t& gameState) const { auto res = Result(); res.Expenditure = ExpenditureType::landscaping; diff --git a/src/openrct2/actions/WaterSetHeightAction.h b/src/openrct2/actions/WaterSetHeightAction.h index 917ef28d43..243f0fe363 100644 --- a/src/openrct2/actions/WaterSetHeightAction.h +++ b/src/openrct2/actions/WaterSetHeightAction.h @@ -28,8 +28,8 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; - Result Query() const override; - Result Execute() const override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; private: StringId CheckParameters() const; diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index f77dbff8ca..f0a0a2e22f 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -318,7 +318,7 @@ static void ConsoleCommandRides(InteractiveConsole& console, const arguments_t& { auto rideAction = GameActions::RideFreezeRatingAction( rideIndex, GameActions::RideRatingType::Excitement, excitement); - GameActions::Execute(&rideAction); + GameActions::Execute(&rideAction, gameState); } } } @@ -352,7 +352,7 @@ static void ConsoleCommandRides(InteractiveConsole& console, const arguments_t& { auto rideAction = GameActions::RideFreezeRatingAction( rideIndex, GameActions::RideRatingType::Intensity, intensity); - GameActions::Execute(&rideAction); + GameActions::Execute(&rideAction, gameState); } } } @@ -386,7 +386,7 @@ static void ConsoleCommandRides(InteractiveConsole& console, const arguments_t& { auto rideAction = GameActions::RideFreezeRatingAction( rideIndex, GameActions::RideRatingType::Nausea, nausea); - GameActions::Execute(&rideAction); + GameActions::Execute(&rideAction, gameState); } } } @@ -404,7 +404,7 @@ static void ConsoleCommandRides(InteractiveConsole& console, const arguments_t& for (const auto& ride : GetRideManager()) { auto rideSetPrice = GameActions::RideSetPriceAction(ride.id, price, true); - GameActions::Execute(&rideSetPrice); + GameActions::Execute(&rideSetPrice, gameState); } } else @@ -424,7 +424,7 @@ static void ConsoleCommandRides(InteractiveConsole& console, const arguments_t& if (ride.type == rideType) { auto rideSetPrice = GameActions::RideSetPriceAction(ride.id, price, true); - GameActions::Execute(&rideSetPrice); + GameActions::Execute(&rideSetPrice, gameState); } } } @@ -446,7 +446,7 @@ static void ConsoleCommandRides(InteractiveConsole& console, const arguments_t& else { auto rideSetPrice = GameActions::RideSetPriceAction(RideId::FromUnderlying(rideId), price, true); - GameActions::Execute(&rideSetPrice); + GameActions::Execute(&rideSetPrice, gameState); } } } @@ -539,7 +539,7 @@ static void ConsoleCommandStaff(InteractiveConsole& console, const arguments_t& auto costume = static_cast(int_val[1]); auto staffSetCostumeAction = GameActions::StaffSetCostumeAction(EntityId::FromUnderlying(int_val[0]), costume); - GameActions::Execute(&staffSetCostumeAction); + GameActions::Execute(&staffSetCostumeAction, gameState); } } } @@ -761,7 +761,9 @@ static void ConsoleSetVariableAction(InteractiveConsole& console, std::string va console.EndAsyncExecution(); }); console.BeginAsyncExecution(); - GameActions::Execute(&action); + + auto& gameState = getGameState(); + GameActions::Execute(&action, gameState); } static void ConsoleCommandSet(InteractiveConsole& console, const arguments_t& argv) @@ -1307,7 +1309,7 @@ static void ConsoleCommandForceDate([[maybe_unused]] InteractiveConsole& console } auto setDateAction = GameActions::ParkSetDateAction(year - 1, month - 1, day - 1); - GameActions::Execute(&setDateAction); + GameActions::Execute(&setDateAction, getGameState()); auto* windowMgr = Ui::GetWindowManager(); windowMgr->InvalidateByClass(WindowClass::BottomToolbar); diff --git a/src/openrct2/management/Research.cpp b/src/openrct2/management/Research.cpp index 7a858ab23d..1c09dc8740 100644 --- a/src/openrct2/management/Research.cpp +++ b/src/openrct2/management/Research.cpp @@ -139,9 +139,10 @@ static void ResearchMarkAsFullyCompleted() gameState.researchProgress = 0; gameState.researchProgressStage = RESEARCH_STAGE_FINISHED_ALL; ResearchInvalidateRelatedWindows(); + // Reset funding to 0 if no more rides. auto gameAction = GameActions::ParkSetResearchFundingAction(gameState.researchPriorities, 0); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, gameState); } /** diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index c35cf8d396..0f8684fdcc 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -2075,7 +2075,7 @@ namespace OpenRCT2::Network pickup_peep->Id, { GetPickupPeepOldX(connection_player->Id), 0, 0 }, GetCurrentPlayerId() }; - auto res = GameActions::Execute(&pickupAction); + auto res = GameActions::Execute(&pickupAction, getGameState()); } ServerSendEventPlayerDisconnected( const_cast(connection_player->Name.c_str()), connection->GetLastDisconnectReason()); @@ -2840,7 +2840,7 @@ namespace OpenRCT2::Network // Something went wrong, game is not loaded. Return to main screen. auto loadOrQuitAction = GameActions::LoadOrQuitAction( GameActions::LoadOrQuitModes::OpenSavePrompt, PromptMode::saveBeforeQuit); - GameActions::Execute(&loadOrQuitAction); + GameActions::Execute(&loadOrQuitAction, getGameState()); } if (has_to_free) { diff --git a/src/openrct2/rct12/ScenarioPatcher.cpp b/src/openrct2/rct12/ScenarioPatcher.cpp index a4eaa1603b..519095a30c 100644 --- a/src/openrct2/rct12/ScenarioPatcher.cpp +++ b/src/openrct2/rct12/ScenarioPatcher.cpp @@ -658,7 +658,8 @@ static void ApplyPathFixes(const json_t& scenarioPatch) auto slope = direction != kInvalidDirection ? direction + 4 : 0; auto footpathPlaceAction = GameActions::FootpathPlaceAction( coordinate.ToCoordsXYZ(), slope, surfaceObjIndex, railingsObjIndex, direction, constructionFlags); - auto result = footpathPlaceAction.Execute(); + auto& gameState = getGameState(); + auto result = footpathPlaceAction.Execute(gameState); if (result.Error != GameActions::Status::Ok) { Guard::Assert(0, "Could not patch path"); diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 70e8acb34f..78da4f39d7 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1130,13 +1130,13 @@ void Ride::update() { // We require this to execute right away during the simulation, always ignore network and queue. auto gameAction = GameActions::RideSetStatusAction(id, RideStatus::closed); - GameActions::ExecuteNested(&gameAction); + GameActions::ExecuteNested(&gameAction, getGameState()); } else { // We require this to execute right away during the simulation, always ignore network and queue. auto gameAction = GameActions::RideSetStatusAction(id, RideStatus::simulating); - GameActions::ExecuteNested(&gameAction); + GameActions::ExecuteNested(&gameAction, getGameState()); } } } @@ -5226,27 +5226,27 @@ void Ride::setRideEntry(ObjectEntryIndex entryIndex) auto colour = RideGetUnusedPresetVehicleColour(entryIndex); auto rideSetVehicleAction = GameActions::RideSetVehicleAction( id, GameActions::RideSetVehicleType::RideEntry, entryIndex, colour); - GameActions::Execute(&rideSetVehicleAction); + GameActions::Execute(&rideSetVehicleAction, getGameState()); } void Ride::setNumTrains(int32_t newNumTrains) { auto rideSetVehicleAction = GameActions::RideSetVehicleAction(id, GameActions::RideSetVehicleType::NumTrains, newNumTrains); - GameActions::Execute(&rideSetVehicleAction); + GameActions::Execute(&rideSetVehicleAction, getGameState()); } void Ride::setNumCarsPerTrain(int32_t numCarsPerVehicle) { auto rideSetVehicleAction = GameActions::RideSetVehicleAction( id, GameActions::RideSetVehicleType::NumCarsPerTrain, numCarsPerVehicle); - GameActions::Execute(&rideSetVehicleAction); + GameActions::Execute(&rideSetVehicleAction, getGameState()); } void Ride::setReversedTrains(bool reverseTrains) { auto rideSetVehicleAction = GameActions::RideSetVehicleAction( id, GameActions::RideSetVehicleType::TrainsReversed, reverseTrains); - GameActions::Execute(&rideSetVehicleAction); + GameActions::Execute(&rideSetVehicleAction, getGameState()); } void Ride::setToDefaultInspectionInterval() diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index b0ff6a221a..067b73305a 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -909,7 +909,7 @@ static bool ride_modify_entrance_or_exit(const CoordsXYE& tileElement) ToolSet(*constructionWindow, newToolWidgetIndex, Tool::crosshair); }); - GameActions::Execute(&rideEntranceExitRemove); + GameActions::Execute(&rideEntranceExitRemove, getGameState()); } windowMgr->InvalidateByClass(WindowClass::RideConstruction); @@ -978,7 +978,7 @@ bool RideModify(const CoordsXYE& input) if (ride->status != RideStatus::simulating) { auto gameAction = GameActions::RideSetStatusAction(ride->id, RideStatus::closed); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } // Check if element is a station entrance or exit @@ -1128,7 +1128,7 @@ money64 RideGetRefundPrice(const Ride& ride) { trackElement.x, trackElement.y, trackElement.element->GetBaseZ(), direction }); trackRemoveAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); - auto res = GameActions::Query(&trackRemoveAction); + auto res = GameActions::Query(&trackRemoveAction, getGameState()); cost += res.Cost; @@ -1156,7 +1156,7 @@ money64 RideGetRefundPrice(const Ride& ride) money64 SetOperatingSetting(RideId rideId, GameActions::RideSetSetting setting, uint8_t value) { auto rideSetSetting = GameActions::RideSetSettingAction(rideId, setting, value); - auto res = GameActions::Execute(&rideSetSetting); + auto res = GameActions::Execute(&rideSetSetting, getGameState()); return res.Error == GameActions::Status::Ok ? 0 : kMoney64Undefined; } @@ -1164,8 +1164,10 @@ money64 SetOperatingSettingNested(RideId rideId, GameActions::RideSetSetting set { auto rideSetSetting = GameActions::RideSetSettingAction(rideId, setting, value); rideSetSetting.SetFlags(flags); - auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&rideSetSetting) - : GameActions::QueryNested(&rideSetSetting); + + auto& gameState = getGameState(); + auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&rideSetSetting, gameState) + : GameActions::QueryNested(&rideSetSetting, gameState); return res.Error == GameActions::Status::Ok ? 0 : kMoney64Undefined; } diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 8a993ebb42..c3e69bc36e 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -991,7 +991,7 @@ static GameActions::Result TrackDesignPlaceSceneryElementRemoveGhost( } ga->SetFlags(flags); - return GameActions::ExecuteNested(ga.get()); + return GameActions::ExecuteNested(ga.get(), getGameState()); } static bool TrackDesignPlaceSceneryElementGetPlaceZ(TrackDesignState& tds, const TrackDesignSceneryElement& scenery) @@ -1045,6 +1045,8 @@ static GameActions::Result TrackDesignPlaceSceneryElement( int16_t z; uint8_t flags; + auto& gameState = getGameState(); + switch (entryInfo->Type) { case ObjectType::smallScenery: @@ -1084,8 +1086,8 @@ static GameActions::Result TrackDesignPlaceSceneryElement( scenery.secondaryColour, scenery.tertiaryColour); smallSceneryPlace.SetFlags(flags); - auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&smallSceneryPlace) - : GameActions::QueryNested(&smallSceneryPlace); + auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&smallSceneryPlace, gameState) + : GameActions::QueryNested(&smallSceneryPlace, gameState); cost = res.Error == GameActions::Status::Ok ? res.Cost : 0; break; @@ -1125,8 +1127,8 @@ static GameActions::Result TrackDesignPlaceSceneryElement( { mapCoord.x, mapCoord.y, z, rotation }, entryInfo->Index, scenery.primaryColour, scenery.secondaryColour, scenery.tertiaryColour); sceneryPlaceAction.SetFlags(flags); - auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&sceneryPlaceAction) - : GameActions::QueryNested(&sceneryPlaceAction); + auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&sceneryPlaceAction, gameState) + : GameActions::QueryNested(&sceneryPlaceAction, gameState); cost = res.Cost; break; @@ -1165,8 +1167,8 @@ static GameActions::Result TrackDesignPlaceSceneryElement( entryInfo->Index, { mapCoord.x, mapCoord.y, z }, rotation, scenery.primaryColour, scenery.secondaryColour, scenery.tertiaryColour); wallPlaceAction.SetFlags(flags); - auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&wallPlaceAction) - : GameActions::QueryNested(&wallPlaceAction); + auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&wallPlaceAction, gameState) + : GameActions::QueryNested(&wallPlaceAction, gameState); cost = res.Cost; break; @@ -1206,8 +1208,8 @@ static GameActions::Result TrackDesignPlaceSceneryElement( auto footpathPlaceAction = GameActions::FootpathLayoutPlaceAction( { mapCoord.x, mapCoord.y, z }, slope, entryInfo->Index, entryInfo->SecondaryIndex, edges, constructFlags); footpathPlaceAction.SetFlags(flags); - auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&footpathPlaceAction) - : GameActions::QueryNested(&footpathPlaceAction); + auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&footpathPlaceAction, gameState) + : GameActions::QueryNested(&footpathPlaceAction, gameState); // Ignore failures cost = res.Error == GameActions::Status::Ok ? res.Cost : 0; } @@ -1324,6 +1326,8 @@ static std::optional TrackDesignPlaceEntrances( TrackDesignUpdatePreviewBounds(tds, newCoords); + auto& gameState = getGameState(); + switch (tds.placeOperation) { case TrackPlaceOperation::drawOutlines: @@ -1383,8 +1387,9 @@ static std::optional TrackDesignPlaceEntrances( auto rideEntranceExitPlaceAction = GameActions::RideEntranceExitPlaceAction( newCoords, rotation, rideId, stationIndex, entrance.isExit); rideEntranceExitPlaceAction.SetFlags(flags); - auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&rideEntranceExitPlaceAction) - : GameActions::QueryNested(&rideEntranceExitPlaceAction); + auto res = flags & GAME_COMMAND_FLAG_APPLY + ? GameActions::ExecuteNested(&rideEntranceExitPlaceAction, gameState) + : GameActions::QueryNested(&rideEntranceExitPlaceAction, gameState); if (res.Error != GameActions::Status::Ok) { @@ -1432,6 +1437,8 @@ static GameActions::Result TrackDesignPlaceMaze( tds.placeZ = 0; money64 totalCost = 0; + auto& gameState = getGameState(); + for (const auto& maze_element : td.mazeElements) { uint8_t rotation = _currentTrackPieceDirection & 3; @@ -1479,8 +1486,8 @@ static GameActions::Result TrackDesignPlaceMaze( auto mazePlace = GameActions::MazePlaceTrackAction({ mapCoord, origin.z }, ride.id, mazeEntry); mazePlace.SetFlags(flags); - auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&mazePlace) - : GameActions::QueryNested(&mazePlace); + auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&mazePlace, gameState) + : GameActions::QueryNested(&mazePlace, gameState); if (res.Error != GameActions::Status::Ok) { return res; @@ -1536,7 +1543,7 @@ static GameActions::Result TrackDesignPlaceMaze( { auto gameAction = GameActions::RideDemolishAction(ride.id, GameActions::RideModifyType::demolish); gameAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); - GameActions::Execute(&gameAction); + GameActions::Execute(&gameAction, getGameState()); } auto res = GameActions::Result(); @@ -1560,6 +1567,8 @@ static GameActions::Result TrackDesignPlaceRide( money64 totalCost = 0; uint8_t rotation = _currentTrackPieceDirection; + auto& gameState = getGameState(); + // Track elements auto newCoords = origin; for (const auto& track : td.trackElements) @@ -1589,7 +1598,7 @@ static GameActions::Result TrackDesignPlaceRide( trackRemoveAction.SetFlags( GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_TRACK_DESIGN); - GameActions::ExecuteNested(&trackRemoveAction); + GameActions::ExecuteNested(&trackRemoveAction, gameState); break; } case TrackPlaceOperation::placeQuery: @@ -1638,8 +1647,8 @@ static GameActions::Result TrackDesignPlaceRide( track.brakeBoosterSpeed, track.colourScheme, track.seatRotation, liftHillAndAlternativeState, true); trackPlaceAction.SetFlags(flags); - auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&trackPlaceAction) - : GameActions::QueryNested(&trackPlaceAction); + auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&trackPlaceAction, gameState) + : GameActions::QueryNested(&trackPlaceAction, gameState); if (res.Error != GameActions::Status::Ok) { return res; @@ -1856,7 +1865,9 @@ static money64 TrackDesignCreateRide(int32_t type, int32_t subType, int32_t flag auto gameAction = GameActions::RideCreateAction(type, subType, 0, 0, getGameState().lastEntranceStyle); gameAction.SetFlags(flags); - auto res = GameActions::ExecuteNested(&gameAction); + auto& gameState = getGameState(); + + auto res = GameActions::ExecuteNested(&gameAction, gameState); // Callee's of this function expect kMoney64Undefined in case of failure. if (res.Error != GameActions::Status::Ok) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 39f49db74d..7f5e4d459d 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -2866,7 +2866,7 @@ void Vehicle::UpdateCollisionSetup() { // We require this to execute right away during the simulation, always ignore network and queue. auto gameAction = GameActions::RideSetStatusAction(curRide->id, RideStatus::closed); - GameActions::ExecuteNested(&gameAction); + GameActions::ExecuteNested(&gameAction, getGameState()); } } @@ -4660,7 +4660,7 @@ void Vehicle::CrashOnLand() { // We require this to execute right away during the simulation, always ignore network and queue. auto gameAction = GameActions::RideSetStatusAction(curRide->id, RideStatus::closed); - GameActions::ExecuteNested(&gameAction); + GameActions::ExecuteNested(&gameAction, getGameState()); } } curRide->lifecycleFlags |= RIDE_LIFECYCLE_CRASHED; @@ -4728,7 +4728,7 @@ void Vehicle::CrashOnWater() { // We require this to execute right away during the simulation, always ignore network and queue. auto gameAction = GameActions::RideSetStatusAction(curRide->id, RideStatus::closed); - GameActions::ExecuteNested(&gameAction); + GameActions::ExecuteNested(&gameAction, getGameState()); } } curRide->lifecycleFlags |= RIDE_LIFECYCLE_CRASHED; diff --git a/src/openrct2/scripting/bindings/game/ScContext.hpp b/src/openrct2/scripting/bindings/game/ScContext.hpp index 4fab734849..59625fe7e6 100644 --- a/src/openrct2/scripting/bindings/game/ScContext.hpp +++ b/src/openrct2/scripting/bindings/game/ScContext.hpp @@ -338,11 +338,11 @@ namespace OpenRCT2::Scripting callback](const GameActions::GameAction* act, const GameActions::Result* res) -> void { HandleGameActionResult(plugin, *act, *res, callback); }); - GameActions::Execute(action.get()); + GameActions::Execute(action.get(), getGameState()); } else { - auto res = GameActions::Query(action.get()); + auto res = GameActions::Query(action.get(), getGameState()); HandleGameActionResult(plugin, *action, res, callback); } } diff --git a/src/openrct2/scripting/bindings/network/ScNetwork.cpp b/src/openrct2/scripting/bindings/network/ScNetwork.cpp index 3b70579583..604c7d50e7 100644 --- a/src/openrct2/scripting/bindings/network/ScNetwork.cpp +++ b/src/openrct2/scripting/bindings/network/ScNetwork.cpp @@ -12,6 +12,7 @@ #include "ScNetwork.hpp" #include "../../../Context.h" + #include "../../../GameState.h" #include "../../../actions/NetworkModifyGroupAction.h" #include "../../../actions/PlayerKickAction.h" #include "../../../network/Network.h" @@ -71,7 +72,7 @@ namespace OpenRCT2::Scripting { #ifndef DISABLE_NETWORK auto action = GameActions::NetworkModifyGroupAction(GameActions::ModifyGroupType::SetDefault, value); - GameActions::Execute(&action); + GameActions::Execute(&action, getGameState()); #endif } @@ -201,7 +202,7 @@ namespace OpenRCT2::Scripting { #ifndef DISABLE_NETWORK auto networkModifyGroup = GameActions::NetworkModifyGroupAction(GameActions::ModifyGroupType::AddGroup); - GameActions::Execute(&networkModifyGroup); + GameActions::Execute(&networkModifyGroup, getGameState()); #endif } @@ -216,7 +217,7 @@ namespace OpenRCT2::Scripting { auto groupId = Network::GetGroupID(index); auto networkAction = GameActions::NetworkModifyGroupAction(GameActions::ModifyGroupType::RemoveGroup, groupId); - GameActions::Execute(&networkAction); + GameActions::Execute(&networkAction, getGameState()); } } else @@ -225,7 +226,7 @@ namespace OpenRCT2::Scripting if (index != -1) { auto networkAction = GameActions::NetworkModifyGroupAction(GameActions::ModifyGroupType::RemoveGroup, id); - GameActions::Execute(&networkAction); + GameActions::Execute(&networkAction, getGameState()); } } #endif @@ -242,7 +243,7 @@ namespace OpenRCT2::Scripting { auto playerId = Network::GetPlayerID(index); auto kickPlayerAction = GameActions::PlayerKickAction(playerId); - GameActions::Execute(&kickPlayerAction); + GameActions::Execute(&kickPlayerAction, getGameState()); } } else @@ -251,7 +252,7 @@ namespace OpenRCT2::Scripting if (index != -1) { auto kickPlayerAction = GameActions::PlayerKickAction(id); - GameActions::Execute(&kickPlayerAction); + GameActions::Execute(&kickPlayerAction, getGameState()); } } #endif diff --git a/src/openrct2/scripting/bindings/network/ScPlayer.cpp b/src/openrct2/scripting/bindings/network/ScPlayer.cpp index 017a721755..966f368e90 100644 --- a/src/openrct2/scripting/bindings/network/ScPlayer.cpp +++ b/src/openrct2/scripting/bindings/network/ScPlayer.cpp @@ -12,6 +12,7 @@ #include "ScPlayer.hpp" #include "../../../Context.h" + #include "../../../GameState.h" #include "../../../actions/PlayerSetGroupAction.h" #include "../../../network/Network.h" #include "../../../network/NetworkAction.h" @@ -55,7 +56,7 @@ namespace OpenRCT2::Scripting { #ifndef DISABLE_NETWORK auto playerSetGroupAction = GameActions::PlayerSetGroupAction(_id, value); - GameActions::Execute(&playerSetGroupAction); + GameActions::Execute(&playerSetGroupAction, getGameState()); #endif } diff --git a/src/openrct2/scripting/bindings/network/ScPlayerGroup.cpp b/src/openrct2/scripting/bindings/network/ScPlayerGroup.cpp index 1c5f5c021d..a9d259c9de 100644 --- a/src/openrct2/scripting/bindings/network/ScPlayerGroup.cpp +++ b/src/openrct2/scripting/bindings/network/ScPlayerGroup.cpp @@ -12,6 +12,7 @@ #include "ScPlayerGroup.hpp" #include "../../../Context.h" + #include "../../../GameState.h" #include "../../../actions/NetworkModifyGroupAction.h" #include "../../../actions/PlayerSetGroupAction.h" #include "../../../core/String.hpp" @@ -47,7 +48,7 @@ namespace OpenRCT2::Scripting { #ifndef DISABLE_NETWORK auto action = GameActions::NetworkModifyGroupAction(GameActions::ModifyGroupType::SetName, _id, value); - GameActions::Execute(&action); + GameActions::Execute(&action, getGameState()); #endif } @@ -102,7 +103,7 @@ namespace OpenRCT2::Scripting // First clear all permissions auto networkAction = GameActions::NetworkModifyGroupAction( GameActions::ModifyGroupType::SetPermissions, _id, "", 0, GameActions::PermissionState::ClearAll); - GameActions::Execute(&networkAction); + GameActions::Execute(&networkAction, getGameState()); std::vector enabledPermissions; enabledPermissions.resize(Network::NetworkActions::Actions.size()); @@ -130,7 +131,7 @@ namespace OpenRCT2::Scripting auto networkAction2 = GameActions::NetworkModifyGroupAction( GameActions::ModifyGroupType::SetPermissions, _id, "", static_cast(i), GameActions::PermissionState::Toggle); - GameActions::Execute(&networkAction2); + GameActions::Execute(&networkAction2, getGameState()); } } #endif diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index 60eb236d0b..89b72bfd30 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -47,7 +47,7 @@ static money64 RideEntranceExitPlaceGhost( auto rideEntranceExitPlaceAction = GameActions::RideEntranceExitPlaceAction( entranceExitCoords, direction, rideIndex, stationNum, placeType == ENTRANCE_TYPE_RIDE_EXIT); rideEntranceExitPlaceAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_GHOST); - auto res = GameActions::Execute(&rideEntranceExitPlaceAction); + auto res = GameActions::Execute(&rideEntranceExitPlaceAction, getGameState()); return res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined; } @@ -63,7 +63,7 @@ void ParkEntranceRemoveGhost() gParkEntranceGhostExists = false; auto parkEntranceRemoveAction = GameActions::ParkEntranceRemoveAction(gParkEntranceGhostPosition); parkEntranceRemoveAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); - GameActions::Execute(&parkEntranceRemoveAction); + GameActions::Execute(&parkEntranceRemoveAction, getGameState()); } } @@ -105,7 +105,7 @@ void RideEntranceExitRemoveGhost() gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT); rideEntranceExitRemove.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); - GameActions::Execute(&rideEntranceExitRemove); + GameActions::Execute(&rideEntranceExitRemove, getGameState()); } } diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 67e54f7e75..4eacd6410e 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -1016,7 +1016,7 @@ static void FootpathFixOwnership(const CoordsXY& mapPos) auto landSetRightsAction = GameActions::LandSetRightsAction( mapPos, GameActions::LandSetRightSetting::SetOwnershipWithChecks, ownership); landSetRightsAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND); - GameActions::Execute(&landSetRightsAction); + GameActions::Execute(&landSetRightsAction, getGameState()); } static bool GetNextDirection(uint32_t edges, int32_t* direction) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index ee1cddf401..91c0aac647 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1408,6 +1408,8 @@ static void MapExtendBoundarySurfaceShiftY(const int32_t amount, const int32_t m */ void ClearElementAt(const CoordsXY& loc, TileElement** elementPtr) { + auto& gameState = getGameState(); + TileElement* element = *elementPtr; switch (element->GetType()) { @@ -1440,7 +1442,7 @@ void ClearElementAt(const CoordsXY& loc, TileElement** elementPtr) break; } auto parkEntranceRemoveAction = GameActions::ParkEntranceRemoveAction(CoordsXYZ{ seqLoc, element->GetBaseZ() }); - auto result = GameActions::ExecuteNested(&parkEntranceRemoveAction); + auto result = GameActions::ExecuteNested(&parkEntranceRemoveAction, gameState); // If asking nicely did not work, forcibly remove this to avoid an infinite loop. if (result.Error != GameActions::Status::Ok) { @@ -1452,7 +1454,7 @@ void ClearElementAt(const CoordsXY& loc, TileElement** elementPtr) { CoordsXYZD wallLocation = { loc.x, loc.y, element->GetBaseZ(), element->GetDirection() }; auto wallRemoveAction = GameActions::WallRemoveAction(wallLocation); - auto result = GameActions::ExecuteNested(&wallRemoveAction); + auto result = GameActions::ExecuteNested(&wallRemoveAction, gameState); // If asking nicely did not work, forcibly remove this to avoid an infinite loop. if (result.Error != GameActions::Status::Ok) { @@ -1464,7 +1466,7 @@ void ClearElementAt(const CoordsXY& loc, TileElement** elementPtr) { auto removeSceneryAction = GameActions::LargeSceneryRemoveAction( { loc.x, loc.y, element->GetBaseZ(), element->GetDirection() }, element->AsLargeScenery()->GetSequenceIndex()); - auto result = GameActions::ExecuteNested(&removeSceneryAction); + auto result = GameActions::ExecuteNested(&removeSceneryAction, gameState); // If asking nicely did not work, forcibly remove this to avoid an infinite loop. if (result.Error != GameActions::Status::Ok) { @@ -1476,7 +1478,7 @@ void ClearElementAt(const CoordsXY& loc, TileElement** elementPtr) { auto bannerRemoveAction = GameActions::BannerRemoveAction( { loc.x, loc.y, element->GetBaseZ(), element->AsBanner()->GetPosition() }); - auto result = GameActions::ExecuteNested(&bannerRemoveAction); + auto result = GameActions::ExecuteNested(&bannerRemoveAction, gameState); // If asking nicely did not work, forcibly remove this to avoid an infinite loop. if (result.Error != GameActions::Status::Ok) { diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index 157bc2ab72..ff7b6ce2be 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -674,7 +674,7 @@ namespace OpenRCT2::Park { auto parkSetParameter = GameActions::ParkSetParameterAction( open ? GameActions::ParkParameter::Open : GameActions::ParkParameter::Close); - GameActions::Execute(&parkSetParameter); + GameActions::Execute(&parkSetParameter, getGameState()); } /** diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index 68806ec7e8..5b523afec9 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -234,6 +234,8 @@ void SmallSceneryElement::UpdateAge(const CoordsXY& sceneryPos) */ void SceneryRemoveGhostToolPlacement() { + auto& gameState = getGameState(); + if (gSceneryGhostType & SCENERY_GHOST_FLAG_0) { gSceneryGhostType &= ~SCENERY_GHOST_FLAG_0; @@ -242,7 +244,7 @@ void SceneryRemoveGhostToolPlacement() gSceneryGhostPosition, gSceneryQuadrant, gSceneryPlaceObject.EntryIndex); removeSceneryAction.SetFlags( GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); - removeSceneryAction.Execute(); + removeSceneryAction.Execute(gameState); } if (gSceneryGhostType & SCENERY_GHOST_FLAG_1) @@ -264,7 +266,7 @@ void SceneryRemoveGhostToolPlacement() auto footpathAdditionRemoveAction = GameActions::FootpathAdditionRemoveAction(gSceneryGhostPosition); footpathAdditionRemoveAction.SetFlags( GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); - GameActions::Execute(&footpathAdditionRemoveAction); + GameActions::Execute(&footpathAdditionRemoveAction, gameState); break; } while (!(tileElement++)->IsLastForTile()); } @@ -276,7 +278,7 @@ void SceneryRemoveGhostToolPlacement() CoordsXYZD wallLocation = { gSceneryGhostPosition, gSceneryGhostWallRotation }; auto wallRemoveAction = GameActions::WallRemoveAction(wallLocation); wallRemoveAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); - wallRemoveAction.Execute(); + wallRemoveAction.Execute(gameState); } if (gSceneryGhostType & SCENERY_GHOST_FLAG_3) @@ -286,7 +288,7 @@ void SceneryRemoveGhostToolPlacement() auto removeSceneryAction = GameActions::LargeSceneryRemoveAction({ gSceneryGhostPosition, gSceneryPlaceRotation }, 0); removeSceneryAction.SetFlags( GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); - removeSceneryAction.Execute(); + removeSceneryAction.Execute(gameState); } if (gSceneryGhostType & SCENERY_GHOST_FLAG_4) @@ -296,7 +298,7 @@ void SceneryRemoveGhostToolPlacement() auto removeSceneryAction = GameActions::BannerRemoveAction({ gSceneryGhostPosition, gSceneryPlaceRotation }); removeSceneryAction.SetFlags( GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); - GameActions::Execute(&removeSceneryAction); + GameActions::Execute(&removeSceneryAction, gameState); } } diff --git a/test/tests/PlayTests.cpp b/test/tests/PlayTests.cpp index 4892963312..744c61f67c 100644 --- a/test/tests/PlayTests.cpp +++ b/test/tests/PlayTests.cpp @@ -83,7 +83,7 @@ template static void execute(Args&&... args) { GA ga(std::forward(args)...); - GameActions::Execute(&ga); + GameActions::Execute(&ga, getGameState()); } TEST_F(PlayTests, SecondGuestInQueueShouldNotRideIfNoFunds)