diff --git a/src/openrct2-ui/ride/Construction.cpp b/src/openrct2-ui/ride/Construction.cpp index 9a8c33adf7..8fd000da6b 100644 --- a/src/openrct2-ui/ride/Construction.cpp +++ b/src/openrct2-ui/ride/Construction.cpp @@ -232,7 +232,7 @@ namespace OpenRCT2 auto gameAction = GameActions::RideCreateAction( listItem.Type, listItem.EntryIndex, colour1, colour2, getGameState().lastEntranceStyle); - gameAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { + gameAction.SetCallback([](const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) return; const auto rideIndex = result->GetData(); diff --git a/src/openrct2-ui/windows/ClearScenery.cpp b/src/openrct2-ui/windows/ClearScenery.cpp index e22618f5b3..9b4c0709fa 100644 --- a/src/openrct2-ui/windows/ClearScenery.cpp +++ b/src/openrct2-ui/windows/ClearScenery.cpp @@ -197,20 +197,20 @@ namespace OpenRCT2::Ui::Windows } } - ClearAction GetClearAction() + GameActions::ClearAction GetClearAction() { auto range = MapRange(gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y); - ClearableItems itemsToClear = 0; + GameActions::ClearableItems itemsToClear = 0; if (_clearSmallScenery) - itemsToClear |= CLEARABLE_ITEMS::kScenerySmall; + itemsToClear |= GameActions::CLEARABLE_ITEMS::kScenerySmall; if (_clearLargeScenery) - itemsToClear |= CLEARABLE_ITEMS::kSceneryLarge; + itemsToClear |= GameActions::CLEARABLE_ITEMS::kSceneryLarge; if (_clearFootpath) - itemsToClear |= CLEARABLE_ITEMS::kSceneryFootpath; + itemsToClear |= GameActions::CLEARABLE_ITEMS::kSceneryFootpath; - return ClearAction(range, itemsToClear); + return GameActions::ClearAction(range, itemsToClear); } int8_t ToolUpdateClearLandPaint(const ScreenCoordsXY& screenPos) diff --git a/src/openrct2-ui/windows/EditorScenarioOptions.cpp b/src/openrct2-ui/windows/EditorScenarioOptions.cpp index 893f10b338..e85161e2bb 100644 --- a/src/openrct2-ui/windows/EditorScenarioOptions.cpp +++ b/src/openrct2-ui/windows/EditorScenarioOptions.cpp @@ -967,8 +967,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_HARD_PARK_RATING: { auto& gameState = getGameState(); - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::ParkRatingHigherDifficultyLevel, + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::ParkRatingHigherDifficultyLevel, gameState.park.flags & PARK_FLAGS_DIFFICULT_PARK_RATING ? 0 : 1); GameActions::Execute(&scenarioSetSetting); Invalidate(); @@ -1386,15 +1386,16 @@ namespace OpenRCT2::Ui::Windows case WIDX_NO_MONEY: { auto newMoneySetting = (gameState.park.flags & PARK_FLAGS_NO_MONEY) ? 0 : 1; - auto scenarioSetSetting = ScenarioSetSettingAction(ScenarioSetSetting::NoMoney, newMoneySetting); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::NoMoney, newMoneySetting); GameActions::Execute(&scenarioSetSetting); Invalidate(); break; } case WIDX_FORBID_MARKETING: { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::ForbidMarketingCampaigns, + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::ForbidMarketingCampaigns, gameState.park.flags & PARK_FLAGS_FORBID_MARKETING_CAMPAIGN ? 0 : 1); GameActions::Execute(&scenarioSetSetting); Invalidate(); @@ -1402,8 +1403,9 @@ namespace OpenRCT2::Ui::Windows } case WIDX_RCT1_INTEREST: { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::UseRCT1Interest, gameState.park.flags & PARK_FLAGS_RCT1_INTEREST ? 0 : 1); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::UseRCT1Interest, + gameState.park.flags & PARK_FLAGS_RCT1_INTEREST ? 0 : 1); GameActions::Execute(&scenarioSetSetting); Invalidate(); break; @@ -1424,8 +1426,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_INITIAL_CASH_INCREASE: if (gameState.scenarioOptions.initialCash < 1000000.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::InitialCash, gameState.scenarioOptions.initialCash + 500.00_GBP); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::InitialCash, gameState.scenarioOptions.initialCash + 500.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1437,8 +1439,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_INITIAL_CASH_DECREASE: if (gameState.scenarioOptions.initialCash > 0.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::InitialCash, gameState.scenarioOptions.initialCash - 500.00_GBP); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::InitialCash, gameState.scenarioOptions.initialCash - 500.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1450,8 +1452,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_INITIAL_LOAN_INCREASE: if (gameState.park.bankLoan < 5000000.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::InitialLoan, gameState.park.bankLoan + 1000.00_GBP); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::InitialLoan, gameState.park.bankLoan + 1000.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1463,8 +1465,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_INITIAL_LOAN_DECREASE: if (gameState.park.bankLoan > 0.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::InitialLoan, gameState.park.bankLoan - 1000.00_GBP); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::InitialLoan, gameState.park.bankLoan - 1000.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1476,8 +1478,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_MAXIMUM_LOAN_INCREASE: if (gameState.park.maxBankLoan < 5000000.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::MaximumLoanSize, gameState.park.maxBankLoan + 1000.00_GBP); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::MaximumLoanSize, gameState.park.maxBankLoan + 1000.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1489,8 +1491,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_MAXIMUM_LOAN_DECREASE: if (gameState.park.maxBankLoan > 0.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::MaximumLoanSize, gameState.park.maxBankLoan - 1000.00_GBP); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::MaximumLoanSize, gameState.park.maxBankLoan - 1000.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1502,8 +1504,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_INTEREST_RATE_INCREASE: if (gameState.park.bankLoanInterestRate < kMaxBankLoanInterestRate) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::AnnualInterestRate, gameState.park.bankLoanInterestRate + 1); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::AnnualInterestRate, gameState.park.bankLoanInterestRate + 1); GameActions::Execute(&scenarioSetSetting); } else @@ -1516,7 +1518,8 @@ namespace OpenRCT2::Ui::Windows if (gameState.park.bankLoanInterestRate > 0) { auto interest = std::min(kMaxBankLoanInterestRate, gameState.park.bankLoanInterestRate - 1); - auto scenarioSetSetting = ScenarioSetSettingAction(ScenarioSetSetting::AnnualInterestRate, interest); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::AnnualInterestRate, interest); GameActions::Execute(&scenarioSetSetting); } else @@ -1528,8 +1531,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_ENTRY_PRICE_INCREASE: if (gameState.park.entranceFee < kMaxEntranceFee) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::ParkChargeEntryFee, gameState.park.entranceFee + 1.00_GBP); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::ParkChargeEntryFee, gameState.park.entranceFee + 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1541,8 +1544,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_ENTRY_PRICE_DECREASE: if (gameState.park.entranceFee > 0.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::ParkChargeEntryFee, gameState.park.entranceFee - 1.00_GBP); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::ParkChargeEntryFee, gameState.park.entranceFee - 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1593,7 +1596,8 @@ namespace OpenRCT2::Ui::Windows { case WIDX_PAY_FOR_PARK_OR_RIDES_DROPDOWN: { - auto scenarioSetSetting = ScenarioSetSettingAction(ScenarioSetSetting::ParkChargeMethod, dropdownIndex); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::ParkChargeMethod, dropdownIndex); GameActions::Execute(&scenarioSetSetting); Invalidate(); break; @@ -1785,8 +1789,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_CASH_PER_GUEST_INCREASE: if (scenarioOptions.guestInitialCash < 1000.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::AverageCashPerGuest, scenarioOptions.guestInitialCash + 1.00_GBP); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::AverageCashPerGuest, scenarioOptions.guestInitialCash + 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1798,8 +1802,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_CASH_PER_GUEST_DECREASE: if (scenarioOptions.guestInitialCash > 0.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::AverageCashPerGuest, scenarioOptions.guestInitialCash - 1.00_GBP); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::AverageCashPerGuest, scenarioOptions.guestInitialCash - 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1811,8 +1815,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_GUEST_INITIAL_HAPPINESS_INCREASE: if (scenarioOptions.guestInitialHappiness < 250) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestInitialHappiness, scenarioOptions.guestInitialHappiness + 4); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::GuestInitialHappiness, scenarioOptions.guestInitialHappiness + 4); GameActions::Execute(&scenarioSetSetting); } else @@ -1824,8 +1828,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_GUEST_INITIAL_HAPPINESS_DECREASE: if (scenarioOptions.guestInitialHappiness > 40) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestInitialHappiness, scenarioOptions.guestInitialHappiness - 4); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::GuestInitialHappiness, scenarioOptions.guestInitialHappiness - 4); GameActions::Execute(&scenarioSetSetting); } else @@ -1837,8 +1841,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_GUEST_INITIAL_HUNGER_INCREASE: if (scenarioOptions.guestInitialHunger > 40) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestInitialHunger, scenarioOptions.guestInitialHunger - 4); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::GuestInitialHunger, scenarioOptions.guestInitialHunger - 4); GameActions::Execute(&scenarioSetSetting); } else @@ -1850,8 +1854,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_GUEST_INITIAL_HUNGER_DECREASE: if (scenarioOptions.guestInitialHunger < 250) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestInitialHunger, scenarioOptions.guestInitialHunger + 4); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::GuestInitialHunger, scenarioOptions.guestInitialHunger + 4); GameActions::Execute(&scenarioSetSetting); } else @@ -1863,8 +1867,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_GUEST_INITIAL_THIRST_INCREASE: if (scenarioOptions.guestInitialThirst > 40) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestInitialThirst, scenarioOptions.guestInitialThirst - 4); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::GuestInitialThirst, scenarioOptions.guestInitialThirst - 4); GameActions::Execute(&scenarioSetSetting); } else @@ -1876,8 +1880,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_GUEST_INITIAL_THIRST_DECREASE: if (scenarioOptions.guestInitialThirst < 250) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestInitialThirst, scenarioOptions.guestInitialThirst + 4); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::GuestInitialThirst, scenarioOptions.guestInitialThirst + 4); GameActions::Execute(&scenarioSetSetting); } else @@ -1916,8 +1920,8 @@ namespace OpenRCT2::Ui::Windows } case WIDX_HARD_GUEST_GENERATION: { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestGenerationHigherDifficultyLevel, + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::GuestGenerationHigherDifficultyLevel, gameState.park.flags & PARK_FLAGS_DIFFICULT_GUEST_GENERATION ? 0 : 1); GameActions::Execute(&scenarioSetSetting); Invalidate(); @@ -1934,12 +1938,12 @@ namespace OpenRCT2::Ui::Windows bool preferLess = dropdownIndex == 0 || dropdownIndex == 2; bool preferMore = dropdownIndex == 0 || dropdownIndex == 3; - auto scenarioSetLessSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestsPreferLessIntenseRides, preferLess); + auto scenarioSetLessSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::GuestsPreferLessIntenseRides, preferLess); GameActions::Execute(&scenarioSetLessSetting); - auto scenarioSetMoreSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestsPreferMoreIntenseRides, preferMore); + auto scenarioSetMoreSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::GuestsPreferMoreIntenseRides, preferMore); GameActions::Execute(&scenarioSetMoreSetting); } @@ -2043,16 +2047,17 @@ namespace OpenRCT2::Ui::Windows { case WIDX_FORBID_TREE_REMOVAL: { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::ForbidTreeRemoval, gameState.park.flags & PARK_FLAGS_FORBID_TREE_REMOVAL ? 0 : 1); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::ForbidTreeRemoval, + gameState.park.flags & PARK_FLAGS_FORBID_TREE_REMOVAL ? 0 : 1); GameActions::Execute(&scenarioSetSetting); Invalidate(); break; } case WIDX_FORBID_LANDSCAPE_CHANGES: { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::ForbidLandscapeChanges, + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::ForbidLandscapeChanges, gameState.park.flags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES ? 0 : 1); GameActions::Execute(&scenarioSetSetting); Invalidate(); @@ -2060,8 +2065,8 @@ namespace OpenRCT2::Ui::Windows } case WIDX_FORBID_HIGH_CONSTRUCTION: { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::ForbidHighConstruction, + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::ForbidHighConstruction, gameState.park.flags & PARK_FLAGS_FORBID_HIGH_CONSTRUCTION ? 0 : 1); GameActions::Execute(&scenarioSetSetting); Invalidate(); @@ -2085,8 +2090,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_LAND_COST_INCREASE: if (scenarioOptions.landPrice < 200.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::CostToBuyLand, scenarioOptions.landPrice + 1.00_GBP); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::CostToBuyLand, scenarioOptions.landPrice + 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -2098,8 +2103,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_LAND_COST_DECREASE: if (scenarioOptions.landPrice > 5.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::CostToBuyLand, scenarioOptions.landPrice - 1.00_GBP); + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::CostToBuyLand, scenarioOptions.landPrice - 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -2111,8 +2116,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_CONSTRUCTION_RIGHTS_COST_INCREASE: if (scenarioOptions.constructionRightsPrice < 200.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::CostToBuyConstructionRights, + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::CostToBuyConstructionRights, scenarioOptions.constructionRightsPrice + 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } @@ -2125,8 +2130,8 @@ namespace OpenRCT2::Ui::Windows case WIDX_CONSTRUCTION_RIGHTS_COST_DECREASE: if (scenarioOptions.constructionRightsPrice > 5.00_GBP) { - auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::CostToBuyConstructionRights, + auto scenarioSetSetting = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::CostToBuyConstructionRights, scenarioOptions.constructionRightsPrice - 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index ef534dbc8f..eddb6e74c1 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -1142,7 +1142,7 @@ namespace OpenRCT2::Ui::Windows auto footpathPlaceAction = GameActions::FootpathPlaceAction( { *mapPos, baseZ }, slope, selectedType, gFootpathSelection.Railings, kInvalidDirection, constructFlags); - footpathPlaceAction.SetCallback([this](const GameAction* ga, const GameActions::Result* result) { + footpathPlaceAction.SetCallback([this](const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error == GameActions::Status::Ok) { // Don't play sound if it is no cost to prevent multiple sounds. TODO: make this work in no money scenarios @@ -1235,46 +1235,47 @@ namespace OpenRCT2::Ui::Windows auto footpathPlaceAction = GameActions::FootpathPlaceAction( footpathLoc, slope, type, gFootpathSelection.Railings, _footpathConstructDirection, constructFlags); - footpathPlaceAction.SetCallback([footpathLoc](const GameAction* ga, const GameActions::Result* result) { - if (result->Error == GameActions::Status::Ok) - { - Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); - } - - auto* windowMgr = GetWindowManager(); - auto* self = static_cast(windowMgr->FindByClass(WindowClass::Footpath)); - if (self == nullptr) - { - return; - } - - if (result->Error == GameActions::Status::Ok) - { - if (gFootpathConstructSlope == 0) + footpathPlaceAction.SetCallback( + [footpathLoc](const GameActions::GameAction* ga, const GameActions::Result* result) { + if (result->Error == GameActions::Status::Ok) { - self->_footpathConstructValidDirections = kInvalidDirection; - } - else - { - self->_footpathConstructValidDirections = self->_footpathConstructDirection; + Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); } - if (gFootpathGroundFlags & ELEMENT_IS_UNDERGROUND) + auto* windowMgr = GetWindowManager(); + auto* self = static_cast(windowMgr->FindByClass(WindowClass::Footpath)); + if (self == nullptr) { - ViewportSetVisibility(ViewportVisibility::UndergroundViewOn); + return; } - gFootpathConstructFromPosition = footpathLoc; - // If we have just built an upwards slope, the next path to construct is - // a bit higher. Note that the z returned by footpath_get_next_path_info - // already is lowered if we are building a downwards slope. - if (gFootpathConstructSlope == 2) + if (result->Error == GameActions::Status::Ok) { - gFootpathConstructFromPosition.z += kPathHeightStep; + if (gFootpathConstructSlope == 0) + { + self->_footpathConstructValidDirections = kInvalidDirection; + } + else + { + self->_footpathConstructValidDirections = self->_footpathConstructDirection; + } + + if (gFootpathGroundFlags & ELEMENT_IS_UNDERGROUND) + { + ViewportSetVisibility(ViewportVisibility::UndergroundViewOn); + } + + gFootpathConstructFromPosition = footpathLoc; + // If we have just built an upwards slope, the next path to construct is + // a bit higher. Note that the z returned by footpath_get_next_path_info + // already is lowered if we are building a downwards slope. + if (gFootpathConstructSlope == 2) + { + gFootpathConstructFromPosition.z += kPathHeightStep; + } } - } - self->WindowFootpathSetEnabledAndPressedWidgets(); - }); + self->WindowFootpathSetEnabledAndPressedWidgets(); + }); GameActions::Execute(&footpathPlaceAction); } diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index bbf8158560..794e9c0045 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -654,16 +654,17 @@ namespace OpenRCT2::Ui::Windows GameActions::PeepPickupAction pickupAction{ GameActions::PeepPickupType::Pickup, EntityId::FromUnderlying(number), nullLoc, NetworkGetCurrentPlayerId() }; - pickupAction.SetCallback([peepnum = number](const GameAction* ga, const GameActions::Result* result) { - if (result->Error != GameActions::Status::Ok) - return; - auto* windowMgr = GetWindowManager(); - WindowBase* wind = windowMgr->FindByNumber(WindowClass::Peep, peepnum); - if (wind != nullptr) - { - ToolSet(*wind, WC_PEEP__WIDX_PICKUP, Tool::picker); - } - }); + pickupAction.SetCallback( + [peepnum = number](const GameActions::GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) + return; + auto* windowMgr = GetWindowManager(); + WindowBase* wind = windowMgr->FindByNumber(WindowClass::Peep, peepnum); + if (wind != nullptr) + { + ToolSet(*wind, WC_PEEP__WIDX_PICKUP, Tool::picker); + } + }); GameActions::Execute(&pickupAction); } break; @@ -1023,7 +1024,7 @@ namespace OpenRCT2::Ui::Windows EntityId::FromUnderlying(number), { destCoords, tileElement->GetBaseZ() }, NetworkGetCurrentPlayerId() }; - pickupAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { + pickupAction.SetCallback([](const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) return; ToolCancel(); diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index eafc703997..5cee7b5f43 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -359,7 +359,8 @@ namespace OpenRCT2::Ui::Windows entranceOrExitCoords, DirectionReverse(entranceOrExitCoords.direction), rideIndex, gRideEntranceExitPlaceStationIndex, gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT); - rideEntranceExitPlaceAction.SetCallback([=, this](const GameAction* ga, const GameActions::Result* result) { + rideEntranceExitPlaceAction.SetCallback([=, this]( + const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) return; diff --git a/src/openrct2-ui/windows/NewCampaign.cpp b/src/openrct2-ui/windows/NewCampaign.cpp index 414b29e7dc..d3d5dbb32b 100644 --- a/src/openrct2-ui/windows/NewCampaign.cpp +++ b/src/openrct2-ui/windows/NewCampaign.cpp @@ -274,7 +274,7 @@ namespace OpenRCT2::Ui::Windows { auto gameAction = GameActions::ParkMarketingAction( Campaign.campaign_type, Campaign.RideId.ToUnderlying(), Campaign.no_weeks); - gameAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { + gameAction.SetCallback([](const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error == GameActions::Status::Ok) { auto* windowMgr = Ui::GetWindowManager(); diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index 99ced2db91..4755cc3c1d 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -1887,8 +1887,8 @@ namespace OpenRCT2::Ui::Windows // current value of allow_early_completion to all clients if (NetworkGetMode() == NETWORK_MODE_SERVER) { - auto setAllowEarlyCompletionAction = ScenarioSetSettingAction( - ScenarioSetSetting::AllowEarlyCompletion, Config::Get().general.AllowEarlyCompletion); + auto setAllowEarlyCompletionAction = GameActions::ScenarioSetSettingAction( + GameActions::ScenarioSetSetting::AllowEarlyCompletion, Config::Get().general.AllowEarlyCompletion); GameActions::Execute(&setAllowEarlyCompletionAction); } Config::Save(); diff --git a/src/openrct2-ui/windows/Player.cpp b/src/openrct2-ui/windows/Player.cpp index 398e39a6cb..fcae4297be 100644 --- a/src/openrct2-ui/windows/Player.cpp +++ b/src/openrct2-ui/windows/Player.cpp @@ -529,13 +529,14 @@ namespace OpenRCT2::Ui::Windows const auto groupId = NetworkGetGroupID(dropdownIndex); const auto windowHandle = std::make_pair(classification, number); auto playerSetGroupAction = GameActions::PlayerSetGroupAction(playerId, groupId); - playerSetGroupAction.SetCallback([windowHandle](const GameAction* ga, const GameActions::Result* result) { - if (result->Error == GameActions::Status::Ok) - { - auto* windowMgr = Ui::GetWindowManager(); - windowMgr->InvalidateByNumber(windowHandle.first, windowHandle.second); - } - }); + playerSetGroupAction.SetCallback( + [windowHandle](const GameActions::GameAction* ga, const GameActions::Result* result) { + if (result->Error == GameActions::Status::Ok) + { + auto* windowMgr = Ui::GetWindowManager(); + windowMgr->InvalidateByNumber(windowHandle.first, windowHandle.second); + } + }); GameActions::Execute(&playerSetGroupAction); } diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index d713ae454a..0f31f3aa33 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -2229,13 +2229,14 @@ namespace OpenRCT2::Ui::Windows { auto rideSetSetting = GameActions::RideSetSettingAction( rideId, GameActions::RideSetSetting::RideType, rideType); - rideSetSetting.SetCallback([](const GameAction* ga, const GameActions::Result* result) { - // Reset ghost track if ride construction window is open, prevents a crash - // Will get set to the correct Alternative variable during set_default_next_piece. - // TODO: Rework construction window to prevent the need for this. - _currentTrackAlternative.clearAll(); - RideConstructionSetDefaultNextPiece(); - }); + rideSetSetting.SetCallback( + [](const GameActions::GameAction* ga, const GameActions::Result* result) { + // Reset ghost track if ride construction window is open, prevents a crash + // Will get set to the correct Alternative variable during set_default_next_piece. + // TODO: Rework construction window to prevent the need for this. + _currentTrackAlternative.clearAll(); + RideConstructionSetDefaultNextPiece(); + }); GameActions::Execute(&rideSetSetting); } } @@ -4488,11 +4489,12 @@ namespace OpenRCT2::Ui::Windows auto objIndex = _entranceDropdownData[dropdownIndex].EntranceTypeId; auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::EntranceStyle, objIndex, 0); - rideSetAppearanceAction.SetCallback([objIndex](const GameAction*, const GameActions::Result* res) { - if (res->Error != GameActions::Status::Ok) - return; - getGameState().lastEntranceStyle = objIndex; - }); + rideSetAppearanceAction.SetCallback( + [objIndex](const GameActions::GameAction*, const GameActions::Result* res) { + if (res->Error != GameActions::Status::Ok) + return; + getGameState().lastEntranceStyle = objIndex; + }); GameActions::Execute(&rideSetAppearanceAction); break; } @@ -4500,12 +4502,13 @@ namespace OpenRCT2::Ui::Windows { auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::VehicleColourScheme, dropdownIndex, 0); - rideSetAppearanceAction.SetCallback([this](const GameAction* ga, const GameActions::Result* result) { - if (result->Error == GameActions::Status::Ok) - { - ResetVehicleIndex(); - } - }); + rideSetAppearanceAction.SetCallback( + [this](const GameActions::GameAction* ga, const GameActions::Result* result) { + if (result->Error == GameActions::Status::Ok) + { + ResetVehicleIndex(); + } + }); GameActions::Execute(&rideSetAppearanceAction); break; } diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index b9f90db11d..390e34badd 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -221,8 +221,10 @@ namespace OpenRCT2::Ui::Windows windowMgr->Close(*w); } - static void RideConstructPlacedForwardGameActionCallback(const GameAction* ga, const GameActions::Result* result); - static void RideConstructPlacedBackwardGameActionCallback(const GameAction* ga, const GameActions::Result* result); + static void RideConstructPlacedForwardGameActionCallback( + const GameActions::GameAction* ga, const GameActions::Result* result); + static void RideConstructPlacedBackwardGameActionCallback( + const GameActions::GameAction* ga, const GameActions::Result* result); static void CloseConstructWindowOnCompletion(const Ride& ride); class RideConstructionWindow final : public Window @@ -2452,7 +2454,7 @@ namespace OpenRCT2::Ui::Windows _currentTrackPieceType, 0, { _currentTrackBegin.x, _currentTrackBegin.y, _currentTrackBegin.z, currentDirection }); - trackRemoveAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + trackRemoveAction.SetCallback([=](const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) { WindowRideConstructionUpdateActiveElements(); @@ -2569,7 +2571,7 @@ namespace OpenRCT2::Ui::Windows { auto trackSetBrakeSpeed = GameActions::TrackSetBrakeSpeedAction( _currentTrackBegin, tileElement->AsTrack()->GetTrackType(), brakesSpeed); - trackSetBrakeSpeed.SetCallback([](const GameAction* ga, const GameActions::Result* result) { + trackSetBrakeSpeed.SetCallback([](const GameActions::GameAction* ga, const GameActions::Result* result) { WindowRideConstructionUpdateActiveElements(); }); GameActions::Execute(&trackSetBrakeSpeed); @@ -2657,36 +2659,37 @@ namespace OpenRCT2::Ui::Windows entranceOrExitCoords, DirectionReverse(gRideEntranceExitPlaceDirection), gRideEntranceExitPlaceRideIndex, gRideEntranceExitPlaceStationIndex, gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT); - rideEntranceExitPlaceAction.SetCallback([=, this](const GameAction* ga, const GameActions::Result* result) { - if (result->Error != GameActions::Status::Ok) - return; + rideEntranceExitPlaceAction.SetCallback( + [=, this](const GameActions::GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) + return; - OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); + OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); - auto* windowMgr = GetWindowManager(); + auto* windowMgr = GetWindowManager(); - auto currentRide = GetRide(gRideEntranceExitPlaceRideIndex); - if (currentRide != nullptr && RideAreAllPossibleEntrancesAndExitsBuilt(*currentRide).Successful) - { - ToolCancel(); - if (!currentRide->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + auto currentRide = GetRide(gRideEntranceExitPlaceRideIndex); + if (currentRide != nullptr && RideAreAllPossibleEntrancesAndExitsBuilt(*currentRide).Successful) { - windowMgr->CloseByClass(WindowClass::RideConstruction); + ToolCancel(); + if (!currentRide->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + { + windowMgr->CloseByClass(WindowClass::RideConstruction); + } } - } - else - { - gRideEntranceExitPlaceType = gRideEntranceExitPlaceType ^ 1; - windowMgr->InvalidateByClass(WindowClass::RideConstruction); + else + { + gRideEntranceExitPlaceType = gRideEntranceExitPlaceType ^ 1; + windowMgr->InvalidateByClass(WindowClass::RideConstruction); - auto newToolWidgetIndex = (gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_ENTRANCE) - ? WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE - : WC_RIDE_CONSTRUCTION__WIDX_EXIT; + auto newToolWidgetIndex = (gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_ENTRANCE) + ? WC_RIDE_CONSTRUCTION__WIDX_ENTRANCE + : WC_RIDE_CONSTRUCTION__WIDX_EXIT; - ToolCancel(); - ToolSet(*this, newToolWidgetIndex, Tool::crosshair); - } - }); + ToolCancel(); + ToolSet(*this, newToolWidgetIndex, Tool::crosshair); + } + }); auto res = GameActions::Execute(&rideEntranceExitPlaceAction); } @@ -2941,7 +2944,8 @@ namespace OpenRCT2::Ui::Windows } } - static void RideConstructPlacedForwardGameActionCallback(const GameAction* ga, const GameActions::Result* result) + static void RideConstructPlacedForwardGameActionCallback( + const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) { @@ -2987,7 +2991,8 @@ namespace OpenRCT2::Ui::Windows CloseConstructWindowOnCompletion(*ride); } - static void RideConstructPlacedBackwardGameActionCallback(const GameAction* ga, const GameActions::Result* result) + static void RideConstructPlacedBackwardGameActionCallback( + const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) { diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index ac4fe463ac..2def6fd209 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -2124,7 +2124,7 @@ namespace OpenRCT2::Ui::Windows // 6e265b auto footpathAdditionPlaceAction = GameActions::FootpathAdditionPlaceAction(loc, entryIndex); footpathAdditionPlaceAction.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED); - footpathAdditionPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + footpathAdditionPlaceAction.SetCallback([=](const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) { return; @@ -2150,7 +2150,7 @@ namespace OpenRCT2::Ui::Windows entryIndex, loc, edge, primaryColour, secondaryColour, tertiaryColour); wallPlaceAction.SetFlags( GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND); - wallPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + wallPlaceAction.SetCallback([=](const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) return; @@ -3058,12 +3058,13 @@ namespace OpenRCT2::Ui::Windows { cur_grid_x, cur_grid_y, gSceneryPlaceZ, gSceneryPlaceRotation }, quadrant, selectedScenery, _sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour); - smallSceneryPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { - if (result->Error == GameActions::Status::Ok) - { - Audio::Play3D(Audio::SoundId::PlaceItem, result->Position); - } - }); + smallSceneryPlaceAction.SetCallback( + [=](const GameActions::GameAction* ga, const GameActions::Result* result) { + if (result->Error == GameActions::Status::Ok) + { + Audio::Play3D(Audio::SoundId::PlaceItem, result->Position); + } + }); auto res = GameActions::Execute(&smallSceneryPlaceAction); if (res.Error == GameActions::Status::Ok) { @@ -3089,13 +3090,14 @@ namespace OpenRCT2::Ui::Windows auto footpathAdditionPlaceAction = GameActions::FootpathAdditionPlaceAction( { gridPos, z }, selectedScenery); - footpathAdditionPlaceAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { - if (result->Error != GameActions::Status::Ok) - { - return; - } - Audio::Play3D(Audio::SoundId::PlaceItem, result->Position); - }); + footpathAdditionPlaceAction.SetCallback( + [](const GameActions::GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) + { + return; + } + Audio::Play3D(Audio::SoundId::PlaceItem, result->Position); + }); auto res = GameActions::Execute(&footpathAdditionPlaceAction); break; } @@ -3142,7 +3144,7 @@ namespace OpenRCT2::Ui::Windows selectedScenery, { gridPos, gSceneryPlaceZ }, edges, _sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour); - wallPlaceAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { + wallPlaceAction.SetCallback([](const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error == GameActions::Status::Ok) { Audio::Play3D(Audio::SoundId::PlaceItem, result->Position); @@ -3195,7 +3197,7 @@ namespace OpenRCT2::Ui::Windows auto sceneryPlaceAction = GameActions::LargeSceneryPlaceAction( loc, selectedScenery, _sceneryPrimaryColour, _scenerySecondaryColour, _sceneryTertiaryColour); - sceneryPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + sceneryPlaceAction.SetCallback([=](const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error == GameActions::Status::Ok) { Audio::Play3D(Audio::SoundId::PlaceItem, result->Position); @@ -3219,7 +3221,7 @@ namespace OpenRCT2::Ui::Windows CoordsXYZD loc{ gridPos, z, direction }; auto primaryColour = _sceneryPrimaryColour; auto bannerPlaceAction = GameActions::BannerPlaceAction(loc, selectedScenery, primaryColour); - bannerPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + bannerPlaceAction.SetCallback([=](const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error == GameActions::Status::Ok) { auto data = result->GetData(); diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 2d616cf235..df03b4288f 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -384,17 +384,18 @@ namespace OpenRCT2::Ui::Windows GameActions::PeepPickupAction pickupAction{ GameActions::PeepPickupType::Pickup, EntityId::FromUnderlying(number), nullLoc, NetworkGetCurrentPlayerId() }; - pickupAction.SetCallback([peepnum = number](const GameAction* ga, const GameActions::Result* result) { - if (result->Error != GameActions::Status::Ok) - return; + pickupAction.SetCallback( + [peepnum = number](const GameActions::GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) + return; - auto* windowMgr = GetWindowManager(); - WindowBase* wind = windowMgr->FindByNumber(WindowClass::Peep, peepnum); - if (wind != nullptr) - { - ToolSet(*wind, WC_STAFF__WIDX_PICKUP, Tool::picker); - } - }); + auto* windowMgr = GetWindowManager(); + WindowBase* wind = windowMgr->FindByNumber(WindowClass::Peep, peepnum); + if (wind != nullptr) + { + ToolSet(*wind, WC_STAFF__WIDX_PICKUP, Tool::picker); + } + }); GameActions::Execute(&pickupAction); } break; @@ -711,7 +712,7 @@ namespace OpenRCT2::Ui::Windows staffEntityId, { destCoords, tileElement->GetBaseZ() }, NetworkGetCurrentPlayerId() }; - pickupAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) { + pickupAction.SetCallback([](const GameActions::GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) return; ToolCancel(); diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 66ead3e95e..aee30dfe17 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -538,7 +538,7 @@ namespace OpenRCT2::Ui::Windows costume = findPeepAnimationsIndexForType(animPeepType); auto hireStaffAction = GameActions::StaffHireNewAction(autoPosition, staffType, costume, staffOrders); - hireStaffAction.SetCallback([=](const GameAction*, const GameActions::Result* res) -> void { + hireStaffAction.SetCallback([=](const GameActions::GameAction*, const GameActions::Result* res) -> void { if (res->Error != GameActions::Status::Ok) return; @@ -555,19 +555,20 @@ namespace OpenRCT2::Ui::Windows GameActions::PeepPickupAction pickupAction{ GameActions::PeepPickupType::Pickup, staff->Id, nullLoc, NetworkGetCurrentPlayerId() }; - pickupAction.SetCallback([staffId = staff->Id](const GameAction* ga, const GameActions::Result* result) { - if (result->Error != GameActions::Status::Ok) - return; + pickupAction.SetCallback( + [staffId = staff->Id](const GameActions::GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) + return; - auto* staff2 = GetEntity(staffId); - auto intent = Intent(WindowClass::Peep); - intent.PutExtra(INTENT_EXTRA_PEEP, staff2); - auto* wind = ContextOpenIntent(&intent); - if (wind != nullptr) - { - ToolSet(*wind, WC_STAFF__WIDX_PICKUP, Tool::picker); - } - }); + auto* staff2 = GetEntity(staffId); + auto intent = Intent(WindowClass::Peep); + intent.PutExtra(INTENT_EXTRA_PEEP, staff2); + auto* wind = ContextOpenIntent(&intent); + if (wind != nullptr) + { + ToolSet(*wind, WC_STAFF__WIDX_PICKUP, Tool::picker); + } + }); GameActions::Execute(&pickupAction); } else diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 06940dc3a0..d797beab46 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -215,7 +215,7 @@ namespace OpenRCT2::Ui::Windows // Valid location found. Place the ghost at the location. auto tdAction = GameActions::TrackDesignAction(trackLoc, *_trackDesign); tdAction.SetFlags(GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST); - tdAction.SetCallback([&](const GameAction*, const GameActions::Result* result) { + tdAction.SetCallback([&](const GameActions::GameAction*, const GameActions::Result* result) { if (result->Error == GameActions::Status::Ok) { _placementGhostRideId = result->GetData(); @@ -283,7 +283,7 @@ namespace OpenRCT2::Ui::Windows } auto tdAction = GameActions::TrackDesignAction({ trackLoc, _currentTrackPieceDirection }, *_trackDesign); - tdAction.SetCallback([&](const GameAction*, const GameActions::Result* result) { + tdAction.SetCallback([&](const GameActions::GameAction*, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) { Audio::Play3D(Audio::SoundId::Error, result->Position); diff --git a/src/openrct2/ReplayManager.cpp b/src/openrct2/ReplayManager.cpp index e3e4bc45eb..6b4b06f985 100644 --- a/src/openrct2/ReplayManager.cpp +++ b/src/openrct2/ReplayManager.cpp @@ -46,6 +46,8 @@ namespace OpenRCT2 { + using namespace OpenRCT2::GameActions; + struct ReplayCommand { uint32_t tick = 0; diff --git a/src/openrct2/ReplayManager.h b/src/openrct2/ReplayManager.h index 8b54f0404f..c2286bf62f 100644 --- a/src/openrct2/ReplayManager.h +++ b/src/openrct2/ReplayManager.h @@ -13,7 +13,10 @@ #include #include -class GameAction; +namespace OpenRCT2::GameActions +{ + class GameAction; +} namespace OpenRCT2 { @@ -48,7 +51,7 @@ namespace OpenRCT2 virtual bool IsNormalising() const = 0; virtual bool ShouldDisplayNotice() const = 0; - virtual void AddGameAction(uint32_t tick, const GameAction* action) = 0; + virtual void AddGameAction(uint32_t tick, const GameActions::GameAction* action) = 0; virtual bool StartRecording( const std::string& name, uint32_t maxTicks = k_MaxReplayTicks, RecordType rt = RecordType::NORMAL) diff --git a/src/openrct2/actions/BalloonPressAction.h b/src/openrct2/actions/BalloonPressAction.h index f5c0f6279b..423c51fe43 100644 --- a/src/openrct2/actions/BalloonPressAction.h +++ b/src/openrct2/actions/BalloonPressAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions BalloonPressAction() = default; BalloonPressAction(EntityId spriteIndex); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/BannerPlaceAction.h b/src/openrct2/actions/BannerPlaceAction.h index 9c75a204ba..fe3885a5ab 100644 --- a/src/openrct2/actions/BannerPlaceAction.h +++ b/src/openrct2/actions/BannerPlaceAction.h @@ -29,7 +29,7 @@ namespace OpenRCT2::GameActions BannerPlaceAction() = default; BannerPlaceAction(const CoordsXYZD& loc, ObjectEntryIndex bannerType, colour_t primaryColour); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/BannerRemoveAction.h b/src/openrct2/actions/BannerRemoveAction.h index 6108212809..e9571f2bcd 100644 --- a/src/openrct2/actions/BannerRemoveAction.h +++ b/src/openrct2/actions/BannerRemoveAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions BannerRemoveAction() = default; BannerRemoveAction(const CoordsXYZD& loc); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/BannerSetColourAction.h b/src/openrct2/actions/BannerSetColourAction.h index 546c1dd68a..3d74238f75 100644 --- a/src/openrct2/actions/BannerSetColourAction.h +++ b/src/openrct2/actions/BannerSetColourAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions BannerSetColourAction() = default; BannerSetColourAction(const CoordsXYZD& loc, uint8_t primaryColour); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/BannerSetNameAction.h b/src/openrct2/actions/BannerSetNameAction.h index 212feea9c4..1d047386ea 100644 --- a/src/openrct2/actions/BannerSetNameAction.h +++ b/src/openrct2/actions/BannerSetNameAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions BannerSetNameAction() = default; BannerSetNameAction(BannerIndex bannerIndex, const std::string& name); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/BannerSetStyleAction.h b/src/openrct2/actions/BannerSetStyleAction.h index bca3226911..ad994bcbab 100644 --- a/src/openrct2/actions/BannerSetStyleAction.h +++ b/src/openrct2/actions/BannerSetStyleAction.h @@ -34,7 +34,7 @@ namespace OpenRCT2::GameActions BannerSetStyleAction() = default; BannerSetStyleAction(BannerSetStyleType type, BannerIndex bannerIndex, uint8_t parameter); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/CheatSetAction.h b/src/openrct2/actions/CheatSetAction.h index 89f7947ff3..062fd18428 100644 --- a/src/openrct2/actions/CheatSetAction.h +++ b/src/openrct2/actions/CheatSetAction.h @@ -26,7 +26,7 @@ namespace OpenRCT2::GameActions CheatSetAction() = default; CheatSetAction(CheatType cheatType, int64_t param1 = 0, int64_t param2 = 0); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/ClearAction.cpp b/src/openrct2/actions/ClearAction.cpp index c49bd3c490..8ae34f4f1c 100644 --- a/src/openrct2/actions/ClearAction.cpp +++ b/src/openrct2/actions/ClearAction.cpp @@ -25,223 +25,220 @@ #include "SmallSceneryRemoveAction.h" #include "WallRemoveAction.h" -using namespace OpenRCT2; - -ClearAction::ClearAction(MapRange range, ClearableItems itemsToClear) - : _range(range) - , _itemsToClear(itemsToClear) +namespace OpenRCT2::GameActions { -} - -void ClearAction::AcceptParameters(GameActionParameterVisitor& visitor) -{ - visitor.Visit(_range); - visitor.Visit("itemsToClear", _itemsToClear); -} - -uint16_t ClearAction::GetActionFlags() const -{ - return GameAction::GetActionFlags(); -} - -void ClearAction::Serialise(DataSerialiser& stream) -{ - GameAction::Serialise(stream); - - stream << DS_TAG(_range) << DS_TAG(_itemsToClear); -} - -GameActions::Result ClearAction::Query() const -{ - return QueryExecute(false); -} - -GameActions::Result ClearAction::Execute() const -{ - return QueryExecute(true); -} - -GameActions::Result ClearAction::CreateResult() const -{ - auto result = GameActions::Result(); - result.ErrorTitle = STR_UNABLE_TO_REMOVE_ALL_SCENERY_FROM_HERE; - result.Expenditure = ExpenditureType::landscaping; - - auto x = (_range.GetLeft() + _range.GetRight()) / 2 + 16; - auto y = (_range.GetTop() + _range.GetBottom()) / 2 + 16; - auto z = TileElementHeight({ x, y }); - result.Position = CoordsXYZ(x, y, z); - - return result; -} - -GameActions::Result ClearAction::QueryExecute(bool executing) const -{ - auto result = CreateResult(); - - auto noValidTiles = true; - auto error = GameActions::Status::Ok; - StringId errorMessage = kStringIdNone; - money64 totalCost = 0; - - auto validRange = ClampRangeWithinMap(_range); - for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) + ClearAction::ClearAction(MapRange range, ClearableItems itemsToClear) + : _range(range) + , _itemsToClear(itemsToClear) { - for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) + } + + void ClearAction::AcceptParameters(GameActionParameterVisitor& visitor) + { + visitor.Visit(_range); + visitor.Visit("itemsToClear", _itemsToClear); + } + + uint16_t ClearAction::GetActionFlags() const + { + return GameAction::GetActionFlags(); + } + + void ClearAction::Serialise(DataSerialiser& stream) + { + GameAction::Serialise(stream); + + stream << DS_TAG(_range) << DS_TAG(_itemsToClear); + } + + Result ClearAction::Query() const + { + return QueryExecute(false); + } + + Result ClearAction::Execute() const + { + return QueryExecute(true); + } + + Result ClearAction::CreateResult() const + { + auto result = Result(); + result.ErrorTitle = STR_UNABLE_TO_REMOVE_ALL_SCENERY_FROM_HERE; + result.Expenditure = ExpenditureType::landscaping; + + auto x = (_range.GetLeft() + _range.GetRight()) / 2 + 16; + auto y = (_range.GetTop() + _range.GetBottom()) / 2 + 16; + auto z = TileElementHeight({ x, y }); + result.Position = CoordsXYZ(x, y, z); + + return result; + } + + Result ClearAction::QueryExecute(bool executing) const + { + auto result = CreateResult(); + + auto noValidTiles = true; + auto error = Status::Ok; + StringId errorMessage = kStringIdNone; + money64 totalCost = 0; + + auto validRange = ClampRangeWithinMap(_range); + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += kCoordsXYStep) { - if (LocationValid({ x, y }) && MapCanClearAt({ x, y })) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += kCoordsXYStep) { - auto cost = ClearSceneryFromTile({ x, y }, executing); - if (cost != kMoney64Undefined) + if (LocationValid({ x, y }) && MapCanClearAt({ x, y })) { - noValidTiles = false; - totalCost += cost; + auto cost = ClearSceneryFromTile({ x, y }, executing); + if (cost != kMoney64Undefined) + { + noValidTiles = false; + totalCost += cost; + } + } + else + { + error = Status::NotOwned; + errorMessage = STR_LAND_NOT_OWNED_BY_PARK; } } - else - { - error = GameActions::Status::NotOwned; - errorMessage = STR_LAND_NOT_OWNED_BY_PARK; - } } + + if (_itemsToClear & CLEARABLE_ITEMS::kSceneryLarge) + { + ResetClearLargeSceneryFlag(); + } + + if (noValidTiles) + { + result.Error = error; + result.ErrorMessage = errorMessage; + } + + result.Cost = totalCost; + return result; } - if (_itemsToClear & CLEARABLE_ITEMS::kSceneryLarge) + money64 ClearAction::ClearSceneryFromTile(const CoordsXY& tilePos, bool executing) const { - ResetClearLargeSceneryFlag(); - } - - if (noValidTiles) - { - result.Error = error; - result.ErrorMessage = errorMessage; - } - - result.Cost = totalCost; - return result; -} - -money64 ClearAction::ClearSceneryFromTile(const CoordsXY& tilePos, bool executing) const -{ - // Pass down all flags. - TileElement* tileElement = nullptr; - money64 totalCost = 0; - bool tileEdited; - do - { - tileEdited = false; - tileElement = MapGetFirstElementAt(tilePos); - if (tileElement == nullptr) - return totalCost; + // Pass down all flags. + TileElement* tileElement = nullptr; + money64 totalCost = 0; + bool tileEdited; do { - if (tileElement->IsGhost()) - continue; - - switch (tileElement->GetType()) - { - case TileElementType::Path: - if (_itemsToClear & CLEARABLE_ITEMS::kSceneryFootpath) - { - auto footpathRemoveAction = GameActions::FootpathRemoveAction({ tilePos, tileElement->GetBaseZ() }); - footpathRemoveAction.SetFlags(GetFlags()); - - auto res = executing ? GameActions::ExecuteNested(&footpathRemoveAction) - : GameActions::QueryNested(&footpathRemoveAction); - - if (res.Error == GameActions::Status::Ok) - { - totalCost += res.Cost; - tileEdited = executing; - } - } - break; - case TileElementType::SmallScenery: - if (_itemsToClear & CLEARABLE_ITEMS::kScenerySmall) - { - auto removeSceneryAction = GameActions::SmallSceneryRemoveAction( - { tilePos, tileElement->GetBaseZ() }, tileElement->AsSmallScenery()->GetSceneryQuadrant(), - tileElement->AsSmallScenery()->GetEntryIndex()); - removeSceneryAction.SetFlags(GetFlags()); - - auto res = executing ? GameActions::ExecuteNested(&removeSceneryAction) - : GameActions::QueryNested(&removeSceneryAction); - - if (res.Error == GameActions::Status::Ok) - { - totalCost += res.Cost; - tileEdited = executing; - } - } - break; - case TileElementType::Wall: - if (_itemsToClear & CLEARABLE_ITEMS::kScenerySmall) - { - CoordsXYZD wallLocation = { tilePos, tileElement->GetBaseZ(), tileElement->GetDirection() }; - auto wallRemoveAction = GameActions::WallRemoveAction(wallLocation); - wallRemoveAction.SetFlags(GetFlags()); - - auto res = executing ? GameActions::ExecuteNested(&wallRemoveAction) - : GameActions::QueryNested(&wallRemoveAction); - - if (res.Error == GameActions::Status::Ok) - { - totalCost += res.Cost; - tileEdited = executing; - } - } - break; - case TileElementType::LargeScenery: - if (_itemsToClear & CLEARABLE_ITEMS::kSceneryLarge) - { - auto removeSceneryAction = GameActions::LargeSceneryRemoveAction( - { tilePos, tileElement->GetBaseZ(), tileElement->GetDirection() }, - tileElement->AsLargeScenery()->GetSequenceIndex()); - removeSceneryAction.SetFlags(GetFlags() | GAME_COMMAND_FLAG_TRACK_DESIGN); - - auto res = executing ? GameActions::ExecuteNested(&removeSceneryAction) - : GameActions::QueryNested(&removeSceneryAction); - - if (res.Error == GameActions::Status::Ok) - { - totalCost += res.Cost; - tileEdited = executing; - } - } - break; - default: - break; - } - } while (!tileEdited && !(tileElement++)->IsLastForTile()); - } while (tileEdited); - - return totalCost; -} - -void ClearAction::ResetClearLargeSceneryFlag() -{ - auto& gameState = getGameState(); - // TODO: Improve efficiency of this - for (int32_t y = 0; y < gameState.mapSize.y; y++) - { - for (int32_t x = 0; x < gameState.mapSize.x; x++) - { - auto tileElement = MapGetFirstElementAt(TileCoordsXY{ x, y }); + tileEdited = false; + tileElement = MapGetFirstElementAt(tilePos); + if (tileElement == nullptr) + return totalCost; do { - if (tileElement == nullptr) - break; - if (tileElement->GetType() == TileElementType::LargeScenery) + if (tileElement->IsGhost()) + continue; + + switch (tileElement->GetType()) { - tileElement->AsLargeScenery()->SetIsAccounted(false); + case TileElementType::Path: + if (_itemsToClear & CLEARABLE_ITEMS::kSceneryFootpath) + { + auto footpathRemoveAction = FootpathRemoveAction({ tilePos, tileElement->GetBaseZ() }); + footpathRemoveAction.SetFlags(GetFlags()); + + auto res = executing ? ExecuteNested(&footpathRemoveAction) : QueryNested(&footpathRemoveAction); + + if (res.Error == Status::Ok) + { + totalCost += res.Cost; + tileEdited = executing; + } + } + break; + case TileElementType::SmallScenery: + if (_itemsToClear & CLEARABLE_ITEMS::kScenerySmall) + { + auto removeSceneryAction = SmallSceneryRemoveAction( + { tilePos, tileElement->GetBaseZ() }, tileElement->AsSmallScenery()->GetSceneryQuadrant(), + tileElement->AsSmallScenery()->GetEntryIndex()); + removeSceneryAction.SetFlags(GetFlags()); + + auto res = executing ? ExecuteNested(&removeSceneryAction) : QueryNested(&removeSceneryAction); + + if (res.Error == Status::Ok) + { + totalCost += res.Cost; + tileEdited = executing; + } + } + break; + case TileElementType::Wall: + if (_itemsToClear & CLEARABLE_ITEMS::kScenerySmall) + { + CoordsXYZD wallLocation = { tilePos, tileElement->GetBaseZ(), tileElement->GetDirection() }; + auto wallRemoveAction = WallRemoveAction(wallLocation); + wallRemoveAction.SetFlags(GetFlags()); + + auto res = executing ? ExecuteNested(&wallRemoveAction) : QueryNested(&wallRemoveAction); + + if (res.Error == Status::Ok) + { + totalCost += res.Cost; + tileEdited = executing; + } + } + break; + case TileElementType::LargeScenery: + if (_itemsToClear & CLEARABLE_ITEMS::kSceneryLarge) + { + auto removeSceneryAction = LargeSceneryRemoveAction( + { tilePos, tileElement->GetBaseZ(), tileElement->GetDirection() }, + tileElement->AsLargeScenery()->GetSequenceIndex()); + removeSceneryAction.SetFlags(GetFlags() | GAME_COMMAND_FLAG_TRACK_DESIGN); + + auto res = executing ? ExecuteNested(&removeSceneryAction) : QueryNested(&removeSceneryAction); + + if (res.Error == Status::Ok) + { + totalCost += res.Cost; + tileEdited = executing; + } + } + break; + default: + break; } - } while (!(tileElement++)->IsLastForTile()); + } while (!tileEdited && !(tileElement++)->IsLastForTile()); + } while (tileEdited); + + return totalCost; + } + + void ClearAction::ResetClearLargeSceneryFlag() + { + auto& gameState = getGameState(); + // TODO: Improve efficiency of this + for (int32_t y = 0; y < gameState.mapSize.y; y++) + { + for (int32_t x = 0; x < gameState.mapSize.x; x++) + { + auto tileElement = MapGetFirstElementAt(TileCoordsXY{ x, y }); + do + { + if (tileElement == nullptr) + break; + if (tileElement->GetType() == TileElementType::LargeScenery) + { + tileElement->AsLargeScenery()->SetIsAccounted(false); + } + } while (!(tileElement++)->IsLastForTile()); + } } } -} -bool ClearAction::MapCanClearAt(const CoordsXY& location) -{ - return gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode - || MapIsLocationOwnedOrHasRights(location); -} + bool ClearAction::MapCanClearAt(const CoordsXY& location) + { + return gLegacyScene == LegacyScene::scenarioEditor || getGameState().cheats.sandboxMode + || MapIsLocationOwnedOrHasRights(location); + } +} // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/ClearAction.h b/src/openrct2/actions/ClearAction.h index eebe1818d5..a36da05382 100644 --- a/src/openrct2/actions/ClearAction.h +++ b/src/openrct2/actions/ClearAction.h @@ -13,43 +13,46 @@ #include "../management/Finance.h" #include "GameAction.h" -using ClearableItems = uint8_t; - -namespace OpenRCT2::CLEARABLE_ITEMS +namespace OpenRCT2::GameActions { - constexpr ClearableItems kScenerySmall = 1 << 0; - constexpr ClearableItems kSceneryLarge = 1 << 1; - constexpr ClearableItems kSceneryFootpath = 1 << 2; -} // namespace OpenRCT2::CLEARABLE_ITEMS + using ClearableItems = uint8_t; -class ClearAction final : public GameActionBase -{ -private: - MapRange _range; - ClearableItems _itemsToClear{}; + namespace CLEARABLE_ITEMS + { + constexpr ClearableItems kScenerySmall = 1 << 0; + constexpr ClearableItems kSceneryLarge = 1 << 1; + constexpr ClearableItems kSceneryFootpath = 1 << 2; + } // namespace CLEARABLE_ITEMS -public: - ClearAction() = default; - ClearAction(MapRange range, ClearableItems itemsToClear); + class ClearAction final : public GameActionBase + { + private: + MapRange _range; + ClearableItems _itemsToClear{}; - void AcceptParameters(GameActionParameterVisitor& visitor) override; + public: + ClearAction() = default; + ClearAction(MapRange range, ClearableItems itemsToClear); - uint16_t GetActionFlags() const override; + void AcceptParameters(GameActionParameterVisitor&) final; - void Serialise(DataSerialiser& stream) override; - OpenRCT2::GameActions::Result Query() const override; - OpenRCT2::GameActions::Result Execute() const override; + uint16_t GetActionFlags() const override; -private: - OpenRCT2::GameActions::Result CreateResult() const; - OpenRCT2::GameActions::Result QueryExecute(bool executing) const; - money64 ClearSceneryFromTile(const CoordsXY& tilePos, bool executing) const; + void Serialise(DataSerialiser& stream) override; + Result Query() const override; + Result Execute() const override; - /** - * Function to clear the flag that is set to prevent cost duplication - * when using the clear scenery tool with large scenery. - */ - static void ResetClearLargeSceneryFlag(); + private: + Result CreateResult() const; + Result QueryExecute(bool executing) const; + money64 ClearSceneryFromTile(const CoordsXY& tilePos, bool executing) const; - static bool MapCanClearAt(const CoordsXY& location); -}; + /** + * 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 bool MapCanClearAt(const CoordsXY& location); + }; +} // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/FootpathAdditionPlaceAction.h b/src/openrct2/actions/FootpathAdditionPlaceAction.h index 8e81475ab1..8c2481a3a5 100644 --- a/src/openrct2/actions/FootpathAdditionPlaceAction.h +++ b/src/openrct2/actions/FootpathAdditionPlaceAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions FootpathAdditionPlaceAction() = default; FootpathAdditionPlaceAction(const CoordsXYZ& loc, ObjectEntryIndex pathItemType); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/FootpathAdditionRemoveAction.h b/src/openrct2/actions/FootpathAdditionRemoveAction.h index e43166f8ed..7cf9b21aea 100644 --- a/src/openrct2/actions/FootpathAdditionRemoveAction.h +++ b/src/openrct2/actions/FootpathAdditionRemoveAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions FootpathAdditionRemoveAction() = default; FootpathAdditionRemoveAction(const CoordsXYZ& loc); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/FootpathLayoutPlaceAction.h b/src/openrct2/actions/FootpathLayoutPlaceAction.h index 576baf8465..fd909c2777 100644 --- a/src/openrct2/actions/FootpathLayoutPlaceAction.h +++ b/src/openrct2/actions/FootpathLayoutPlaceAction.h @@ -30,7 +30,7 @@ namespace OpenRCT2::GameActions const CoordsXYZ& loc, uint8_t slope, ObjectEntryIndex type, ObjectEntryIndex railingsType, uint8_t edges, PathConstructFlags constructFlags = 0); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/FootpathPlaceAction.h b/src/openrct2/actions/FootpathPlaceAction.h index d4b6abe423..1a04e57ec3 100644 --- a/src/openrct2/actions/FootpathPlaceAction.h +++ b/src/openrct2/actions/FootpathPlaceAction.h @@ -29,7 +29,7 @@ namespace OpenRCT2::GameActions FootpathPlaceAction( const CoordsXYZ& loc, uint8_t slope, ObjectEntryIndex type, ObjectEntryIndex railingsType, Direction direction = kInvalidDirection, PathConstructFlags constructFlags = 0); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/FootpathRemoveAction.h b/src/openrct2/actions/FootpathRemoveAction.h index 2398de32dc..a2acda5b3f 100644 --- a/src/openrct2/actions/FootpathRemoveAction.h +++ b/src/openrct2/actions/FootpathRemoveAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions FootpathRemoveAction() = default; FootpathRemoveAction(const CoordsXYZ& location); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index 361b2ebb97..2de84c51fa 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -463,43 +463,43 @@ namespace OpenRCT2::GameActions { return ExecuteInternal(action, false); } -} // namespace OpenRCT2::GameActions -const char* GameAction::GetName() const -{ - return OpenRCT2::GameActions::GetName(_type); -} - -bool GameAction::LocationValid(const CoordsXY& coords) const -{ - auto result = MapIsLocationValid(coords); - if (!result) - return false; -#ifdef ENABLE_SCRIPTING - auto& hookEngine = OpenRCT2::GetContext()->GetScriptEngine().GetHookEngine(); - if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::actionLocation)) + const char* GameAction::GetName() const { - auto ctx = OpenRCT2::GetContext()->GetScriptEngine().GetContext(); - - // Create event args object - auto obj = OpenRCT2::Scripting::DukObject(ctx); - obj.Set("x", coords.x); - obj.Set("y", coords.y); - obj.Set("player", _playerId); - obj.Set("type", EnumValue(_type)); - - auto flags = GetActionFlags(); - obj.Set("isClientOnly", (flags & OpenRCT2::GameActions::Flags::ClientOnly) != 0); - obj.Set("result", true); - - // Call the subscriptions - auto e = obj.Take(); - hookEngine.Call(OpenRCT2::Scripting::HookType::actionLocation, e, true); - - auto scriptResult = OpenRCT2::Scripting::AsOrDefault(e["result"], true); - - return scriptResult; + return OpenRCT2::GameActions::GetName(_type); } + + bool GameAction::LocationValid(const CoordsXY& coords) const + { + auto result = MapIsLocationValid(coords); + if (!result) + return false; +#ifdef ENABLE_SCRIPTING + auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine(); + if (hookEngine.HasSubscriptions(Scripting::HookType::actionLocation)) + { + auto ctx = GetContext()->GetScriptEngine().GetContext(); + + // Create event args object + auto obj = Scripting::DukObject(ctx); + obj.Set("x", coords.x); + obj.Set("y", coords.y); + obj.Set("player", _playerId); + obj.Set("type", EnumValue(_type)); + + auto flags = GetActionFlags(); + obj.Set("isClientOnly", (flags & GameActions::Flags::ClientOnly) != 0); + obj.Set("result", true); + + // Call the subscriptions + auto e = obj.Take(); + hookEngine.Call(Scripting::HookType::actionLocation, e, true); + + auto scriptResult = Scripting::AsOrDefault(e["result"], true); + + return scriptResult; + } #endif - return true; -} + return true; + } +} // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/GameAction.h b/src/openrct2/actions/GameAction.h index 0e200d3143..7c215fbbde 100644 --- a/src/openrct2/actions/GameAction.h +++ b/src/openrct2/actions/GameAction.h @@ -27,245 +27,239 @@ namespace OpenRCT2::GameActions constexpr uint16_t IgnoreForReplays = 1 << 3; } // namespace Flags -} // namespace OpenRCT2::GameActions - + // GCC 15.1 is overzealous with its 'final' warnings #ifdef __WARN_SUGGEST_FINAL_METHODS__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsuggest-final-methods" #pragma GCC diagnostic ignored "-Wsuggest-final-types" #endif -/** - * - */ -class GameActionParameterVisitor -{ -public: - virtual ~GameActionParameterVisitor() = default; - - virtual void Visit(std::string_view name, bool& param) + class GameActionParameterVisitor { - } + public: + virtual ~GameActionParameterVisitor() = default; - virtual void Visit(std::string_view name, int32_t& param) - { - } - - virtual void Visit(std::string_view name, std::string& param) - { - } - - void Visit(CoordsXY& param) - { - Visit("x", param.x); - Visit("y", param.y); - } - - void Visit(CoordsXYZ& param) - { - Visit("x", param.x); - Visit("y", param.y); - Visit("z", param.z); - } - - void Visit(CoordsXYZD& param) - { - Visit("x", param.x); - Visit("y", param.y); - Visit("z", param.z); - Visit("direction", param.direction); - } - - void Visit(MapRange& param) - { - Visit("x1", param.Point1.x); - Visit("y1", param.Point1.y); - Visit("x2", param.Point2.x); - Visit("y2", param.Point2.y); - } - - template - void Visit(std::string_view name, T& param) - { - static_assert(std::is_arithmetic_v || std::is_enum_v, "Not an arithmetic type"); - auto value = static_cast(param); - Visit(name, value); - param = static_cast(value); - } - - template - void Visit(std::string_view name, TIdentifier& param) - { - auto value = param.ToUnderlying(); - Visit(name, value); - param = TIdentifier::FromUnderlying(value); - } - - template - void Visit(std::string_view name, NetworkObjectId& param) - { - Visit(name, param.id); - } -}; - -class GameAction -{ -public: - using Ptr = std::unique_ptr; - using Callback_t = std::function; - -private: - GameCommand const _type; - - NetworkPlayerId_t _playerId = { -1 }; // Callee - uint32_t _flags = 0; // GAME_COMMAND_FLAGS - uint32_t _networkId = 0; - Callback_t _callback; - -public: - GameAction(GameCommand type) - : _type(type) - { - } - - virtual ~GameAction() = default; - - const char* GetName() const; - - virtual void AcceptParameters(GameActionParameterVisitor&) - { - } - - void AcceptFlags(GameActionParameterVisitor& visitor) - { - visitor.Visit("flags", _flags); - } - - NetworkPlayerId_t GetPlayer() const - { - return _playerId; - } - - void SetPlayer(NetworkPlayerId_t playerId) - { - _playerId = playerId; - } - - /** - * Gets the OpenRCT2::GameActions::Flags flags that are enabled for this game action. - */ - virtual uint16_t GetActionFlags() const - { - // Make sure we execute some things only on the client. - uint16_t flags = 0; - - if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) != 0 || (GetFlags() & GAME_COMMAND_FLAG_NO_SPEND) != 0) + virtual void Visit(std::string_view name, bool& param) { - flags |= OpenRCT2::GameActions::Flags::ClientOnly; } - if (GetFlags() & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) + virtual void Visit(std::string_view name, int32_t& param) { - flags |= OpenRCT2::GameActions::Flags::AllowWhilePaused; } - return flags; - } + virtual void Visit(std::string_view name, std::string& param) + { + } - /** - * Currently used for GAME_COMMAND_FLAGS, needs refactoring once everything is replaced. - */ - uint32_t GetFlags() const + void Visit(CoordsXY& param) + { + Visit("x", param.x); + Visit("y", param.y); + } + + void Visit(CoordsXYZ& param) + { + Visit("x", param.x); + Visit("y", param.y); + Visit("z", param.z); + } + + void Visit(CoordsXYZD& param) + { + Visit("x", param.x); + Visit("y", param.y); + Visit("z", param.z); + Visit("direction", param.direction); + } + + void Visit(MapRange& param) + { + Visit("x1", param.Point1.x); + Visit("y1", param.Point1.y); + Visit("x2", param.Point2.x); + Visit("y2", param.Point2.y); + } + + template + void Visit(std::string_view name, T& param) + { + static_assert(std::is_arithmetic_v || std::is_enum_v, "Not an arithmetic type"); + auto value = static_cast(param); + Visit(name, value); + param = static_cast(value); + } + + template + void Visit(std::string_view name, TIdentifier& param) + { + auto value = param.ToUnderlying(); + Visit(name, value); + param = TIdentifier::FromUnderlying(value); + } + + template + void Visit(std::string_view name, NetworkObjectId& param) + { + Visit(name, param.id); + } + }; + + class GameAction { - return _flags; - } + public: + using Ptr = std::unique_ptr; + using Callback_t = std::function; - uint32_t SetFlags(uint32_t flags) - { - return _flags = flags; - } + private: + GameCommand const _type; - GameCommand GetType() const - { - return _type; - } + NetworkPlayerId_t _playerId = { -1 }; // Callee + uint32_t _flags = 0; // GAME_COMMAND_FLAGS + uint32_t _networkId = 0; + Callback_t _callback; - void SetCallback(Callback_t cb) - { - _callback = cb; - } + public: + GameAction(GameCommand type) + : _type(type) + { + } - const Callback_t& GetCallback() const - { - return _callback; - } + virtual ~GameAction() = default; - void SetNetworkId(uint32_t id) - { - _networkId = id; - } + const char* GetName() const; - uint32_t GetNetworkId() const - { - return _networkId; - } + virtual void AcceptParameters(GameActionParameterVisitor&) + { + } - virtual void Serialise(DataSerialiser& stream) - { - stream << DS_TAG(_networkId) << DS_TAG(_flags) << DS_TAG(_playerId); - } + void AcceptFlags(GameActionParameterVisitor& visitor) + { + visitor.Visit("flags", _flags); + } - // Helper function, allows const Objects to still serialize into DataSerialiser while being const. - void Serialise(DataSerialiser& stream) const - { - return const_cast(*this).Serialise(stream); - } + NetworkPlayerId_t GetPlayer() const + { + return _playerId; + } - /** - * Override this to specify the wait time in milliseconds the player is required to wait before - * being able to execute it again. - */ - virtual uint32_t GetCooldownTime() const - { - return 0; - } + void SetPlayer(NetworkPlayerId_t playerId) + { + _playerId = playerId; + } - /** - * Query the result of the game action without changing the game state. - */ - virtual OpenRCT2::GameActions::Result Query() const = 0; + /** + * Gets the OpenRCT2::GameActions::Flags flags that are enabled for this game action. + */ + virtual uint16_t GetActionFlags() const + { + // Make sure we execute some things only on the client. + uint16_t flags = 0; - /** - * Apply the game action and change the game state. - */ - virtual OpenRCT2::GameActions::Result Execute() const = 0; + if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) != 0 || (GetFlags() & GAME_COMMAND_FLAG_NO_SPEND) != 0) + { + flags |= OpenRCT2::GameActions::Flags::ClientOnly; + } - bool LocationValid(const CoordsXY& coords) const; -}; + if (GetFlags() & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) + { + flags |= OpenRCT2::GameActions::Flags::AllowWhilePaused; + } + + return flags; + } + + /** + * Currently used for GAME_COMMAND_FLAGS, needs refactoring once everything is replaced. + */ + uint32_t GetFlags() const + { + return _flags; + } + + uint32_t SetFlags(uint32_t flags) + { + return _flags = flags; + } + + GameCommand GetType() const + { + return _type; + } + + void SetCallback(Callback_t cb) + { + _callback = cb; + } + + const Callback_t& GetCallback() const + { + return _callback; + } + + void SetNetworkId(uint32_t id) + { + _networkId = id; + } + + uint32_t GetNetworkId() const + { + return _networkId; + } + + virtual void Serialise(DataSerialiser& stream) + { + stream << DS_TAG(_networkId) << DS_TAG(_flags) << DS_TAG(_playerId); + } + + // Helper function, allows const Objects to still serialize into DataSerialiser while being const. + void Serialise(DataSerialiser& stream) const + { + return const_cast(*this).Serialise(stream); + } + + /** + * Override this to specify the wait time in milliseconds the player is required to wait before + * being able to execute it again. + */ + virtual uint32_t GetCooldownTime() const + { + return 0; + } + + /** + * Query the result of the game action without changing the game state. + */ + virtual OpenRCT2::GameActions::Result Query() const = 0; + + /** + * Apply the game action and change the game state. + */ + virtual OpenRCT2::GameActions::Result Execute() const = 0; + + bool LocationValid(const CoordsXY& coords) const; + }; #ifdef __WARN_SUGGEST_FINAL_METHODS__ #pragma GCC diagnostic pop #endif -template -struct GameActionNameQuery -{ -}; - -template -struct GameActionBase : GameAction -{ -public: - static constexpr GameCommand kType = TType; - - GameActionBase() - : GameAction(kType) + template + struct GameActionNameQuery { - } -}; + }; + + template + struct GameActionBase : GameAction + { + public: + static constexpr GameCommand kType = TType; + + GameActionBase() + : GameAction(kType) + { + } + }; -namespace OpenRCT2::GameActions -{ using GameActionFactory = GameAction* (*)(); bool IsValidId(uint32_t id); diff --git a/src/openrct2/actions/GameSetSpeedAction.h b/src/openrct2/actions/GameSetSpeedAction.h index 89c84b0db2..45b126a0cb 100644 --- a/src/openrct2/actions/GameSetSpeedAction.h +++ b/src/openrct2/actions/GameSetSpeedAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions GameSetSpeedAction() = default; GameSetSpeedAction(uint8_t speed); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/GuestSetFlagsAction.h b/src/openrct2/actions/GuestSetFlagsAction.h index ac9ddac1e0..675c2c232f 100644 --- a/src/openrct2/actions/GuestSetFlagsAction.h +++ b/src/openrct2/actions/GuestSetFlagsAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions GuestSetFlagsAction() = default; GuestSetFlagsAction(EntityId peepId, uint32_t flags); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/GuestSetNameAction.h b/src/openrct2/actions/GuestSetNameAction.h index 292f792a3f..571b11f02a 100644 --- a/src/openrct2/actions/GuestSetNameAction.h +++ b/src/openrct2/actions/GuestSetNameAction.h @@ -26,7 +26,7 @@ namespace OpenRCT2::GameActions EntityId GetSpriteIndex() const; std::string GetGuestName() const; - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/LandBuyRightsAction.h b/src/openrct2/actions/LandBuyRightsAction.h index 577f5617e2..e3d024b278 100644 --- a/src/openrct2/actions/LandBuyRightsAction.h +++ b/src/openrct2/actions/LandBuyRightsAction.h @@ -36,7 +36,7 @@ namespace OpenRCT2::GameActions LandBuyRightsAction(const MapRange& range, LandBuyRightSetting setting); LandBuyRightsAction(const CoordsXY& coord, LandBuyRightSetting setting); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/LandLowerAction.h b/src/openrct2/actions/LandLowerAction.h index a9eed1fc4a..3bfefc3b86 100644 --- a/src/openrct2/actions/LandLowerAction.h +++ b/src/openrct2/actions/LandLowerAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions LandLowerAction() = default; LandLowerAction(const CoordsXY& coords, MapRange range, uint8_t selectionType); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/LandRaiseAction.h b/src/openrct2/actions/LandRaiseAction.h index 0ea3f92372..4e335352df 100644 --- a/src/openrct2/actions/LandRaiseAction.h +++ b/src/openrct2/actions/LandRaiseAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions LandRaiseAction() = default; LandRaiseAction(const CoordsXY& coords, MapRange range, uint8_t selectionType); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/LandSetHeightAction.h b/src/openrct2/actions/LandSetHeightAction.h index eab40d6b79..2669411711 100644 --- a/src/openrct2/actions/LandSetHeightAction.h +++ b/src/openrct2/actions/LandSetHeightAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions LandSetHeightAction() = default; LandSetHeightAction(const CoordsXY& coords, uint8_t height, uint8_t style); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/LandSetRightsAction.h b/src/openrct2/actions/LandSetRightsAction.h index bf804da984..4dee79f29d 100644 --- a/src/openrct2/actions/LandSetRightsAction.h +++ b/src/openrct2/actions/LandSetRightsAction.h @@ -35,7 +35,7 @@ namespace OpenRCT2::GameActions LandSetRightsAction(const MapRange& range, LandSetRightSetting setting, uint8_t ownership = 0); LandSetRightsAction(const CoordsXY& coord, LandSetRightSetting setting, uint8_t ownership = 0); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/LandSmoothAction.h b/src/openrct2/actions/LandSmoothAction.h index 9889a63f41..419f1b3c48 100644 --- a/src/openrct2/actions/LandSmoothAction.h +++ b/src/openrct2/actions/LandSmoothAction.h @@ -30,7 +30,7 @@ namespace OpenRCT2::GameActions LandSmoothAction() = default; LandSmoothAction(const CoordsXY& coords, MapRange range, uint8_t selectionType, bool isLowering); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.h b/src/openrct2/actions/LargeSceneryPlaceAction.h index 730061f82f..86fe27e1de 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.h +++ b/src/openrct2/actions/LargeSceneryPlaceAction.h @@ -42,7 +42,7 @@ namespace OpenRCT2::GameActions const CoordsXYZD& loc, ObjectEntryIndex sceneryType, uint8_t primaryColour, uint8_t secondaryColour, uint8_t tertiaryColour); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/LargeSceneryRemoveAction.h b/src/openrct2/actions/LargeSceneryRemoveAction.h index 6b6e5e0b79..0995e92257 100644 --- a/src/openrct2/actions/LargeSceneryRemoveAction.h +++ b/src/openrct2/actions/LargeSceneryRemoveAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions LargeSceneryRemoveAction() = default; LargeSceneryRemoveAction(const CoordsXYZD& location, uint16_t tileIndex); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/LargeScenerySetColourAction.h b/src/openrct2/actions/LargeScenerySetColourAction.h index f0a56d7dcb..199f3c0e2e 100644 --- a/src/openrct2/actions/LargeScenerySetColourAction.h +++ b/src/openrct2/actions/LargeScenerySetColourAction.h @@ -27,7 +27,7 @@ namespace OpenRCT2::GameActions LargeScenerySetColourAction( const CoordsXYZD& loc, uint8_t tileIndex, uint8_t primaryColour, uint8_t secondaryColour, uint8_t tertiaryColour); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/LoadOrQuitAction.h b/src/openrct2/actions/LoadOrQuitAction.h index 611cd9261e..0b3ed06e45 100644 --- a/src/openrct2/actions/LoadOrQuitAction.h +++ b/src/openrct2/actions/LoadOrQuitAction.h @@ -30,7 +30,7 @@ namespace OpenRCT2::GameActions LoadOrQuitAction() = default; LoadOrQuitAction(LoadOrQuitModes mode, PromptMode savePromptMode = PromptMode::saveBeforeLoad); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/MapChangeSizeAction.h b/src/openrct2/actions/MapChangeSizeAction.h index 5c8520c145..d8e884bf27 100644 --- a/src/openrct2/actions/MapChangeSizeAction.h +++ b/src/openrct2/actions/MapChangeSizeAction.h @@ -21,7 +21,7 @@ namespace OpenRCT2::GameActions MapChangeSizeAction(const TileCoordsXY& targetSize); MapChangeSizeAction(const TileCoordsXY& targetSize, const TileCoordsXY& shift); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; diff --git a/src/openrct2/actions/MazePlaceTrackAction.h b/src/openrct2/actions/MazePlaceTrackAction.h index b2bb6086c5..84f650671b 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.h +++ b/src/openrct2/actions/MazePlaceTrackAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions MazePlaceTrackAction() = default; MazePlaceTrackAction(const CoordsXYZ& location, RideId rideIndex, uint16_t mazeEntry); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; void Serialise(DataSerialiser& stream) override; Result Query() const override; Result Execute() const override; diff --git a/src/openrct2/actions/MazeSetTrackAction.h b/src/openrct2/actions/MazeSetTrackAction.h index bbd70abf54..ad70a9fbc7 100644 --- a/src/openrct2/actions/MazeSetTrackAction.h +++ b/src/openrct2/actions/MazeSetTrackAction.h @@ -25,7 +25,7 @@ namespace OpenRCT2::GameActions MazeSetTrackAction() = default; MazeSetTrackAction(const CoordsXYZD& location, bool initialPlacement, RideId rideIndex, uint8_t mode); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; void Serialise(DataSerialiser& stream) override; Result Query() const override; Result Execute() const override; diff --git a/src/openrct2/actions/NetworkModifyGroupAction.h b/src/openrct2/actions/NetworkModifyGroupAction.h index 394c84780b..7844b406b1 100644 --- a/src/openrct2/actions/NetworkModifyGroupAction.h +++ b/src/openrct2/actions/NetworkModifyGroupAction.h @@ -46,7 +46,7 @@ namespace OpenRCT2::GameActions ModifyGroupType type, uint8_t groupId = std::numeric_limits::max(), const std::string name = "", uint32_t permissionIndex = 0, PermissionState permissionState = PermissionState::Count); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/ParkEntrancePlaceAction.h b/src/openrct2/actions/ParkEntrancePlaceAction.h index 7e9cc7f1fd..319d14b8cf 100644 --- a/src/openrct2/actions/ParkEntrancePlaceAction.h +++ b/src/openrct2/actions/ParkEntrancePlaceAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions ParkEntrancePlaceAction() = default; ParkEntrancePlaceAction(const CoordsXYZD& location, ObjectEntryIndex pathType, ObjectEntryIndex entranceType); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/ParkEntranceRemoveAction.h b/src/openrct2/actions/ParkEntranceRemoveAction.h index 76106403a8..93a1743ad7 100644 --- a/src/openrct2/actions/ParkEntranceRemoveAction.h +++ b/src/openrct2/actions/ParkEntranceRemoveAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions ParkEntranceRemoveAction() = default; ParkEntranceRemoveAction(const CoordsXYZ& loc); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/ParkMarketingAction.h b/src/openrct2/actions/ParkMarketingAction.h index c1ec93257a..ad473f8fda 100644 --- a/src/openrct2/actions/ParkMarketingAction.h +++ b/src/openrct2/actions/ParkMarketingAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions ParkMarketingAction() = default; ParkMarketingAction(int32_t type, int32_t item, int32_t numWeeks); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/ParkSetDateAction.h b/src/openrct2/actions/ParkSetDateAction.h index cfe587ba4a..05a38d81d9 100644 --- a/src/openrct2/actions/ParkSetDateAction.h +++ b/src/openrct2/actions/ParkSetDateAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions ParkSetDateAction() = default; ParkSetDateAction(int32_t year, int32_t month, int32_t day); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/ParkSetEntranceFeeAction.h b/src/openrct2/actions/ParkSetEntranceFeeAction.h index f77ff7a760..41ffddb644 100644 --- a/src/openrct2/actions/ParkSetEntranceFeeAction.h +++ b/src/openrct2/actions/ParkSetEntranceFeeAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions ParkSetEntranceFeeAction() = default; ParkSetEntranceFeeAction(money64 fee); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/ParkSetLoanAction.h b/src/openrct2/actions/ParkSetLoanAction.h index b85feb86a6..7421d7bcdc 100644 --- a/src/openrct2/actions/ParkSetLoanAction.h +++ b/src/openrct2/actions/ParkSetLoanAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions ParkSetLoanAction() = default; ParkSetLoanAction(money64 value); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/ParkSetNameAction.h b/src/openrct2/actions/ParkSetNameAction.h index 49e0302dcc..fe7ea7515f 100644 --- a/src/openrct2/actions/ParkSetNameAction.h +++ b/src/openrct2/actions/ParkSetNameAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions ParkSetNameAction() = default; ParkSetNameAction(const std::string& name); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/ParkSetParameterAction.h b/src/openrct2/actions/ParkSetParameterAction.h index 4ccf87d888..6a229d8656 100644 --- a/src/openrct2/actions/ParkSetParameterAction.h +++ b/src/openrct2/actions/ParkSetParameterAction.h @@ -38,7 +38,7 @@ namespace OpenRCT2::GameActions ParkSetParameterAction() = default; ParkSetParameterAction(ParkParameter parameter, uint64_t value = 0); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/ParkSetResearchFundingAction.h b/src/openrct2/actions/ParkSetResearchFundingAction.h index ab663bdc7a..3b87a25ffc 100644 --- a/src/openrct2/actions/ParkSetResearchFundingAction.h +++ b/src/openrct2/actions/ParkSetResearchFundingAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions ParkSetResearchFundingAction() = default; ParkSetResearchFundingAction(uint32_t priorities, uint8_t fundingAmount); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/PeepPickupAction.h b/src/openrct2/actions/PeepPickupAction.h index 903a15d7a7..7e7d558ce0 100644 --- a/src/openrct2/actions/PeepPickupAction.h +++ b/src/openrct2/actions/PeepPickupAction.h @@ -34,7 +34,7 @@ namespace OpenRCT2::GameActions PeepPickupAction() = default; PeepPickupAction(PeepPickupType type, EntityId entityId, const CoordsXYZ& loc, NetworkPlayerId_t owner); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/PeepSpawnPlaceAction.h b/src/openrct2/actions/PeepSpawnPlaceAction.h index 3696e71ec4..2b4f338577 100644 --- a/src/openrct2/actions/PeepSpawnPlaceAction.h +++ b/src/openrct2/actions/PeepSpawnPlaceAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions PeepSpawnPlaceAction() = default; PeepSpawnPlaceAction(const CoordsXYZD& location); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/PlayerKickAction.h b/src/openrct2/actions/PlayerKickAction.h index 66d756bc73..2e6d3e3866 100644 --- a/src/openrct2/actions/PlayerKickAction.h +++ b/src/openrct2/actions/PlayerKickAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions PlayerKickAction(NetworkPlayerId_t playerId); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/PlayerSetGroupAction.h b/src/openrct2/actions/PlayerSetGroupAction.h index fd0bf591f7..2bf7c16d9b 100644 --- a/src/openrct2/actions/PlayerSetGroupAction.h +++ b/src/openrct2/actions/PlayerSetGroupAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions PlayerSetGroupAction() = default; PlayerSetGroupAction(NetworkPlayerId_t playerId, uint8_t groupId); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/RideCreateAction.h b/src/openrct2/actions/RideCreateAction.h index 191cb5e866..f75a1a0bf9 100644 --- a/src/openrct2/actions/RideCreateAction.h +++ b/src/openrct2/actions/RideCreateAction.h @@ -28,7 +28,7 @@ namespace OpenRCT2::GameActions ride_type_t rideType, ObjectEntryIndex subType, colour_t colour1, colour_t colour2, ObjectEntryIndex entranceStyleIndex); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; ride_type_t GetRideType() const; ObjectEntryIndex GetRideObject() const; diff --git a/src/openrct2/actions/RideDemolishAction.h b/src/openrct2/actions/RideDemolishAction.h index ff009dab53..9368435302 100644 --- a/src/openrct2/actions/RideDemolishAction.h +++ b/src/openrct2/actions/RideDemolishAction.h @@ -29,9 +29,9 @@ namespace OpenRCT2::GameActions RideDemolishAction() = default; RideDemolishAction(RideId rideIndex, RideModifyType modifyType); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; - uint32_t GetCooldownTime() const override; + uint32_t GetCooldownTime() const final; void Serialise(DataSerialiser& stream) override; Result Query() const override; diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.h b/src/openrct2/actions/RideEntranceExitPlaceAction.h index d08d9965dc..7078a95794 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.h +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.h @@ -28,7 +28,7 @@ namespace OpenRCT2::GameActions RideEntranceExitPlaceAction( const CoordsXY& loc, Direction direction, RideId rideIndex, StationIndex stationNum, bool isExit); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/RideEntranceExitRemoveAction.h b/src/openrct2/actions/RideEntranceExitRemoveAction.h index eb381bdbb5..cb554a1aab 100644 --- a/src/openrct2/actions/RideEntranceExitRemoveAction.h +++ b/src/openrct2/actions/RideEntranceExitRemoveAction.h @@ -25,7 +25,7 @@ namespace OpenRCT2::GameActions RideEntranceExitRemoveAction() = default; RideEntranceExitRemoveAction(const CoordsXY& loc, RideId rideIndex, StationIndex stationNum, bool isExit); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/RideFreezeRatingAction.h b/src/openrct2/actions/RideFreezeRatingAction.h index 5a23e9b97a..4fd1208f23 100644 --- a/src/openrct2/actions/RideFreezeRatingAction.h +++ b/src/openrct2/actions/RideFreezeRatingAction.h @@ -31,7 +31,7 @@ namespace OpenRCT2::GameActions RideFreezeRatingAction() = default; RideFreezeRatingAction(RideId rideIndex, RideRatingType type, RideRating_t value); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; void Serialise(DataSerialiser& stream) override; Result Query() const override; diff --git a/src/openrct2/actions/RideSetAppearanceAction.h b/src/openrct2/actions/RideSetAppearanceAction.h index 53aea6f639..a86203ef51 100644 --- a/src/openrct2/actions/RideSetAppearanceAction.h +++ b/src/openrct2/actions/RideSetAppearanceAction.h @@ -39,7 +39,7 @@ namespace OpenRCT2::GameActions RideSetAppearanceAction() = default; RideSetAppearanceAction(RideId rideIndex, RideSetAppearanceType type, uint16_t value, uint32_t index); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/RideSetColourSchemeAction.h b/src/openrct2/actions/RideSetColourSchemeAction.h index 8995d1f531..c15a7a3e99 100644 --- a/src/openrct2/actions/RideSetColourSchemeAction.h +++ b/src/openrct2/actions/RideSetColourSchemeAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions RideSetColourSchemeAction() = default; RideSetColourSchemeAction(const CoordsXYZD& location, TrackElemType trackType, uint16_t newColourScheme); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/RideSetNameAction.h b/src/openrct2/actions/RideSetNameAction.h index 1a4555a194..81587f9d37 100644 --- a/src/openrct2/actions/RideSetNameAction.h +++ b/src/openrct2/actions/RideSetNameAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions RideSetNameAction() = default; RideSetNameAction(RideId rideIndex, const std::string& name); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/RideSetPriceAction.h b/src/openrct2/actions/RideSetPriceAction.h index e8d8f89d93..8029eab0b7 100644 --- a/src/openrct2/actions/RideSetPriceAction.h +++ b/src/openrct2/actions/RideSetPriceAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions RideSetPriceAction() = default; RideSetPriceAction(RideId rideIndex, money64 price, bool primaryPrice); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/RideSetSettingAction.h b/src/openrct2/actions/RideSetSettingAction.h index 5933b33624..5db87c1f07 100644 --- a/src/openrct2/actions/RideSetSettingAction.h +++ b/src/openrct2/actions/RideSetSettingAction.h @@ -39,7 +39,7 @@ namespace OpenRCT2::GameActions RideSetSettingAction() = default; RideSetSettingAction(RideId rideIndex, RideSetSetting setting, uint8_t value); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/RideSetStatusAction.h b/src/openrct2/actions/RideSetStatusAction.h index 53f683f6ae..e5087c0de5 100644 --- a/src/openrct2/actions/RideSetStatusAction.h +++ b/src/openrct2/actions/RideSetStatusAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions RideSetStatusAction() = default; RideSetStatusAction(RideId rideIndex, RideStatus status); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/RideSetVehicleAction.h b/src/openrct2/actions/RideSetVehicleAction.h index 147fd7ab75..778d8db877 100644 --- a/src/openrct2/actions/RideSetVehicleAction.h +++ b/src/openrct2/actions/RideSetVehicleAction.h @@ -34,7 +34,7 @@ namespace OpenRCT2::GameActions RideSetVehicleAction() = default; RideSetVehicleAction(RideId rideIndex, RideSetVehicleType type, uint16_t value, uint8_t colour = 0); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/ScenarioSetSettingAction.cpp b/src/openrct2/actions/ScenarioSetSettingAction.cpp index 6b697f3f2d..17314ba671 100644 --- a/src/openrct2/actions/ScenarioSetSettingAction.cpp +++ b/src/openrct2/actions/ScenarioSetSettingAction.cpp @@ -18,256 +18,255 @@ #include "../ui/WindowManager.h" #include "../world/Park.h" -using namespace OpenRCT2; - -void ScenarioSetSettingAction::Serialise(DataSerialiser& stream) +namespace OpenRCT2::GameActions { - GameAction::Serialise(stream); - - stream << DS_TAG(_setting) << DS_TAG(_value); -} - -void ScenarioSetSettingAction::AcceptParameters(GameActionParameterVisitor& visitor) -{ - visitor.Visit("setting", _setting); - visitor.Visit("value", _value); -} - -GameActions::Result ScenarioSetSettingAction::Query() const -{ - if (_setting >= ScenarioSetSetting::Count) + void ScenarioSetSettingAction::Serialise(DataSerialiser& stream) { - LOG_ERROR("Invalid scenario setting: %u", _setting); - return GameActions::Result( - GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE); + GameAction::Serialise(stream); + + stream << DS_TAG(_setting) << DS_TAG(_value); } - return GameActions::Result(); -} - -GameActions::Result ScenarioSetSettingAction::Execute() const -{ - auto& gameState = getGameState(); - auto* windowMgr = Ui::GetWindowManager(); - - switch (_setting) + void ScenarioSetSettingAction::AcceptParameters(GameActionParameterVisitor& visitor) { - case ScenarioSetSetting::NoMoney: - if (gLegacyScene == LegacyScene::scenarioEditor) - { - if (_value != 0) + visitor.Visit("setting", _setting); + visitor.Visit("value", _value); + } + + Result ScenarioSetSettingAction::Query() const + { + if (_setting >= ScenarioSetSetting::Count) + { + LOG_ERROR("Invalid scenario setting: %u", _setting); + return Result(Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE); + } + + return Result(); + } + + Result ScenarioSetSettingAction::Execute() const + { + auto& gameState = getGameState(); + auto* windowMgr = Ui::GetWindowManager(); + + switch (_setting) + { + case ScenarioSetSetting::NoMoney: + if (gLegacyScene == LegacyScene::scenarioEditor) { - gameState.park.flags |= PARK_FLAGS_NO_MONEY; + if (_value != 0) + { + gameState.park.flags |= PARK_FLAGS_NO_MONEY; + } + else + { + gameState.park.flags &= ~PARK_FLAGS_NO_MONEY; + } } else { - gameState.park.flags &= ~PARK_FLAGS_NO_MONEY; + if (_value != 0) + { + gameState.park.flags |= PARK_FLAGS_NO_MONEY; + } + else + { + gameState.park.flags &= ~PARK_FLAGS_NO_MONEY; + } + // Invalidate all windows that have anything to do with finance + windowMgr->InvalidateByClass(WindowClass::Ride); + windowMgr->InvalidateByClass(WindowClass::Peep); + windowMgr->InvalidateByClass(WindowClass::ParkInformation); + windowMgr->InvalidateByClass(WindowClass::Finances); + windowMgr->InvalidateByClass(WindowClass::BottomToolbar); + windowMgr->InvalidateByClass(WindowClass::TopToolbar); } - } - else - { - if (_value != 0) - { - gameState.park.flags |= PARK_FLAGS_NO_MONEY; - } - else - { - gameState.park.flags &= ~PARK_FLAGS_NO_MONEY; - } - // Invalidate all windows that have anything to do with finance - windowMgr->InvalidateByClass(WindowClass::Ride); - windowMgr->InvalidateByClass(WindowClass::Peep); - windowMgr->InvalidateByClass(WindowClass::ParkInformation); + break; + case ScenarioSetSetting::InitialCash: + gameState.scenarioOptions.initialCash = std::clamp(_value, 0.00_GBP, 1000000.00_GBP); + gameState.park.cash = gameState.scenarioOptions.initialCash; windowMgr->InvalidateByClass(WindowClass::Finances); windowMgr->InvalidateByClass(WindowClass::BottomToolbar); - windowMgr->InvalidateByClass(WindowClass::TopToolbar); - } - break; - case ScenarioSetSetting::InitialCash: - gameState.scenarioOptions.initialCash = std::clamp(_value, 0.00_GBP, 1000000.00_GBP); - gameState.park.cash = gameState.scenarioOptions.initialCash; - windowMgr->InvalidateByClass(WindowClass::Finances); - windowMgr->InvalidateByClass(WindowClass::BottomToolbar); - break; - case ScenarioSetSetting::InitialLoan: - gameState.park.bankLoan = std::clamp(_value, 0.00_GBP, 5000000.00_GBP); - gameState.park.maxBankLoan = std::max(gameState.park.bankLoan, gameState.park.maxBankLoan); - windowMgr->InvalidateByClass(WindowClass::Finances); - break; - case ScenarioSetSetting::MaximumLoanSize: - gameState.park.maxBankLoan = std::clamp(_value, 0.00_GBP, 5000000.00_GBP); - gameState.park.bankLoan = std::min(gameState.park.bankLoan, gameState.park.maxBankLoan); - windowMgr->InvalidateByClass(WindowClass::Finances); - break; - case ScenarioSetSetting::AnnualInterestRate: - gameState.park.bankLoanInterestRate = std::clamp(_value, 0, kMaxBankLoanInterestRate); - windowMgr->InvalidateByClass(WindowClass::Finances); - break; - case ScenarioSetSetting::ForbidMarketingCampaigns: - if (_value != 0) - { - gameState.park.flags |= PARK_FLAGS_FORBID_MARKETING_CAMPAIGN; - } - else - { - gameState.park.flags &= ~PARK_FLAGS_FORBID_MARKETING_CAMPAIGN; - } - break; - case ScenarioSetSetting::AverageCashPerGuest: - gameState.scenarioOptions.guestInitialCash = std::clamp(_value, 0.00_GBP, 1000.00_GBP); - break; - case ScenarioSetSetting::GuestInitialHappiness: - gameState.scenarioOptions.guestInitialHappiness = std::clamp(_value, 40, 250); - break; - case ScenarioSetSetting::GuestInitialHunger: - gameState.scenarioOptions.guestInitialHunger = std::clamp(_value, 40, 250); - break; - case ScenarioSetSetting::GuestInitialThirst: - gameState.scenarioOptions.guestInitialThirst = std::clamp(_value, 40, 250); - break; - case ScenarioSetSetting::GuestsPreferLessIntenseRides: - if (_value != 0) - { - gameState.park.flags |= PARK_FLAGS_PREF_LESS_INTENSE_RIDES; - } - else - { - gameState.park.flags &= ~PARK_FLAGS_PREF_LESS_INTENSE_RIDES; - } - break; - case ScenarioSetSetting::GuestsPreferMoreIntenseRides: - if (_value != 0) - { - gameState.park.flags |= PARK_FLAGS_PREF_MORE_INTENSE_RIDES; - } - else - { - gameState.park.flags &= ~PARK_FLAGS_PREF_MORE_INTENSE_RIDES; - } - break; - case ScenarioSetSetting::CostToBuyLand: - gameState.scenarioOptions.landPrice = std::clamp(_value, 5.00_GBP, 200.00_GBP); - break; - case ScenarioSetSetting::CostToBuyConstructionRights: - gameState.scenarioOptions.constructionRightsPrice = std::clamp(_value, 5.00_GBP, 200.00_GBP); - break; - case ScenarioSetSetting::ParkChargeMethod: - if (gLegacyScene == LegacyScene::scenarioEditor) - { - if (_value == 0) + break; + case ScenarioSetSetting::InitialLoan: + gameState.park.bankLoan = std::clamp(_value, 0.00_GBP, 5000000.00_GBP); + gameState.park.maxBankLoan = std::max(gameState.park.bankLoan, gameState.park.maxBankLoan); + windowMgr->InvalidateByClass(WindowClass::Finances); + break; + case ScenarioSetSetting::MaximumLoanSize: + gameState.park.maxBankLoan = std::clamp(_value, 0.00_GBP, 5000000.00_GBP); + gameState.park.bankLoan = std::min(gameState.park.bankLoan, gameState.park.maxBankLoan); + windowMgr->InvalidateByClass(WindowClass::Finances); + break; + case ScenarioSetSetting::AnnualInterestRate: + gameState.park.bankLoanInterestRate = std::clamp(_value, 0, kMaxBankLoanInterestRate); + windowMgr->InvalidateByClass(WindowClass::Finances); + break; + case ScenarioSetSetting::ForbidMarketingCampaigns: + if (_value != 0) { - gameState.park.flags |= PARK_FLAGS_PARK_FREE_ENTRY; - gameState.park.flags &= ~PARK_FLAGS_UNLOCK_ALL_PRICES; - gameState.park.entranceFee = 0.00_GBP; - } - else if (_value == 1) - { - gameState.park.flags &= ~PARK_FLAGS_PARK_FREE_ENTRY; - gameState.park.flags &= ~PARK_FLAGS_UNLOCK_ALL_PRICES; - gameState.park.entranceFee = 10.00_GBP; + gameState.park.flags |= PARK_FLAGS_FORBID_MARKETING_CAMPAIGN; } else { - gameState.park.flags |= PARK_FLAGS_PARK_FREE_ENTRY; - gameState.park.flags |= PARK_FLAGS_UNLOCK_ALL_PRICES; - gameState.park.entranceFee = 10.00_GBP; + gameState.park.flags &= ~PARK_FLAGS_FORBID_MARKETING_CAMPAIGN; } - } - else - { - if (_value == 0) + break; + case ScenarioSetSetting::AverageCashPerGuest: + gameState.scenarioOptions.guestInitialCash = std::clamp(_value, 0.00_GBP, 1000.00_GBP); + break; + case ScenarioSetSetting::GuestInitialHappiness: + gameState.scenarioOptions.guestInitialHappiness = std::clamp(_value, 40, 250); + break; + case ScenarioSetSetting::GuestInitialHunger: + gameState.scenarioOptions.guestInitialHunger = std::clamp(_value, 40, 250); + break; + case ScenarioSetSetting::GuestInitialThirst: + gameState.scenarioOptions.guestInitialThirst = std::clamp(_value, 40, 250); + break; + case ScenarioSetSetting::GuestsPreferLessIntenseRides: + if (_value != 0) { - gameState.park.flags |= PARK_FLAGS_PARK_FREE_ENTRY; - gameState.park.flags &= ~PARK_FLAGS_UNLOCK_ALL_PRICES; - } - else if (_value == 1) - { - gameState.park.flags &= ~PARK_FLAGS_PARK_FREE_ENTRY; - gameState.park.flags &= ~PARK_FLAGS_UNLOCK_ALL_PRICES; + gameState.park.flags |= PARK_FLAGS_PREF_LESS_INTENSE_RIDES; } else { - gameState.park.flags |= PARK_FLAGS_PARK_FREE_ENTRY; - gameState.park.flags |= PARK_FLAGS_UNLOCK_ALL_PRICES; + gameState.park.flags &= ~PARK_FLAGS_PREF_LESS_INTENSE_RIDES; } + break; + case ScenarioSetSetting::GuestsPreferMoreIntenseRides: + if (_value != 0) + { + gameState.park.flags |= PARK_FLAGS_PREF_MORE_INTENSE_RIDES; + } + else + { + gameState.park.flags &= ~PARK_FLAGS_PREF_MORE_INTENSE_RIDES; + } + break; + case ScenarioSetSetting::CostToBuyLand: + gameState.scenarioOptions.landPrice = std::clamp(_value, 5.00_GBP, 200.00_GBP); + break; + case ScenarioSetSetting::CostToBuyConstructionRights: + gameState.scenarioOptions.constructionRightsPrice = std::clamp(_value, 5.00_GBP, 200.00_GBP); + break; + case ScenarioSetSetting::ParkChargeMethod: + if (gLegacyScene == LegacyScene::scenarioEditor) + { + if (_value == 0) + { + gameState.park.flags |= PARK_FLAGS_PARK_FREE_ENTRY; + gameState.park.flags &= ~PARK_FLAGS_UNLOCK_ALL_PRICES; + gameState.park.entranceFee = 0.00_GBP; + } + else if (_value == 1) + { + gameState.park.flags &= ~PARK_FLAGS_PARK_FREE_ENTRY; + gameState.park.flags &= ~PARK_FLAGS_UNLOCK_ALL_PRICES; + gameState.park.entranceFee = 10.00_GBP; + } + else + { + gameState.park.flags |= PARK_FLAGS_PARK_FREE_ENTRY; + gameState.park.flags |= PARK_FLAGS_UNLOCK_ALL_PRICES; + gameState.park.entranceFee = 10.00_GBP; + } + } + else + { + if (_value == 0) + { + gameState.park.flags |= PARK_FLAGS_PARK_FREE_ENTRY; + gameState.park.flags &= ~PARK_FLAGS_UNLOCK_ALL_PRICES; + } + else if (_value == 1) + { + gameState.park.flags &= ~PARK_FLAGS_PARK_FREE_ENTRY; + gameState.park.flags &= ~PARK_FLAGS_UNLOCK_ALL_PRICES; + } + else + { + gameState.park.flags |= PARK_FLAGS_PARK_FREE_ENTRY; + gameState.park.flags |= PARK_FLAGS_UNLOCK_ALL_PRICES; + } + windowMgr->InvalidateByClass(WindowClass::ParkInformation); + windowMgr->InvalidateByClass(WindowClass::Ride); + } + break; + case ScenarioSetSetting::ParkChargeEntryFee: + gameState.park.entranceFee = std::clamp(_value, 0.00_GBP, kMaxEntranceFee); windowMgr->InvalidateByClass(WindowClass::ParkInformation); - windowMgr->InvalidateByClass(WindowClass::Ride); - } - break; - case ScenarioSetSetting::ParkChargeEntryFee: - gameState.park.entranceFee = std::clamp(_value, 0.00_GBP, kMaxEntranceFee); - windowMgr->InvalidateByClass(WindowClass::ParkInformation); - break; - case ScenarioSetSetting::ForbidTreeRemoval: - if (_value != 0) + break; + case ScenarioSetSetting::ForbidTreeRemoval: + if (_value != 0) + { + gameState.park.flags |= PARK_FLAGS_FORBID_TREE_REMOVAL; + } + else + { + gameState.park.flags &= ~PARK_FLAGS_FORBID_TREE_REMOVAL; + } + break; + case ScenarioSetSetting::ForbidLandscapeChanges: + if (_value != 0) + { + gameState.park.flags |= PARK_FLAGS_FORBID_LANDSCAPE_CHANGES; + } + else + { + gameState.park.flags &= ~PARK_FLAGS_FORBID_LANDSCAPE_CHANGES; + } + break; + case ScenarioSetSetting::ForbidHighConstruction: + if (_value != 0) + { + gameState.park.flags |= PARK_FLAGS_FORBID_HIGH_CONSTRUCTION; + } + else + { + gameState.park.flags &= ~PARK_FLAGS_FORBID_HIGH_CONSTRUCTION; + } + break; + case ScenarioSetSetting::ParkRatingHigherDifficultyLevel: + if (_value != 0) + { + gameState.park.flags |= PARK_FLAGS_DIFFICULT_PARK_RATING; + } + else + { + gameState.park.flags &= ~PARK_FLAGS_DIFFICULT_PARK_RATING; + } + break; + case ScenarioSetSetting::GuestGenerationHigherDifficultyLevel: + if (_value != 0) + { + gameState.park.flags |= PARK_FLAGS_DIFFICULT_GUEST_GENERATION; + } + else + { + gameState.park.flags &= ~PARK_FLAGS_DIFFICULT_GUEST_GENERATION; + } + break; + case ScenarioSetSetting::AllowEarlyCompletion: + gAllowEarlyCompletionInNetworkPlay = _value; + break; + case ScenarioSetSetting::UseRCT1Interest: { - gameState.park.flags |= PARK_FLAGS_FORBID_TREE_REMOVAL; + if (_value != 0) + { + gameState.park.flags |= PARK_FLAGS_RCT1_INTEREST; + } + else + { + gameState.park.flags &= ~PARK_FLAGS_RCT1_INTEREST; + } + break; } - else - { - gameState.park.flags &= ~PARK_FLAGS_FORBID_TREE_REMOVAL; - } - break; - case ScenarioSetSetting::ForbidLandscapeChanges: - if (_value != 0) - { - gameState.park.flags |= PARK_FLAGS_FORBID_LANDSCAPE_CHANGES; - } - else - { - gameState.park.flags &= ~PARK_FLAGS_FORBID_LANDSCAPE_CHANGES; - } - break; - case ScenarioSetSetting::ForbidHighConstruction: - if (_value != 0) - { - gameState.park.flags |= PARK_FLAGS_FORBID_HIGH_CONSTRUCTION; - } - else - { - gameState.park.flags &= ~PARK_FLAGS_FORBID_HIGH_CONSTRUCTION; - } - break; - case ScenarioSetSetting::ParkRatingHigherDifficultyLevel: - if (_value != 0) - { - gameState.park.flags |= PARK_FLAGS_DIFFICULT_PARK_RATING; - } - else - { - gameState.park.flags &= ~PARK_FLAGS_DIFFICULT_PARK_RATING; - } - break; - case ScenarioSetSetting::GuestGenerationHigherDifficultyLevel: - if (_value != 0) - { - gameState.park.flags |= PARK_FLAGS_DIFFICULT_GUEST_GENERATION; - } - else - { - gameState.park.flags &= ~PARK_FLAGS_DIFFICULT_GUEST_GENERATION; - } - break; - case ScenarioSetSetting::AllowEarlyCompletion: - gAllowEarlyCompletionInNetworkPlay = _value; - break; - case ScenarioSetSetting::UseRCT1Interest: - { - if (_value != 0) - { - gameState.park.flags |= PARK_FLAGS_RCT1_INTEREST; - } - else - { - gameState.park.flags &= ~PARK_FLAGS_RCT1_INTEREST; - } - break; + default: + LOG_ERROR("Invalid scenario setting %u", _setting); + return Result(Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE); } - default: - LOG_ERROR("Invalid scenario setting %u", _setting); - return GameActions::Result( - GameActions::Status::InvalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_VALUE_OUT_OF_RANGE); + windowMgr->InvalidateByClass(WindowClass::EditorScenarioOptions); + return Result(); } - windowMgr->InvalidateByClass(WindowClass::EditorScenarioOptions); - return GameActions::Result(); -} +} // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/ScenarioSetSettingAction.h b/src/openrct2/actions/ScenarioSetSettingAction.h index c591a77f1e..3becef7591 100644 --- a/src/openrct2/actions/ScenarioSetSettingAction.h +++ b/src/openrct2/actions/ScenarioSetSettingAction.h @@ -11,56 +11,59 @@ #include "GameAction.h" -enum class ScenarioSetSetting : uint8_t +namespace OpenRCT2::GameActions { - NoMoney, - InitialCash, - InitialLoan, - MaximumLoanSize, - AnnualInterestRate, - ForbidMarketingCampaigns, - AverageCashPerGuest, - GuestInitialHappiness, - GuestInitialHunger, - GuestInitialThirst, - GuestsPreferLessIntenseRides, - GuestsPreferMoreIntenseRides, - CostToBuyLand, - CostToBuyConstructionRights, - ParkChargeMethod, - ParkChargeEntryFee, - ForbidTreeRemoval, - ForbidLandscapeChanges, - ForbidHighConstruction, - ParkRatingHigherDifficultyLevel, - GuestGenerationHigherDifficultyLevel, - AllowEarlyCompletion, - UseRCT1Interest, - Count -}; - -class ScenarioSetSettingAction final : public GameActionBase -{ -private: - ScenarioSetSetting _setting{ ScenarioSetSetting::Count }; - uint32_t _value{}; - -public: - ScenarioSetSettingAction() = default; - ScenarioSetSettingAction(ScenarioSetSetting setting, uint32_t value) - : _setting(setting) - , _value(value) + enum class ScenarioSetSetting : uint8_t { - } + NoMoney, + InitialCash, + InitialLoan, + MaximumLoanSize, + AnnualInterestRate, + ForbidMarketingCampaigns, + AverageCashPerGuest, + GuestInitialHappiness, + GuestInitialHunger, + GuestInitialThirst, + GuestsPreferLessIntenseRides, + GuestsPreferMoreIntenseRides, + CostToBuyLand, + CostToBuyConstructionRights, + ParkChargeMethod, + ParkChargeEntryFee, + ForbidTreeRemoval, + ForbidLandscapeChanges, + ForbidHighConstruction, + ParkRatingHigherDifficultyLevel, + GuestGenerationHigherDifficultyLevel, + AllowEarlyCompletion, + UseRCT1Interest, + Count + }; - void AcceptParameters(GameActionParameterVisitor& visitor) override; - - uint16_t GetActionFlags() const override + class ScenarioSetSettingAction final : public GameActionBase { - return GameAction::GetActionFlags() | OpenRCT2::GameActions::Flags::AllowWhilePaused; - } + private: + ScenarioSetSetting _setting{ ScenarioSetSetting::Count }; + uint32_t _value{}; - void Serialise(DataSerialiser& stream) override; - OpenRCT2::GameActions::Result Query() const override; - OpenRCT2::GameActions::Result Execute() const override; -}; + public: + ScenarioSetSettingAction() = default; + ScenarioSetSettingAction(ScenarioSetSetting setting, uint32_t value) + : _setting(setting) + , _value(value) + { + } + + void AcceptParameters(GameActionParameterVisitor&) final; + + uint16_t GetActionFlags() const override + { + return GameAction::GetActionFlags() | Flags::AllowWhilePaused; + } + + void Serialise(DataSerialiser& stream) override; + Result Query() const override; + Result Execute() const override; + }; +} // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/SignSetNameAction.h b/src/openrct2/actions/SignSetNameAction.h index 6965b4b7b5..3723d8e727 100644 --- a/src/openrct2/actions/SignSetNameAction.h +++ b/src/openrct2/actions/SignSetNameAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions SignSetNameAction() = default; SignSetNameAction(BannerIndex bannerIndex, const std::string& name); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/SignSetStyleAction.h b/src/openrct2/actions/SignSetStyleAction.h index 95502dd978..4c1b67d798 100644 --- a/src/openrct2/actions/SignSetStyleAction.h +++ b/src/openrct2/actions/SignSetStyleAction.h @@ -25,7 +25,7 @@ namespace OpenRCT2::GameActions SignSetStyleAction() = default; SignSetStyleAction(BannerIndex bannerIndex, uint8_t mainColour, uint8_t textColour, bool isLarge); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.h b/src/openrct2/actions/SmallSceneryPlaceAction.h index acb4f7e6e6..882fa4fbc4 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.h +++ b/src/openrct2/actions/SmallSceneryPlaceAction.h @@ -36,9 +36,9 @@ namespace OpenRCT2::GameActions const CoordsXYZD& loc, uint8_t quadrant, ObjectEntryIndex sceneryType, uint8_t primaryColour, uint8_t secondaryColour, uint8_t tertiaryColour); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; - uint32_t GetCooldownTime() const override; + uint32_t GetCooldownTime() const final; uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.h b/src/openrct2/actions/SmallSceneryRemoveAction.h index 3636599d1e..13a482e59a 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.h +++ b/src/openrct2/actions/SmallSceneryRemoveAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions SmallSceneryRemoveAction() = default; SmallSceneryRemoveAction(const CoordsXYZ& location, uint8_t quadrant, ObjectEntryIndex sceneryType); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/SmallScenerySetColourAction.h b/src/openrct2/actions/SmallScenerySetColourAction.h index 292e641eab..123e4b74a5 100644 --- a/src/openrct2/actions/SmallScenerySetColourAction.h +++ b/src/openrct2/actions/SmallScenerySetColourAction.h @@ -29,7 +29,7 @@ namespace OpenRCT2::GameActions const CoordsXYZ& loc, uint8_t quadrant, ObjectEntryIndex sceneryType, uint8_t primaryColour, uint8_t secondaryColour, uint8_t tertiaryColour); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/StaffFireAction.h b/src/openrct2/actions/StaffFireAction.h index 00e9a2d910..70fb105dc6 100644 --- a/src/openrct2/actions/StaffFireAction.h +++ b/src/openrct2/actions/StaffFireAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions StaffFireAction() = default; StaffFireAction(EntityId spriteId); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/StaffHireNewAction.h b/src/openrct2/actions/StaffHireNewAction.h index 5040d33b9a..0a69ad2016 100644 --- a/src/openrct2/actions/StaffHireNewAction.h +++ b/src/openrct2/actions/StaffHireNewAction.h @@ -31,7 +31,7 @@ namespace OpenRCT2::GameActions StaffHireNewAction() = default; StaffHireNewAction(bool autoPosition, StaffType staffType, ObjectEntryIndex costumeIndex, uint32_t staffOrders); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/StaffSetColourAction.h b/src/openrct2/actions/StaffSetColourAction.h index 2ee3787814..27646bb878 100644 --- a/src/openrct2/actions/StaffSetColourAction.h +++ b/src/openrct2/actions/StaffSetColourAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions StaffSetColourAction() = default; StaffSetColourAction(StaffType staffType, uint8_t colour); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/StaffSetCostumeAction.h b/src/openrct2/actions/StaffSetCostumeAction.h index 2cdd356383..06f1431e33 100644 --- a/src/openrct2/actions/StaffSetCostumeAction.h +++ b/src/openrct2/actions/StaffSetCostumeAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions StaffSetCostumeAction() = default; StaffSetCostumeAction(EntityId spriteIndex, OpenRCT2::ObjectEntryIndex costume); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/StaffSetNameAction.h b/src/openrct2/actions/StaffSetNameAction.h index 59bab0c6e7..d46e835f61 100644 --- a/src/openrct2/actions/StaffSetNameAction.h +++ b/src/openrct2/actions/StaffSetNameAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions StaffSetNameAction() = default; StaffSetNameAction(EntityId spriteIndex, const std::string& name); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; void Serialise(DataSerialiser& stream) override; diff --git a/src/openrct2/actions/StaffSetOrdersAction.h b/src/openrct2/actions/StaffSetOrdersAction.h index 24a0d6be14..3c5db943a9 100644 --- a/src/openrct2/actions/StaffSetOrdersAction.h +++ b/src/openrct2/actions/StaffSetOrdersAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions StaffSetOrdersAction() = default; StaffSetOrdersAction(EntityId spriteIndex, uint8_t ordersId); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.h b/src/openrct2/actions/StaffSetPatrolAreaAction.h index f18ee9a9cc..389ce79abb 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.h +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.h @@ -35,7 +35,7 @@ namespace OpenRCT2::GameActions uint16_t GetActionFlags() const override; - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; void Serialise(DataSerialiser& stream) override; Result Query() const override; Result Execute() const override; diff --git a/src/openrct2/actions/SurfaceSetStyleAction.h b/src/openrct2/actions/SurfaceSetStyleAction.h index fbf2483235..503bb3eec2 100644 --- a/src/openrct2/actions/SurfaceSetStyleAction.h +++ b/src/openrct2/actions/SurfaceSetStyleAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions SurfaceSetStyleAction() = default; SurfaceSetStyleAction(MapRange range, ObjectEntryIndex surfaceStyle, ObjectEntryIndex edgeStyle); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; void Serialise(DataSerialiser& stream) override; Result Query() const override; diff --git a/src/openrct2/actions/TileModifyAction.h b/src/openrct2/actions/TileModifyAction.h index a11e1e000c..38e3c0d77d 100644 --- a/src/openrct2/actions/TileModifyAction.h +++ b/src/openrct2/actions/TileModifyAction.h @@ -60,7 +60,7 @@ namespace OpenRCT2::GameActions CoordsXY loc, TileModifyType setting, uint32_t value1 = 0, uint32_t value2 = 0, TileElement pasteElement = {}, Banner _pasteBanner = {}); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/TrackDesignAction.h b/src/openrct2/actions/TrackDesignAction.h index df8bd1fbd4..19f48402ac 100644 --- a/src/openrct2/actions/TrackDesignAction.h +++ b/src/openrct2/actions/TrackDesignAction.h @@ -24,7 +24,7 @@ namespace OpenRCT2::GameActions TrackDesignAction() = default; TrackDesignAction(const CoordsXYZD& location, const TrackDesign& td); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/TrackPlaceAction.h b/src/openrct2/actions/TrackPlaceAction.h index 6ac393b1b6..d74943670e 100644 --- a/src/openrct2/actions/TrackPlaceAction.h +++ b/src/openrct2/actions/TrackPlaceAction.h @@ -38,9 +38,9 @@ namespace OpenRCT2::GameActions RideId rideIndex, TrackElemType trackType, ride_type_t rideType, const CoordsXYZD& origin, int32_t brakeSpeed, int32_t colour, int32_t seatRotation, SelectedLiftAndInverted liftHillAndAlternativeState, bool fromTrackDesign); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; - uint16_t GetActionFlags() const override final; + uint16_t GetActionFlags() const final; void Serialise(DataSerialiser& stream) override; GameActions::Result Query() const override; diff --git a/src/openrct2/actions/TrackRemoveAction.h b/src/openrct2/actions/TrackRemoveAction.h index 6207dd14b5..c784bbbb87 100644 --- a/src/openrct2/actions/TrackRemoveAction.h +++ b/src/openrct2/actions/TrackRemoveAction.h @@ -24,9 +24,9 @@ namespace OpenRCT2::GameActions TrackRemoveAction() = default; TrackRemoveAction(TrackElemType trackType, int32_t sequence, const CoordsXYZD& origin); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; - uint16_t GetActionFlags() const override final; + uint16_t GetActionFlags() const final; void Serialise(DataSerialiser& stream) override; Result Query() const override; diff --git a/src/openrct2/actions/TrackSetBrakeSpeedAction.h b/src/openrct2/actions/TrackSetBrakeSpeedAction.h index 399737f783..473523e981 100644 --- a/src/openrct2/actions/TrackSetBrakeSpeedAction.h +++ b/src/openrct2/actions/TrackSetBrakeSpeedAction.h @@ -24,9 +24,9 @@ namespace OpenRCT2::GameActions TrackSetBrakeSpeedAction() = default; TrackSetBrakeSpeedAction(const CoordsXYZ& loc, OpenRCT2::TrackElemType trackType, uint8_t brakeSpeed); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; - uint16_t GetActionFlags() const override final; + uint16_t GetActionFlags() const final; void Serialise(DataSerialiser& stream) override; Result Query() const override; diff --git a/src/openrct2/actions/WallPlaceAction.h b/src/openrct2/actions/WallPlaceAction.h index 19a2ab1d4e..308cb76e07 100644 --- a/src/openrct2/actions/WallPlaceAction.h +++ b/src/openrct2/actions/WallPlaceAction.h @@ -44,9 +44,9 @@ namespace OpenRCT2::GameActions ObjectEntryIndex wallType, const CoordsXYZ& loc, uint8_t edge, int32_t primaryColour, int32_t secondaryColour, int32_t tertiaryColour); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; - uint16_t GetActionFlags() const override final; + uint16_t GetActionFlags() const final; void Serialise(DataSerialiser& stream) override; Result Query() const override; diff --git a/src/openrct2/actions/WallRemoveAction.h b/src/openrct2/actions/WallRemoveAction.h index 6ac00ca752..e101e114db 100644 --- a/src/openrct2/actions/WallRemoveAction.h +++ b/src/openrct2/actions/WallRemoveAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions WallRemoveAction() = default; WallRemoveAction(const CoordsXYZD& loc); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; void Serialise(DataSerialiser& stream) override; Result Query() const override; Result Execute() const override; diff --git a/src/openrct2/actions/WallSetColourAction.h b/src/openrct2/actions/WallSetColourAction.h index 89259d4137..e7750616f6 100644 --- a/src/openrct2/actions/WallSetColourAction.h +++ b/src/openrct2/actions/WallSetColourAction.h @@ -25,7 +25,7 @@ namespace OpenRCT2::GameActions WallSetColourAction() = default; WallSetColourAction(const CoordsXYZD& loc, int32_t primaryColour, int32_t secondaryColour, int32_t tertiaryColour); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/WaterLowerAction.h b/src/openrct2/actions/WaterLowerAction.h index 6820d602f8..a0aba9c33f 100644 --- a/src/openrct2/actions/WaterLowerAction.h +++ b/src/openrct2/actions/WaterLowerAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions WaterLowerAction() = default; WaterLowerAction(MapRange range); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/WaterRaiseAction.h b/src/openrct2/actions/WaterRaiseAction.h index 8382615348..c8f1a2d20d 100644 --- a/src/openrct2/actions/WaterRaiseAction.h +++ b/src/openrct2/actions/WaterRaiseAction.h @@ -22,7 +22,7 @@ namespace OpenRCT2::GameActions WaterRaiseAction() = default; WaterRaiseAction(MapRange range); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/actions/WaterSetHeightAction.h b/src/openrct2/actions/WaterSetHeightAction.h index af86074962..917ef28d43 100644 --- a/src/openrct2/actions/WaterSetHeightAction.h +++ b/src/openrct2/actions/WaterSetHeightAction.h @@ -23,7 +23,7 @@ namespace OpenRCT2::GameActions WaterSetHeightAction() = default; WaterSetHeightAction(const CoordsXY& coords, uint8_t height); - void AcceptParameters(GameActionParameterVisitor& visitor) override; + void AcceptParameters(GameActionParameterVisitor&) final; uint16_t GetActionFlags() const override; diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 37752df0fb..9e290c1604 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -746,7 +746,7 @@ template static void ConsoleSetVariableAction(InteractiveConsole& console, std::string var, TArgs&&... args) { auto action = TAction(std::forward(args)...); - action.SetCallback([&console, var](const GameAction*, const GameActions::Result* res) { + action.SetCallback([&console, var](const GameActions::GameAction*, const GameActions::Result* res) { if (res->Error != GameActions::Status::Ok) console.WriteLineError( String::stdFormat( @@ -803,75 +803,77 @@ static void ConsoleCommandSet(InteractiveConsole& console, const arguments_t& ar } else if (varName == "scenario_initial_cash" && InvalidArguments(&invalidArgs, int_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::InitialCash, + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::InitialCash, std::clamp(ToMoney64FromGBP(int_val[0]), 0.00_GBP, 1000000.00_GBP)); } else if (varName == "current_loan" && InvalidArguments(&invalidArgs, int_valid[0])) { auto amount = std::clamp( ToMoney64FromGBP(int_val[0]) - ToMoney64FromGBP(int_val[0] % 1000), 0.00_GBP, gameState.park.maxBankLoan); - ConsoleSetVariableAction(console, varName, ScenarioSetSetting::InitialLoan, amount); + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::InitialLoan, amount); } else if (varName == "max_loan" && InvalidArguments(&invalidArgs, int_valid[0])) { auto amount = std::clamp( ToMoney64FromGBP(int_val[0]) - ToMoney64FromGBP(int_val[0] % 1000), 0.00_GBP, 5000000.00_GBP); - ConsoleSetVariableAction(console, varName, ScenarioSetSetting::MaximumLoanSize, amount); + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::MaximumLoanSize, amount); } else if (varName == "guest_initial_cash" && InvalidArguments(&invalidArgs, double_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::AverageCashPerGuest, + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::AverageCashPerGuest, std::clamp(ToMoney64FromGBP(double_val[0]), 0.00_GBP, 1000.00_GBP)); } else if (varName == "guest_initial_happiness" && InvalidArguments(&invalidArgs, int_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::GuestInitialHappiness, + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::GuestInitialHappiness, Park::CalculateGuestInitialHappiness(static_cast(int_val[0]))); } else if (varName == "guest_initial_hunger" && InvalidArguments(&invalidArgs, int_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::GuestInitialHunger, + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::GuestInitialHunger, (std::clamp(int_val[0], 1, 84) * 255 / 100 - 255) * -1); } else if (varName == "guest_initial_thirst" && InvalidArguments(&invalidArgs, int_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::GuestInitialThirst, + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::GuestInitialThirst, (std::clamp(int_val[0], 1, 84) * 255 / 100 - 255) * -1); } else if (varName == "guest_prefer_less_intense_rides" && InvalidArguments(&invalidArgs, int_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::GuestsPreferLessIntenseRides, int_val[0]); + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::GuestsPreferLessIntenseRides, int_val[0]); } else if (varName == "guest_prefer_more_intense_rides" && InvalidArguments(&invalidArgs, int_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::GuestsPreferMoreIntenseRides, int_val[0]); + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::GuestsPreferMoreIntenseRides, int_val[0]); } else if (varName == "forbid_marketing_campaigns" && InvalidArguments(&invalidArgs, int_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::ForbidMarketingCampaigns, int_val[0]); + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::ForbidMarketingCampaigns, int_val[0]); } else if (varName == "forbid_landscape_changes" && InvalidArguments(&invalidArgs, int_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::ForbidLandscapeChanges, int_val[0]); + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::ForbidLandscapeChanges, int_val[0]); } else if (varName == "forbid_tree_removal" && InvalidArguments(&invalidArgs, int_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::ForbidTreeRemoval, int_val[0]); + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::ForbidTreeRemoval, int_val[0]); } else if (varName == "forbid_high_construction" && InvalidArguments(&invalidArgs, int_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::ForbidHighConstruction, int_val[0]); + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::ForbidHighConstruction, int_val[0]); } else if (varName == "pay_for_rides" && InvalidArguments(&invalidArgs, int_valid[0])) { @@ -884,13 +886,13 @@ static void ConsoleCommandSet(InteractiveConsole& console, const arguments_t& ar } else if (varName == "difficult_park_rating" && InvalidArguments(&invalidArgs, int_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::ParkRatingHigherDifficultyLevel, int_val[0]); + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::ParkRatingHigherDifficultyLevel, int_val[0]); } else if (varName == "difficult_guest_generation" && InvalidArguments(&invalidArgs, int_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::GuestGenerationHigherDifficultyLevel, int_val[0]); + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::GuestGenerationHigherDifficultyLevel, int_val[0]); } else if (varName == "park_open" && InvalidArguments(&invalidArgs, int_valid[0])) { @@ -899,14 +901,14 @@ static void ConsoleCommandSet(InteractiveConsole& console, const arguments_t& ar } else if (varName == "land_rights_cost" && InvalidArguments(&invalidArgs, double_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::CostToBuyLand, + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::CostToBuyLand, std::clamp(ToMoney64FromGBP(double_val[0]), 0.00_GBP, 200.00_GBP)); } else if (varName == "construction_rights_cost" && InvalidArguments(&invalidArgs, double_valid[0])) { - ConsoleSetVariableAction( - console, varName, ScenarioSetSetting::CostToBuyConstructionRights, + ConsoleSetVariableAction( + console, varName, GameActions::ScenarioSetSetting::CostToBuyConstructionRights, std::clamp(ToMoney64FromGBP(double_val[0]), 0.00_GBP, 200.00_GBP)); } else if (varName == "game_speed" && InvalidArguments(&invalidArgs, int_valid[0])) diff --git a/src/openrct2/network/Network.h b/src/openrct2/network/Network.h index af0b191983..8c1c17e7b0 100644 --- a/src/openrct2/network/Network.h +++ b/src/openrct2/network/Network.h @@ -25,15 +25,17 @@ constexpr const char* kNetworkLanBroadcastMsg = "openrct2.server.query"; constexpr const char* kMasterServerURL = "https://servers.openrct2.io"; constexpr uint16_t kMaxServerDescriptionLength = 256; -class GameAction; struct Peep; struct CoordsXYZ; + namespace OpenRCT2::GameActions { + class GameAction; enum class ModifyGroupType : uint8_t; enum class PermissionState : uint8_t; class Result; } // namespace OpenRCT2::GameActions + enum class NetworkPermission : uint32_t; void NetworkReconnect(); @@ -97,7 +99,7 @@ void NetworkSetPickupPeepOldX(uint8_t playerid, int32_t x); [[nodiscard]] bool NetworkIsServerPlayerInvisible(); void NetworkSendChat(const char* text, const std::vector& playerIds = {}); -void NetworkSendGameAction(const GameAction* action); +void NetworkSendGameAction(const OpenRCT2::GameActions::GameAction* action); void NetworkSendPassword(const std::string& password); void NetworkSetPassword(const char* password); diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index ad3eb0519d..aab577a8b2 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -112,8 +112,8 @@ static u8string NetworkGetKeysDirectory(); static u8string NetworkGetPrivateKeyPath(u8string_view playerName); static u8string NetworkGetPublicKeyPath(u8string_view playerName, u8string_view hash); -NetworkBase::NetworkBase(OpenRCT2::IContext& context) - : OpenRCT2::System(context) +NetworkBase::NetworkBase(IContext& context) + : System(context) { mode = NETWORK_MODE_NONE; status = NETWORK_STATUS_NONE; @@ -1496,7 +1496,7 @@ void NetworkBase::ServerSendMap(NetworkConnection* connection) std::vector NetworkBase::SaveForNetwork(const std::vector& objects) const { std::vector result; - auto ms = OpenRCT2::MemoryStream(); + auto ms = MemoryStream(); if (SaveMap(&ms, objects)) { result.resize(ms.GetLength()); @@ -1539,7 +1539,7 @@ void NetworkBase::ServerSendChat(const char* text, const std::vector& p } } -void NetworkBase::Client_Send_GAME_ACTION(const GameAction* action) +void NetworkBase::Client_Send_GAME_ACTION(const GameActions::GameAction* action) { NetworkPacket packet(NetworkCommand::GameAction); @@ -1547,7 +1547,7 @@ void NetworkBase::Client_Send_GAME_ACTION(const GameAction* action) networkId = ++_actionId; // I know its ugly, want basic functionality for now. - const_cast(action)->SetNetworkId(networkId); + const_cast(action)->SetNetworkId(networkId); if (action->GetCallback()) { _gameActionCallbacks.insert(std::make_pair(networkId, action->GetCallback())); @@ -1560,7 +1560,7 @@ void NetworkBase::Client_Send_GAME_ACTION(const GameAction* action) _serverConnection->QueuePacket(std::move(packet)); } -void NetworkBase::ServerSendGameAction(const GameAction* action) +void NetworkBase::ServerSendGameAction(const GameActions::GameAction* action) { NetworkPacket packet(NetworkCommand::GameAction); @@ -1823,7 +1823,7 @@ static bool ProcessPlayerAuthenticatePluginHooks( using namespace OpenRCT2::Scripting; auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine(); - if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::networkAuthenticate)) + if (hookEngine.HasSubscriptions(Scripting::HookType::networkAuthenticate)) { auto ctx = GetContext()->GetScriptEngine().GetContext(); @@ -1836,7 +1836,7 @@ static bool ProcessPlayerAuthenticatePluginHooks( auto e = eObj.Take(); // Call the subscriptions - hookEngine.Call(OpenRCT2::Scripting::HookType::networkAuthenticate, e, false); + hookEngine.Call(Scripting::HookType::networkAuthenticate, e, false); // Check if any hook has cancelled the join if (AsOrDefault(e["cancel"], false)) @@ -1854,7 +1854,7 @@ static void ProcessPlayerJoinedPluginHooks(uint8_t playerId) using namespace OpenRCT2::Scripting; auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine(); - if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::networkJoin)) + if (hookEngine.HasSubscriptions(Scripting::HookType::networkJoin)) { auto ctx = GetContext()->GetScriptEngine().GetContext(); @@ -1864,7 +1864,7 @@ static void ProcessPlayerJoinedPluginHooks(uint8_t playerId) auto e = eObj.Take(); // Call the subscriptions - hookEngine.Call(OpenRCT2::Scripting::HookType::networkJoin, e, false); + hookEngine.Call(Scripting::HookType::networkJoin, e, false); } #endif } @@ -1875,7 +1875,7 @@ static void ProcessPlayerLeftPluginHooks(uint8_t playerId) using namespace OpenRCT2::Scripting; auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine(); - if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::networkLeave)) + if (hookEngine.HasSubscriptions(Scripting::HookType::networkLeave)) { auto ctx = GetContext()->GetScriptEngine().GetContext(); @@ -1885,7 +1885,7 @@ static void ProcessPlayerLeftPluginHooks(uint8_t playerId) auto e = eObj.Take(); // Call the subscriptions - hookEngine.Call(OpenRCT2::Scripting::HookType::networkLeave, e, false); + hookEngine.Call(Scripting::HookType::networkLeave, e, false); } #endif } @@ -2900,7 +2900,7 @@ static bool ProcessChatMessagePluginHooks(uint8_t playerId, std::string& text) { #ifdef ENABLE_SCRIPTING auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine(); - if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::networkChat)) + if (hookEngine.HasSubscriptions(Scripting::HookType::networkChat)) { auto ctx = GetContext()->GetScriptEngine().GetContext(); @@ -2913,7 +2913,7 @@ static bool ProcessChatMessagePluginHooks(uint8_t playerId, std::string& text) auto e = DukValue::take_from_stack(ctx); // Call the subscriptions - hookEngine.Call(OpenRCT2::Scripting::HookType::networkChat, e, false); + hookEngine.Call(Scripting::HookType::networkChat, e, false); // Update text from object if subscriptions changed it if (e["message"].type() != DukValue::Type::STRING) @@ -2975,7 +2975,7 @@ void NetworkBase::Client_Handle_GAME_ACTION([[maybe_unused]] NetworkConnection& DataSerialiser ds(false, stream); - GameAction::Ptr action = GameActions::Create(actionType); + GameActions::GameAction::Ptr action = GameActions::Create(actionType); if (action == nullptr) { LOG_ERROR("Received unregistered game action type: 0x%08X", actionType); @@ -3029,7 +3029,7 @@ void NetworkBase::ServerHandleGameAction(NetworkConnection& connection, NetworkP } // Create and enqueue the action. - GameAction::Ptr ga = GameActions::Create(actionType); + GameActions::GameAction::Ptr ga = GameActions::Create(actionType); if (ga == nullptr) { LOG_ERROR( @@ -3272,97 +3272,97 @@ void NetworkBase::Client_Handle_GAMEINFO([[maybe_unused]] NetworkConnection& con void NetworkReconnect() { - OpenRCT2::GetContext()->GetNetwork().Reconnect(); + GetContext()->GetNetwork().Reconnect(); } void NetworkShutdownClient() { - OpenRCT2::GetContext()->GetNetwork().ServerClientDisconnected(); + GetContext()->GetNetwork().ServerClientDisconnected(); } int32_t NetworkBeginClient(const std::string& host, int32_t port) { - return OpenRCT2::GetContext()->GetNetwork().BeginClient(host, port); + return GetContext()->GetNetwork().BeginClient(host, port); } int32_t NetworkBeginServer(int32_t port, const std::string& address) { - return OpenRCT2::GetContext()->GetNetwork().BeginServer(port, address); + return GetContext()->GetNetwork().BeginServer(port, address); } void NetworkUpdate() { - OpenRCT2::GetContext()->GetNetwork().Update(); + GetContext()->GetNetwork().Update(); } void NetworkProcessPending() { - OpenRCT2::GetContext()->GetNetwork().ProcessPending(); + GetContext()->GetNetwork().ProcessPending(); } void NetworkFlush() { - OpenRCT2::GetContext()->GetNetwork().Flush(); + GetContext()->GetNetwork().Flush(); } int32_t NetworkGetMode() { - return OpenRCT2::GetContext()->GetNetwork().GetMode(); + return GetContext()->GetNetwork().GetMode(); } int32_t NetworkGetStatus() { - return OpenRCT2::GetContext()->GetNetwork().GetStatus(); + return GetContext()->GetNetwork().GetStatus(); } bool NetworkIsDesynchronised() { - return OpenRCT2::GetContext()->GetNetwork().IsDesynchronised(); + return GetContext()->GetNetwork().IsDesynchronised(); } bool NetworkCheckDesynchronisation() { - return OpenRCT2::GetContext()->GetNetwork().CheckDesynchronizaton(); + return GetContext()->GetNetwork().CheckDesynchronizaton(); } void NetworkRequestGamestateSnapshot() { - return OpenRCT2::GetContext()->GetNetwork().RequestStateSnapshot(); + return GetContext()->GetNetwork().RequestStateSnapshot(); } void NetworkSendTick() { - OpenRCT2::GetContext()->GetNetwork().ServerSendTick(); + GetContext()->GetNetwork().ServerSendTick(); } NetworkAuth NetworkGetAuthstatus() { - return OpenRCT2::GetContext()->GetNetwork().GetAuthStatus(); + return GetContext()->GetNetwork().GetAuthStatus(); } uint32_t NetworkGetServerTick() { - return OpenRCT2::GetContext()->GetNetwork().GetServerTick(); + return GetContext()->GetNetwork().GetServerTick(); } uint8_t NetworkGetCurrentPlayerId() { - return OpenRCT2::GetContext()->GetNetwork().GetPlayerID(); + return GetContext()->GetNetwork().GetPlayerID(); } int32_t NetworkGetNumPlayers() { - return OpenRCT2::GetContext()->GetNetwork().GetTotalNumPlayers(); + return GetContext()->GetNetwork().GetTotalNumPlayers(); } int32_t NetworkGetNumVisiblePlayers() { - return OpenRCT2::GetContext()->GetNetwork().GetNumVisiblePlayers(); + return GetContext()->GetNetwork().GetNumVisiblePlayers(); } const char* NetworkGetPlayerName(uint32_t index) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(index, network.player_list); return static_cast(network.player_list[index]->Name.c_str()); @@ -3370,7 +3370,7 @@ const char* NetworkGetPlayerName(uint32_t index) uint32_t NetworkGetPlayerFlags(uint32_t index) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(index, network.player_list); return network.player_list[index]->Flags; @@ -3378,7 +3378,7 @@ uint32_t NetworkGetPlayerFlags(uint32_t index) int32_t NetworkGetPlayerPing(uint32_t index) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(index, network.player_list); return network.player_list[index]->Ping; @@ -3386,7 +3386,7 @@ int32_t NetworkGetPlayerPing(uint32_t index) int32_t NetworkGetPlayerID(uint32_t index) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(index, network.player_list); return network.player_list[index]->Id; @@ -3394,7 +3394,7 @@ int32_t NetworkGetPlayerID(uint32_t index) money64 NetworkGetPlayerMoneySpent(uint32_t index) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(index, network.player_list); return network.player_list[index]->MoneySpent; @@ -3402,7 +3402,7 @@ money64 NetworkGetPlayerMoneySpent(uint32_t index) std::string NetworkGetPlayerIPAddress(uint32_t id) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); auto conn = network.GetPlayerConnection(id); if (conn != nullptr && conn->Socket != nullptr) { @@ -3413,7 +3413,7 @@ std::string NetworkGetPlayerIPAddress(uint32_t id) std::string NetworkGetPlayerPublicKeyHash(uint32_t id) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); auto player = network.GetPlayerByID(id); if (player != nullptr) { @@ -3424,7 +3424,7 @@ std::string NetworkGetPlayerPublicKeyHash(uint32_t id) void NetworkIncrementPlayerNumCommands(uint32_t playerIndex) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(playerIndex, network.player_list); network.player_list[playerIndex]->IncrementNumCommands(); @@ -3432,7 +3432,7 @@ void NetworkIncrementPlayerNumCommands(uint32_t playerIndex) void NetworkAddPlayerMoneySpent(uint32_t index, money64 cost) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(index, network.player_list); network.player_list[index]->AddMoneySpent(cost); @@ -3440,7 +3440,7 @@ void NetworkAddPlayerMoneySpent(uint32_t index, money64 cost) int32_t NetworkGetPlayerLastAction(uint32_t index, int32_t time) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(index, network.player_list); if (time && Platform::GetTicks() > network.player_list[index]->LastActionTime + time) @@ -3452,7 +3452,7 @@ int32_t NetworkGetPlayerLastAction(uint32_t index, int32_t time) void NetworkSetPlayerLastAction(uint32_t index, GameCommand command) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(index, network.player_list); network.player_list[index]->LastAction = static_cast(NetworkActions::FindCommand(command)); @@ -3461,15 +3461,15 @@ void NetworkSetPlayerLastAction(uint32_t index, GameCommand command) CoordsXYZ NetworkGetPlayerLastActionCoord(uint32_t index) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); - Guard::IndexInRange(index, OpenRCT2::GetContext()->GetNetwork().player_list); + auto& network = GetContext()->GetNetwork(); + Guard::IndexInRange(index, GetContext()->GetNetwork().player_list); return network.player_list[index]->LastActionCoord; } void NetworkSetPlayerLastActionCoord(uint32_t index, const CoordsXYZ& coord) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(index, network.player_list); if (index < network.player_list.size()) @@ -3480,15 +3480,15 @@ void NetworkSetPlayerLastActionCoord(uint32_t index, const CoordsXYZ& coord) uint32_t NetworkGetPlayerCommandsRan(uint32_t index) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); - Guard::IndexInRange(index, OpenRCT2::GetContext()->GetNetwork().player_list); + auto& network = GetContext()->GetNetwork(); + Guard::IndexInRange(index, GetContext()->GetNetwork().player_list); return network.player_list[index]->CommandsRan; } int32_t NetworkGetPlayerIndex(uint32_t id) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); auto it = network.GetPlayerIteratorByID(id); if (it == network.player_list.end()) { @@ -3499,7 +3499,7 @@ int32_t NetworkGetPlayerIndex(uint32_t id) uint8_t NetworkGetPlayerGroup(uint32_t index) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(index, network.player_list); return network.player_list[index]->Group; @@ -3507,7 +3507,7 @@ uint8_t NetworkGetPlayerGroup(uint32_t index) void NetworkSetPlayerGroup(uint32_t index, uint32_t groupindex) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(index, network.player_list); Guard::IndexInRange(groupindex, network.group_list); @@ -3516,7 +3516,7 @@ void NetworkSetPlayerGroup(uint32_t index, uint32_t groupindex) int32_t NetworkGetGroupIndex(uint8_t id) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); auto it = network.GetGroupIteratorByID(id); if (it == network.group_list.end()) { @@ -3527,7 +3527,7 @@ int32_t NetworkGetGroupIndex(uint8_t id) uint8_t NetworkGetGroupID(uint32_t index) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(index, network.group_list); return network.group_list[index]->Id; @@ -3535,13 +3535,13 @@ uint8_t NetworkGetGroupID(uint32_t index) int32_t NetworkGetNumGroups() { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); return static_cast(network.group_list.size()); } const char* NetworkGetGroupName(uint32_t index) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); return network.group_list[index]->GetName().c_str(); } @@ -3576,7 +3576,7 @@ void NetworkChatShowServerGreeting() GameActions::Result NetworkSetPlayerGroup( NetworkPlayerId_t actionPlayerId, NetworkPlayerId_t playerId, uint8_t groupId, bool isExecuting) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); NetworkPlayer* player = network.GetPlayerByID(playerId); NetworkGroup* fromgroup = network.GetGroupByID(actionPlayerId); @@ -3637,7 +3637,7 @@ GameActions::Result NetworkModifyGroups( NetworkPlayerId_t actionPlayerId, GameActions::ModifyGroupType type, uint8_t groupId, const std::string& name, uint32_t permissionIndex, GameActions::PermissionState permissionState, bool isExecuting) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); switch (type) { case GameActions::ModifyGroupType::AddGroup: @@ -3773,7 +3773,7 @@ GameActions::Result NetworkModifyGroups( GameActions::Result NetworkKickPlayer(NetworkPlayerId_t playerId, bool isExecuting) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); NetworkPlayer* player = network.GetPlayerByID(playerId); if (player == nullptr) { @@ -3804,7 +3804,7 @@ GameActions::Result NetworkKickPlayer(NetworkPlayerId_t playerId, bool isExecuti uint8_t NetworkGetDefaultGroup() { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); return network.GetDefaultGroup(); } @@ -3825,7 +3825,7 @@ StringId NetworkGetActionNameStringID(uint32_t index) int32_t NetworkCanPerformAction(uint32_t groupindex, NetworkPermission index) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(groupindex, network.group_list); return network.group_list[groupindex]->CanPerformAction(index); @@ -3833,7 +3833,7 @@ int32_t NetworkCanPerformAction(uint32_t groupindex, NetworkPermission index) int32_t NetworkCanPerformCommand(uint32_t groupindex, int32_t index) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); Guard::IndexInRange(groupindex, network.group_list); return network.group_list[groupindex]->CanPerformCommand(static_cast(index)); // TODO @@ -3841,7 +3841,7 @@ int32_t NetworkCanPerformCommand(uint32_t groupindex, int32_t index) void NetworkSetPickupPeep(uint8_t playerid, Peep* peep) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); if (network.GetMode() == NETWORK_MODE_NONE) { _pickup_peep = peep; @@ -3858,7 +3858,7 @@ void NetworkSetPickupPeep(uint8_t playerid, Peep* peep) Peep* NetworkGetPickupPeep(uint8_t playerid) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); if (network.GetMode() == NETWORK_MODE_NONE) { return _pickup_peep; @@ -3874,7 +3874,7 @@ Peep* NetworkGetPickupPeep(uint8_t playerid) void NetworkSetPickupPeepOldX(uint8_t playerid, int32_t x) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); if (network.GetMode() == NETWORK_MODE_NONE) { _pickup_peep_old_x = x; @@ -3891,7 +3891,7 @@ void NetworkSetPickupPeepOldX(uint8_t playerid, int32_t x) int32_t NetworkGetPickupPeepOldX(uint8_t playerid) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); if (network.GetMode() == NETWORK_MODE_NONE) { return _pickup_peep_old_x; @@ -3907,12 +3907,12 @@ int32_t NetworkGetPickupPeepOldX(uint8_t playerid) bool NetworkIsServerPlayerInvisible() { - return OpenRCT2::GetContext()->GetNetwork().IsServerPlayerInvisible; + return GetContext()->GetNetwork().IsServerPlayerInvisible; } int32_t NetworkGetCurrentPlayerGroupIndex() { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); NetworkPlayer* player = network.GetPlayerByID(network.GetPlayerID()); if (player != nullptr) { @@ -3923,7 +3923,7 @@ int32_t NetworkGetCurrentPlayerGroupIndex() void NetworkSendChat(const char* text, const std::vector& playerIds) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); if (network.GetMode() == NETWORK_MODE_CLIENT) { network.Client_Send_CHAT(text); @@ -3949,9 +3949,9 @@ void NetworkSendChat(const char* text, const std::vector& playerIds) } } -void NetworkSendGameAction(const GameAction* action) +void NetworkSendGameAction(const GameActions::GameAction* action) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); switch (network.GetMode()) { case NETWORK_MODE_SERVER: @@ -3965,7 +3965,7 @@ void NetworkSendGameAction(const GameAction* action) void NetworkSendPassword(const std::string& password) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); const auto keyPath = NetworkGetPrivateKeyPath(Config::Get().network.PlayerName); if (!File::Exists(keyPath)) { @@ -3994,19 +3994,19 @@ void NetworkSendPassword(const std::string& password) void NetworkSetPassword(const char* password) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); network.SetPassword(password); } void NetworkAppendChatLog(std::string_view text) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); network.AppendChatLog(text); } void NetworkAppendServerLog(const utf8* text) { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); network.AppendServerLog(text); } @@ -4029,32 +4029,32 @@ static u8string NetworkGetPublicKeyPath(u8string_view playerName, u8string_view u8string NetworkGetServerName() { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); return network.ServerName; } u8string NetworkGetServerDescription() { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); return network.ServerDescription; } u8string NetworkGetServerGreeting() { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); return network.ServerGreeting; } u8string NetworkGetServerProviderName() { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); return network.ServerProviderName; } u8string NetworkGetServerProviderEmail() { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); return network.ServerProviderEmail; } u8string NetworkGetServerProviderWebsite() { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); return network.ServerProviderWebsite; } @@ -4065,13 +4065,13 @@ std::string NetworkGetVersion() NetworkStats NetworkGetStats() { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); return network.GetStats(); } NetworkServerState NetworkGetServerState() { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); return network.GetServerState(); } @@ -4082,7 +4082,7 @@ bool NetworkGamestateSnapshotsEnabled() json_t NetworkGetServerInfoAsJson() { - auto& network = OpenRCT2::GetContext()->GetNetwork(); + auto& network = GetContext()->GetNetwork(); return network.GetServerInfoAsJson(); } #else @@ -4123,7 +4123,7 @@ bool NetworkCheckDesynchronisation() void NetworkRequestGamestateSnapshot() { } -void NetworkSendGameAction(const GameAction* action) +void NetworkSendGameAction(const GameActions::GameAction* action) { } void NetworkUpdate() diff --git a/src/openrct2/network/NetworkBase.h b/src/openrct2/network/NetworkBase.h index 20c8c4c6d8..625bb978a2 100644 --- a/src/openrct2/network/NetworkBase.h +++ b/src/openrct2/network/NetworkBase.h @@ -89,7 +89,7 @@ public: // Server void ServerSendToken(NetworkConnection& connection); void ServerSendMap(NetworkConnection* connection = nullptr); void ServerSendChat(const char* text, const std::vector& playerIds = {}); - void ServerSendGameAction(const GameAction* action); + void ServerSendGameAction(const OpenRCT2::GameActions::GameAction* action); void ServerSendTick(); void ServerSendPlayerInfo(int32_t playerId); void ServerSendPlayerList(); @@ -142,7 +142,7 @@ public: // Client void Client_Send_AUTH( const std::string& name, const std::string& password, const std::string& pubkey, const std::vector& signature); void Client_Send_CHAT(const char* text); - void Client_Send_GAME_ACTION(const GameAction* action); + void Client_Send_GAME_ACTION(const OpenRCT2::GameActions::GameAction* action); void Client_Send_PING(); void Client_Send_GAMEINFO(); void Client_Send_MAPREQUEST(const std::vector& objects); @@ -170,7 +170,7 @@ public: // Client void Client_Handle_GAMESTATE(NetworkConnection& connection, NetworkPacket& packet); std::vector _challenge; - std::map _gameActionCallbacks; + std::map _gameActionCallbacks; NetworkKey _key; NetworkUserManager _userManager; diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index 80cda484e7..55f4d2f365 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -897,7 +897,7 @@ static bool ride_modify_entrance_or_exit(const CoordsXYE& tileElement) auto rideEntranceExitRemove = GameActions::RideEntranceExitRemoveAction( { tileElement.x, tileElement.y }, rideIndex, stationIndex, entranceType == ENTRANCE_TYPE_RIDE_EXIT); - rideEntranceExitRemove.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + rideEntranceExitRemove.SetCallback([=](const GameActions::GameAction* ga, const GameActions::Result* result) { gRideEntranceExitPlaceType = entranceType; windowMgr->InvalidateByClass(WindowClass::RideConstruction); diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 8f52672869..230645c6ba 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -953,7 +953,7 @@ static GameActions::Result TrackDesignPlaceSceneryElementRemoveGhost( uint8_t sceneryRotation = (rotation + scenery.getRotation()) & kTileElementDirectionMask; const uint32_t flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST; - std::unique_ptr ga; + std::unique_ptr ga; switch (entryInfo->Type) { case ObjectType::smallScenery: diff --git a/src/openrct2/scripting/ScriptEngine.cpp b/src/openrct2/scripting/ScriptEngine.cpp index afae8a8ea2..aff46dee7e 100644 --- a/src/openrct2/scripting/ScriptEngine.cpp +++ b/src/openrct2/scripting/ScriptEngine.cpp @@ -1195,7 +1195,7 @@ ExpenditureType ScriptEngine::StringToExpenditureType(std::string_view expenditu return ExpenditureType::count; } -DukValue ScriptEngine::GameActionResultToDuk(const GameAction& action, const GameActions::Result& result) +DukValue ScriptEngine::GameActionResultToDuk(const GameActions::GameAction& action, const GameActions::Result& result) { DukStackFrame frame(_context); DukObject obj(_context); @@ -1298,7 +1298,7 @@ void ScriptEngine::RemoveCustomGameActions(const std::shared_ptr& plugin } } -class DukToGameActionParameterVisitor : public GameActionParameterVisitor +class DukToGameActionParameterVisitor : public GameActions::GameActionParameterVisitor { private: DukValue _dukValue; @@ -1325,7 +1325,7 @@ public: } }; -class DukFromGameActionParameterVisitor : public GameActionParameterVisitor +class DukFromGameActionParameterVisitor : public GameActions::GameActionParameterVisitor { private: DukObject& _dukObject; @@ -1451,7 +1451,7 @@ static std::string GetActionName(GameCommand commandId) return {}; } -static std::unique_ptr CreateGameActionFromActionId(const std::string& name) +static std::unique_ptr CreateGameActionFromActionId(const std::string& name) { auto result = ActionNameToType.find(name); if (result != ActionNameToType.end()) @@ -1461,7 +1461,7 @@ static std::unique_ptr CreateGameActionFromActionId(const std::strin return nullptr; } -void ScriptEngine::RunGameActionHooks(const GameAction& action, GameActions::Result& result, bool isExecute) +void ScriptEngine::RunGameActionHooks(const GameActions::GameAction& action, GameActions::Result& result, bool isExecute) { DukStackFrame frame(_context); @@ -1497,8 +1497,8 @@ void ScriptEngine::RunGameActionHooks(const GameAction& action, GameActions::Res DukObject args(_context); DukFromGameActionParameterVisitor visitor(args); - const_cast(action).AcceptParameters(visitor); - const_cast(action).AcceptFlags(visitor); + const_cast(action).AcceptParameters(visitor); + const_cast(action).AcceptFlags(visitor); obj.Set("args", args.Take()); } @@ -1530,7 +1530,7 @@ void ScriptEngine::RunGameActionHooks(const GameAction& action, GameActions::Res } } -std::unique_ptr ScriptEngine::CreateGameAction( +std::unique_ptr ScriptEngine::CreateGameAction( const std::string& actionid, const DukValue& args, const std::string& pluginName) { auto action = CreateGameActionFromActionId(actionid); diff --git a/src/openrct2/scripting/ScriptEngine.h b/src/openrct2/scripting/ScriptEngine.h index dcb2ae9a36..cd54c054e5 100644 --- a/src/openrct2/scripting/ScriptEngine.h +++ b/src/openrct2/scripting/ScriptEngine.h @@ -31,11 +31,12 @@ struct duk_hthread; typedef struct duk_hthread duk_context; -class GameAction; namespace OpenRCT2::GameActions { + class GameAction; class Result; -} +} // namespace OpenRCT2::GameActions + class FileWatcher; class InteractiveConsole; @@ -252,10 +253,10 @@ namespace OpenRCT2::Scripting const GameActions::CustomAction& action, bool isExecute); bool RegisterCustomAction( const std::shared_ptr& plugin, std::string_view action, const DukValue& query, const DukValue& execute); - void RunGameActionHooks(const GameAction& action, GameActions::Result& result, bool isExecute); - [[nodiscard]] std::unique_ptr CreateGameAction( + void RunGameActionHooks(const GameActions::GameAction& action, GameActions::Result& result, bool isExecute); + [[nodiscard]] std::unique_ptr CreateGameAction( const std::string& actionid, const DukValue& args, const std::string& pluginName); - [[nodiscard]] DukValue GameActionResultToDuk(const GameAction& action, const GameActions::Result& result); + [[nodiscard]] DukValue GameActionResultToDuk(const GameActions::GameAction& action, const GameActions::Result& result); void SaveSharedStorage(); diff --git a/src/openrct2/scripting/bindings/game/ScContext.hpp b/src/openrct2/scripting/bindings/game/ScContext.hpp index d5f8ddca86..4fab734849 100644 --- a/src/openrct2/scripting/bindings/game/ScContext.hpp +++ b/src/openrct2/scripting/bindings/game/ScContext.hpp @@ -334,7 +334,8 @@ namespace OpenRCT2::Scripting if (isExecute) { action->SetCallback( - [this, plugin, callback](const GameAction* act, const GameActions::Result* res) -> void { + [this, plugin, + callback](const GameActions::GameAction* act, const GameActions::Result* res) -> void { HandleGameActionResult(plugin, *act, *res, callback); }); GameActions::Execute(action.get()); @@ -357,7 +358,7 @@ namespace OpenRCT2::Scripting } void HandleGameActionResult( - const std::shared_ptr& plugin, const GameAction& action, const GameActions::Result& res, + const std::shared_ptr& plugin, const GameActions::GameAction& action, const GameActions::Result& res, const DukValue& callback) { if (callback.is_function())