forked from rosebudai/OpenRCT2-Web
Move ClearAction, GameAction, ScenarioSetSettingAction into GameActions (#25045)
This commit is contained in:
1 parent
ffc7eaf97e
commit
abe58f6439
110 files changed
+1216
-1188
No files matched your search
@@ -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<RideId>();
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<uint8_t>(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);
|
||||
}
|
||||
|
||||
@@ -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<FootpathWindow*>(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<FootpathWindow*>(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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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<GameActions::BannerPlaceActionResult>();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<Staff>(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<Staff>(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
|
||||
|
||||
@@ -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<RideId>();
|
||||
@@ -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);
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
using namespace OpenRCT2::GameActions;
|
||||
|
||||
struct ReplayCommand
|
||||
{
|
||||
uint32_t tick = 0;
|
||||
|
||||
@@ -13,7 +13,10 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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<GameCommand::ClearScenery>
|
||||
{
|
||||
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<GameCommand::ClearScenery>
|
||||
{
|
||||
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
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
+198
-204
@@ -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<typename T>
|
||||
void Visit(std::string_view name, T& param)
|
||||
{
|
||||
static_assert(std::is_arithmetic_v<T> || std::is_enum_v<T>, "Not an arithmetic type");
|
||||
auto value = static_cast<int32_t>(param);
|
||||
Visit(name, value);
|
||||
param = static_cast<T>(value);
|
||||
}
|
||||
|
||||
template<typename T, T TNull, typename TTag>
|
||||
void Visit(std::string_view name, TIdentifier<T, TNull, TTag>& param)
|
||||
{
|
||||
auto value = param.ToUnderlying();
|
||||
Visit(name, value);
|
||||
param = TIdentifier<T, TNull, TTag>::FromUnderlying(value);
|
||||
}
|
||||
|
||||
template<typename T, size_t _TypeID>
|
||||
void Visit(std::string_view name, NetworkObjectId<T, _TypeID>& param)
|
||||
{
|
||||
Visit(name, param.id);
|
||||
}
|
||||
};
|
||||
|
||||
class GameAction
|
||||
{
|
||||
public:
|
||||
using Ptr = std::unique_ptr<GameAction>;
|
||||
using Callback_t = std::function<void(const class GameAction*, const OpenRCT2::GameActions::Result*)>;
|
||||
|
||||
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<typename T>
|
||||
void Visit(std::string_view name, T& param)
|
||||
{
|
||||
static_assert(std::is_arithmetic_v<T> || std::is_enum_v<T>, "Not an arithmetic type");
|
||||
auto value = static_cast<int32_t>(param);
|
||||
Visit(name, value);
|
||||
param = static_cast<T>(value);
|
||||
}
|
||||
|
||||
template<typename T, T TNull, typename TTag>
|
||||
void Visit(std::string_view name, TIdentifier<T, TNull, TTag>& param)
|
||||
{
|
||||
auto value = param.ToUnderlying();
|
||||
Visit(name, value);
|
||||
param = TIdentifier<T, TNull, TTag>::FromUnderlying(value);
|
||||
}
|
||||
|
||||
template<typename T, size_t _TypeID>
|
||||
void Visit(std::string_view name, NetworkObjectId<T, _TypeID>& param)
|
||||
{
|
||||
Visit(name, param.id);
|
||||
}
|
||||
};
|
||||
|
||||
class GameAction
|
||||
{
|
||||
return _flags;
|
||||
}
|
||||
public:
|
||||
using Ptr = std::unique_ptr<GameAction>;
|
||||
using Callback_t = std::function<void(const class GameAction*, const OpenRCT2::GameActions::Result*)>;
|
||||
|
||||
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<GameAction&>(*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<GameAction&>(*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<GameCommand TId>
|
||||
struct GameActionNameQuery
|
||||
{
|
||||
};
|
||||
|
||||
template<GameCommand TType>
|
||||
struct GameActionBase : GameAction
|
||||
{
|
||||
public:
|
||||
static constexpr GameCommand kType = TType;
|
||||
|
||||
GameActionBase()
|
||||
: GameAction(kType)
|
||||
template<GameCommand TId>
|
||||
struct GameActionNameQuery
|
||||
{
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<GameCommand TType>
|
||||
struct GameActionBase : GameAction
|
||||
{
|
||||
public:
|
||||
static constexpr GameCommand kType = TType;
|
||||
|
||||
GameActionBase()
|
||||
: GameAction(kType)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
using GameActionFactory = GameAction* (*)();
|
||||
|
||||
bool IsValidId(uint32_t id);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRCT2::GameActions
|
||||
ModifyGroupType type, uint8_t groupId = std::numeric_limits<uint8_t>::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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<money64>(_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<money64>(_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<money64>(_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<money64>(_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<uint8_t>(_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<money64>(_value, 0.00_GBP, 1000.00_GBP);
|
||||
break;
|
||||
case ScenarioSetSetting::GuestInitialHappiness:
|
||||
gameState.scenarioOptions.guestInitialHappiness = std::clamp<uint8_t>(_value, 40, 250);
|
||||
break;
|
||||
case ScenarioSetSetting::GuestInitialHunger:
|
||||
gameState.scenarioOptions.guestInitialHunger = std::clamp<uint8_t>(_value, 40, 250);
|
||||
break;
|
||||
case ScenarioSetSetting::GuestInitialThirst:
|
||||
gameState.scenarioOptions.guestInitialThirst = std::clamp<uint8_t>(_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<money64>(_value, 5.00_GBP, 200.00_GBP);
|
||||
break;
|
||||
case ScenarioSetSetting::CostToBuyConstructionRights:
|
||||
gameState.scenarioOptions.constructionRightsPrice = std::clamp<money64>(_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<money64>(_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<money64>(_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<uint8_t>(_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<money64>(_value, 0.00_GBP, 1000.00_GBP);
|
||||
break;
|
||||
case ScenarioSetSetting::GuestInitialHappiness:
|
||||
gameState.scenarioOptions.guestInitialHappiness = std::clamp<uint8_t>(_value, 40, 250);
|
||||
break;
|
||||
case ScenarioSetSetting::GuestInitialHunger:
|
||||
gameState.scenarioOptions.guestInitialHunger = std::clamp<uint8_t>(_value, 40, 250);
|
||||
break;
|
||||
case ScenarioSetSetting::GuestInitialThirst:
|
||||
gameState.scenarioOptions.guestInitialThirst = std::clamp<uint8_t>(_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<money64>(_value, 5.00_GBP, 200.00_GBP);
|
||||
break;
|
||||
case ScenarioSetSetting::CostToBuyConstructionRights:
|
||||
gameState.scenarioOptions.constructionRightsPrice = std::clamp<money64>(_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<money64>(_value, 0.00_GBP, kMaxEntranceFee);
|
||||
windowMgr->InvalidateByClass(WindowClass::ParkInformation);
|
||||
windowMgr->InvalidateByClass(WindowClass::Ride);
|
||||
}
|
||||
break;
|
||||
case ScenarioSetSetting::ParkChargeEntryFee:
|
||||
gameState.park.entranceFee = std::clamp<money64>(_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
|
||||
@@ -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<GameCommand::EditScenarioOptions>
|
||||
{
|
||||
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<GameCommand::EditScenarioOptions>
|
||||
{
|
||||
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
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Loaded 100 of 110 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user