From aa35ec07cdbb63237bad91c487c5fe85dcadab37 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Fri, 22 Aug 2025 15:57:33 +0200 Subject: [PATCH 1/4] Introduce Scenario::Options struct; move cash and guest options --- .../windows/EditorScenarioOptions.cpp | 51 ++++++++++--------- src/openrct2/Editor.cpp | 40 +++++++-------- src/openrct2/GameState.h | 20 ++++++-- .../actions/ScenarioSetSettingAction.cpp | 12 ++--- src/openrct2/audio/Audio.h | 1 - src/openrct2/entity/Guest.cpp | 14 ++--- src/openrct2/interface/InteractiveConsole.cpp | 20 ++++---- src/openrct2/management/Finance.cpp | 6 +-- src/openrct2/park/ParkFile.cpp | 12 ++--- src/openrct2/rct1/S4Importer.cpp | 10 ++-- src/openrct2/rct2/S6Importer.cpp | 10 ++-- src/openrct2/scenario/Scenario.cpp | 6 +-- .../scripting/bindings/world/ScPark.cpp | 8 +-- src/openrct2/world/Park.cpp | 8 +-- 14 files changed, 115 insertions(+), 103 deletions(-) diff --git a/src/openrct2-ui/windows/EditorScenarioOptions.cpp b/src/openrct2-ui/windows/EditorScenarioOptions.cpp index 0709ef3d43..65545a5359 100644 --- a/src/openrct2-ui/windows/EditorScenarioOptions.cpp +++ b/src/openrct2-ui/windows/EditorScenarioOptions.cpp @@ -1408,10 +1408,10 @@ namespace OpenRCT2::Ui::Windows switch (widgetIndex) { case WIDX_INITIAL_CASH_INCREASE: - if (gameState.initialCash < 1000000.00_GBP) + if (gameState.scenarioOptions.initialCash < 1000000.00_GBP) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::InitialCash, gameState.initialCash + 500.00_GBP); + ScenarioSetSetting::InitialCash, gameState.scenarioOptions.initialCash + 500.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1421,10 +1421,10 @@ namespace OpenRCT2::Ui::Windows Invalidate(); break; case WIDX_INITIAL_CASH_DECREASE: - if (gameState.initialCash > 0.00_GBP) + if (gameState.scenarioOptions.initialCash > 0.00_GBP) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::InitialCash, gameState.initialCash - 500.00_GBP); + ScenarioSetSetting::InitialCash, gameState.scenarioOptions.initialCash - 500.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1686,7 +1686,7 @@ namespace OpenRCT2::Ui::Windows { screenCoords = windowPos + ScreenCoordsXY{ initialCashWidget.left + 1, initialCashWidget.top }; auto ft = Formatter(); - ft.Add(getGameState().initialCash); + ft.Add(getGameState().scenarioOptions.initialCash); auto colour = !IsWidgetDisabled(WIDX_INITIAL_CASH) ? wColour2 : wColour2.withFlag(ColourFlag::inset, true); DrawTextBasic(rt, screenCoords, STR_CURRENCY_FORMAT_LABEL, ft, colour); } @@ -1767,14 +1767,15 @@ namespace OpenRCT2::Ui::Windows void GuestsMouseDown(WidgetIndex widgetIndex) { auto& gameState = getGameState(); + auto& scenarioOptions = gameState.scenarioOptions; switch (widgetIndex) { case WIDX_CASH_PER_GUEST_INCREASE: - if (gameState.guestInitialCash < 1000.00_GBP) + if (scenarioOptions.guestInitialCash < 1000.00_GBP) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::AverageCashPerGuest, gameState.guestInitialCash + 1.00_GBP); + ScenarioSetSetting::AverageCashPerGuest, scenarioOptions.guestInitialCash + 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1784,10 +1785,10 @@ namespace OpenRCT2::Ui::Windows Invalidate(); break; case WIDX_CASH_PER_GUEST_DECREASE: - if (gameState.guestInitialCash > 0.00_GBP) + if (scenarioOptions.guestInitialCash > 0.00_GBP) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::AverageCashPerGuest, gameState.guestInitialCash - 1.00_GBP); + ScenarioSetSetting::AverageCashPerGuest, scenarioOptions.guestInitialCash - 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -1797,10 +1798,10 @@ namespace OpenRCT2::Ui::Windows Invalidate(); break; case WIDX_GUEST_INITIAL_HAPPINESS_INCREASE: - if (gameState.guestInitialHappiness < 250) + if (scenarioOptions.guestInitialHappiness < 250) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestInitialHappiness, gameState.guestInitialHappiness + 4); + ScenarioSetSetting::GuestInitialHappiness, scenarioOptions.guestInitialHappiness + 4); GameActions::Execute(&scenarioSetSetting); } else @@ -1810,10 +1811,10 @@ namespace OpenRCT2::Ui::Windows Invalidate(); break; case WIDX_GUEST_INITIAL_HAPPINESS_DECREASE: - if (gameState.guestInitialHappiness > 40) + if (scenarioOptions.guestInitialHappiness > 40) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestInitialHappiness, gameState.guestInitialHappiness - 4); + ScenarioSetSetting::GuestInitialHappiness, scenarioOptions.guestInitialHappiness - 4); GameActions::Execute(&scenarioSetSetting); } else @@ -1823,10 +1824,10 @@ namespace OpenRCT2::Ui::Windows Invalidate(); break; case WIDX_GUEST_INITIAL_HUNGER_INCREASE: - if (gameState.guestInitialHunger > 40) + if (scenarioOptions.guestInitialHunger > 40) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestInitialHunger, gameState.guestInitialHunger - 4); + ScenarioSetSetting::GuestInitialHunger, scenarioOptions.guestInitialHunger - 4); GameActions::Execute(&scenarioSetSetting); } else @@ -1836,10 +1837,10 @@ namespace OpenRCT2::Ui::Windows Invalidate(); break; case WIDX_GUEST_INITIAL_HUNGER_DECREASE: - if (gameState.guestInitialHunger < 250) + if (scenarioOptions.guestInitialHunger < 250) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestInitialHunger, gameState.guestInitialHunger + 4); + ScenarioSetSetting::GuestInitialHunger, scenarioOptions.guestInitialHunger + 4); GameActions::Execute(&scenarioSetSetting); } else @@ -1849,10 +1850,10 @@ namespace OpenRCT2::Ui::Windows Invalidate(); break; case WIDX_GUEST_INITIAL_THIRST_INCREASE: - if (gameState.guestInitialThirst > 40) + if (scenarioOptions.guestInitialThirst > 40) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestInitialThirst, gameState.guestInitialThirst - 4); + ScenarioSetSetting::GuestInitialThirst, scenarioOptions.guestInitialThirst - 4); GameActions::Execute(&scenarioSetSetting); } else @@ -1862,10 +1863,10 @@ namespace OpenRCT2::Ui::Windows Invalidate(); break; case WIDX_GUEST_INITIAL_THIRST_DECREASE: - if (gameState.guestInitialThirst < 250) + if (scenarioOptions.guestInitialThirst < 250) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::GuestInitialThirst, gameState.guestInitialThirst + 4); + ScenarioSetSetting::GuestInitialThirst, scenarioOptions.guestInitialThirst + 4); GameActions::Execute(&scenarioSetSetting); } else @@ -1975,7 +1976,7 @@ namespace OpenRCT2::Ui::Windows // Cash per guest value screenCoords = windowPos + ScreenCoordsXY{ cashPerGuestWidget.left + 1, cashPerGuestWidget.top }; auto ft = Formatter(); - ft.Add(gameState.guestInitialCash); + ft.Add(gameState.scenarioOptions.guestInitialCash); auto colour = !IsWidgetDisabled(WIDX_CASH_PER_GUEST) ? wColour2 : wColour2.withFlag(ColourFlag::inset, true); DrawTextBasic(rt, screenCoords, STR_CURRENCY_FORMAT_LABEL, ft, colour); } @@ -1986,21 +1987,21 @@ namespace OpenRCT2::Ui::Windows const auto& initialHappinessWidget = widgets[WIDX_GUEST_INITIAL_HAPPINESS]; screenCoords = windowPos + ScreenCoordsXY{ initialHappinessWidget.left + 1, initialHappinessWidget.top }; auto ft = Formatter(); - ft.Add((gameState.guestInitialHappiness * 100) / 255); + ft.Add((gameState.scenarioOptions.guestInitialHappiness * 100) / 255); DrawTextBasic(rt, screenCoords, STR_PERCENT_FORMAT_LABEL, ft, colour); // Guest initial hunger value const auto& initialHungerWidget = widgets[WIDX_GUEST_INITIAL_HUNGER]; screenCoords = windowPos + ScreenCoordsXY{ initialHungerWidget.left + 1, initialHungerWidget.top }; ft = Formatter(); - ft.Add(((255 - gameState.guestInitialHunger) * 100) / 255); + ft.Add(((255 - gameState.scenarioOptions.guestInitialHunger) * 100) / 255); DrawTextBasic(rt, screenCoords, STR_PERCENT_FORMAT_LABEL, ft, colour); // Guest initial thirst value const auto& initialThirstWidget = widgets[WIDX_GUEST_INITIAL_THIRST]; screenCoords = windowPos + ScreenCoordsXY{ initialThirstWidget.left + 1, initialThirstWidget.top }; ft = Formatter(); - ft.Add(((255 - gameState.guestInitialThirst) * 100) / 255); + ft.Add(((255 - gameState.scenarioOptions.guestInitialThirst) * 100) / 255); DrawTextBasic(rt, screenCoords, STR_PERCENT_FORMAT_LABEL, ft, colour); // Guests' intensity value diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 5e5f17bb4a..231275ef07 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -298,40 +298,40 @@ namespace OpenRCT2::Editor staff->SetName({}); } - auto& gameState = getGameState(); - ResetAllEntities(); UpdateConsolidatedPatrolAreas(); - gameState.park.numGuestsInPark = 0; - gameState.park.numGuestsHeadingForPark = 0; - gameState.park.numGuestsInParkLastWeek = 0; - gameState.park.guestChangeModifier = 0; + + auto& gameState = getGameState(); + auto& park = gameState.park; + auto& scenarioOptions = gameState.scenarioOptions; + + park.numGuestsInPark = 0; + park.numGuestsHeadingForPark = 0; + park.numGuestsInParkLastWeek = 0; + park.guestChangeModifier = 0; + if (fromSave) { - gameState.park.flags |= PARK_FLAGS_NO_MONEY; + park.flags |= PARK_FLAGS_NO_MONEY; - if (gameState.park.entranceFee == 0) + if (park.entranceFee == 0) { - gameState.park.flags |= PARK_FLAGS_PARK_FREE_ENTRY; + park.flags |= PARK_FLAGS_PARK_FREE_ENTRY; } else { - gameState.park.flags &= ~PARK_FLAGS_PARK_FREE_ENTRY; + park.flags &= ~PARK_FLAGS_PARK_FREE_ENTRY; } - gameState.park.flags &= ~PARK_FLAGS_SPRITES_INITIALISED; + park.flags &= ~PARK_FLAGS_SPRITES_INITIALISED; - gameState.guestInitialCash = std::clamp(gameState.guestInitialCash, 10.00_GBP, kMaxEntranceFee); - - gameState.initialCash = std::min(gameState.initialCash, 100000); + scenarioOptions.guestInitialCash = std::clamp(scenarioOptions.guestInitialCash, 10.00_GBP, kMaxEntranceFee); + scenarioOptions.initialCash = std::min(scenarioOptions.initialCash, 100000); FinanceResetCashToInitial(); - gameState.park.bankLoan = std::clamp(gameState.park.bankLoan, 0.00_GBP, 5000000.00_GBP); - - gameState.park.maxBankLoan = std::clamp(gameState.park.maxBankLoan, 0.00_GBP, 5000000.00_GBP); - - gameState.park.bankLoanInterestRate = std::clamp( - gameState.park.bankLoanInterestRate, 5, kMaxBankLoanInterestRate); + park.bankLoan = std::clamp(park.bankLoan, 0.00_GBP, 5000000.00_GBP); + park.maxBankLoan = std::clamp(park.maxBankLoan, 0.00_GBP, 5000000.00_GBP); + park.bankLoanInterestRate = std::clamp(park.bankLoanInterestRate, 5, kMaxBankLoanInterestRate); } ClimateReset(); diff --git a/src/openrct2/GameState.h b/src/openrct2/GameState.h index c0c2e0cb5d..773fadf284 100644 --- a/src/openrct2/GameState.h +++ b/src/openrct2/GameState.h @@ -30,11 +30,26 @@ #include #include +namespace OpenRCT2::Scenario +{ + struct Options + { + money64 initialCash; + + money64 guestInitialCash; + uint8_t guestInitialHappiness; + uint8_t guestInitialHunger; + uint8_t guestInitialThirst; + }; +} // namespace OpenRCT2::Scenario + namespace OpenRCT2 { + struct GameState_t { Park::ParkData park{}; + Scenario::Options scenarioOptions; std::string pluginStorage; uint32_t currentTicks{}; Date date; @@ -43,11 +58,6 @@ namespace OpenRCT2 WeatherState weatherNext; uint16_t weatherUpdateTimer; - money64 initialCash; - money64 guestInitialCash; - uint8_t guestInitialHappiness; - uint8_t guestInitialHunger; - uint8_t guestInitialThirst; uint32_t nextGuestNumber; Objective scenarioObjective; diff --git a/src/openrct2/actions/ScenarioSetSettingAction.cpp b/src/openrct2/actions/ScenarioSetSettingAction.cpp index 4f251c4b6d..699df23200 100644 --- a/src/openrct2/actions/ScenarioSetSettingAction.cpp +++ b/src/openrct2/actions/ScenarioSetSettingAction.cpp @@ -83,8 +83,8 @@ GameActions::Result ScenarioSetSettingAction::Execute() const } break; case ScenarioSetSetting::InitialCash: - gameState.initialCash = std::clamp(_value, 0.00_GBP, 1000000.00_GBP); - gameState.park.cash = gameState.initialCash; + gameState.scenarioOptions.initialCash = std::clamp(_value, 0.00_GBP, 1000000.00_GBP); + gameState.park.cash = gameState.scenarioOptions.initialCash; windowMgr->InvalidateByClass(WindowClass::Finances); windowMgr->InvalidateByClass(WindowClass::BottomToolbar); break; @@ -113,16 +113,16 @@ GameActions::Result ScenarioSetSettingAction::Execute() const } break; case ScenarioSetSetting::AverageCashPerGuest: - gameState.guestInitialCash = std::clamp(_value, 0.00_GBP, 1000.00_GBP); + gameState.scenarioOptions.guestInitialCash = std::clamp(_value, 0.00_GBP, 1000.00_GBP); break; case ScenarioSetSetting::GuestInitialHappiness: - gameState.guestInitialHappiness = std::clamp(_value, 40, 250); + gameState.scenarioOptions.guestInitialHappiness = std::clamp(_value, 40, 250); break; case ScenarioSetSetting::GuestInitialHunger: - gameState.guestInitialHunger = std::clamp(_value, 40, 250); + gameState.scenarioOptions.guestInitialHunger = std::clamp(_value, 40, 250); break; case ScenarioSetSetting::GuestInitialThirst: - gameState.guestInitialThirst = std::clamp(_value, 40, 250); + gameState.scenarioOptions.guestInitialThirst = std::clamp(_value, 40, 250); break; case ScenarioSetSetting::GuestsPreferLessIntenseRides: if (_value != 0) diff --git a/src/openrct2/audio/Audio.h b/src/openrct2/audio/Audio.h index 3edac36578..dfcaf54521 100644 --- a/src/openrct2/audio/Audio.h +++ b/src/openrct2/audio/Audio.h @@ -18,7 +18,6 @@ #include #include -class AudioObject; struct CoordsXYZ; namespace OpenRCT2::Audio diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 9883979d2b..873cc8cae9 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -7338,10 +7338,10 @@ Guest* Guest::Generate(const CoordsXYZ& coords) /* Scenario editor limits initial guest happiness to between 37..253. * To be on the safe side, assume the value could have been hacked * to any value 0..255. */ - peep->Happiness = gameState.guestInitialHappiness; + peep->Happiness = gameState.scenarioOptions.guestInitialHappiness; /* Assume a default initial happiness of 0 is wrong and set * to 128 (50%) instead. */ - if (gameState.guestInitialHappiness == 0) + if (gameState.scenarioOptions.guestInitialHappiness == 0) peep->Happiness = 128; /* Initial value will vary by -15..16 */ int8_t happinessDelta = (ScenarioRand() & 0x1F) - 15; @@ -7354,7 +7354,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords) /* Scenario editor limits initial guest hunger to between 37..253. * To be on the safe side, assume the value could have been hacked * to any value 0..255. */ - peep->Hunger = gameState.guestInitialHunger; + peep->Hunger = gameState.scenarioOptions.guestInitialHunger; /* Initial value will vary by -15..16 */ int8_t hungerDelta = (ScenarioRand() & 0x1F) - 15; /* Adjust by the delta, clamping at min=0 and max=255. */ @@ -7363,7 +7363,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords) /* Scenario editor limits initial guest thirst to between 37..253. * To be on the safe side, assume the value could have been hacked * to any value 0..255. */ - peep->Thirst = gameState.guestInitialThirst; + peep->Thirst = gameState.scenarioOptions.guestInitialThirst; /* Initial value will vary by -15..16 */ int8_t thirstDelta = (ScenarioRand() & 0x1F) - 15; /* Adjust by the delta, clamping at min=0 and max=255. */ @@ -7376,11 +7376,11 @@ Guest* Guest::Generate(const CoordsXYZ& coords) peep->PeepId = gameState.nextGuestNumber++; peep->Name = nullptr; - money64 cash = (static_cast(ScenarioRand() & 0x3) * 100) - 100 + gameState.guestInitialCash; + money64 cash = (static_cast(ScenarioRand() & 0x3) * 100) - 100 + gameState.scenarioOptions.guestInitialCash; if (cash < 0) cash = 0; - if (gameState.guestInitialCash == 0.00_GBP) + if (gameState.scenarioOptions.guestInitialCash == 0.00_GBP) { cash = 500; } @@ -7390,7 +7390,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords) cash = 0; } - if (gameState.guestInitialCash == kMoney64Undefined) + if (gameState.scenarioOptions.guestInitialCash == kMoney64Undefined) { cash = 0; } diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index f788144554..b3fc3973f1 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -565,7 +565,7 @@ static void ConsoleCommandGet(InteractiveConsole& console, const arguments_t& ar } else if (argv[0] == "scenario_initial_cash") { - console.WriteLine(FormatString("scenario_initial_cash {CURRENCY2DP}", gameState.initialCash)); + console.WriteLine(FormatString("scenario_initial_cash {CURRENCY2DP}", gameState.scenarioOptions.initialCash)); } else if (argv[0] == "current_loan") { @@ -577,7 +577,7 @@ static void ConsoleCommandGet(InteractiveConsole& console, const arguments_t& ar } else if (argv[0] == "guest_initial_cash") { - console.WriteLine(FormatString("guest_initial_cash {CURRENCY2DP}", gameState.guestInitialCash)); + console.WriteLine(FormatString("guest_initial_cash {CURRENCY2DP}", gameState.scenarioOptions.guestInitialCash)); } else if (argv[0] == "land_rights_cost") { @@ -589,16 +589,18 @@ static void ConsoleCommandGet(InteractiveConsole& console, const arguments_t& ar } else if (argv[0] == "guest_initial_happiness") { - uint32_t current_happiness = gameState.guestInitialHappiness; + uint32_t current_happiness = gameState.scenarioOptions.guestInitialHappiness; for (int32_t i = 15; i <= 99; i++) { if (i == 99) { - console.WriteFormatLine("guest_initial_happiness %d%% (%d)", 15, gameState.guestInitialHappiness); + console.WriteFormatLine( + "guest_initial_happiness %d%% (%d)", 15, gameState.scenarioOptions.guestInitialHappiness); } else if (current_happiness == Park::CalculateGuestInitialHappiness(i)) { - console.WriteFormatLine("guest_initial_happiness %d%% (%d)", i, gameState.guestInitialHappiness); + console.WriteFormatLine( + "guest_initial_happiness %d%% (%d)", i, gameState.scenarioOptions.guestInitialHappiness); break; } } @@ -606,14 +608,14 @@ static void ConsoleCommandGet(InteractiveConsole& console, const arguments_t& ar else if (argv[0] == "guest_initial_hunger") { console.WriteFormatLine( - "guest_initial_hunger %d%% (%d)", ((255 - gameState.guestInitialHunger) * 100) / 255, - gameState.guestInitialHunger); + "guest_initial_hunger %d%% (%d)", ((255 - gameState.scenarioOptions.guestInitialHunger) * 100) / 255, + gameState.scenarioOptions.guestInitialHunger); } else if (argv[0] == "guest_initial_thirst") { console.WriteFormatLine( - "guest_initial_thirst %d%% (%d)", ((255 - gameState.guestInitialThirst) * 100) / 255, - gameState.guestInitialThirst); + "guest_initial_thirst %d%% (%d)", ((255 - gameState.scenarioOptions.guestInitialThirst) * 100) / 255, + gameState.scenarioOptions.guestInitialThirst); } else if (argv[0] == "guest_prefer_less_intense_rides") { diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index 20c23cd0ae..cdc084f73d 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -235,7 +235,7 @@ void FinanceInit() gameState.park.weeklyProfitAverageDividend = 0; gameState.park.weeklyProfitAverageDivisor = 0; - gameState.initialCash = 10000.00_GBP; // Cheat detection + gameState.scenarioOptions.initialCash = 10000.00_GBP; // Cheat detection gameState.park.cash = 10000.00_GBP; gameState.park.bankLoan = 10000.00_GBP; @@ -306,7 +306,7 @@ void FinanceUpdateDailyProfit() money64 FinanceGetInitialCash() { - return getGameState().initialCash; + return getGameState().scenarioOptions.initialCash; } money64 FinanceGetCurrentLoan() @@ -368,7 +368,7 @@ void FinanceShiftExpenditureTable() void FinanceResetCashToInitial() { auto& gameState = getGameState(); - gameState.park.cash = gameState.initialCash; + gameState.park.cash = gameState.scenarioOptions.initialCash; } /** diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index 1970b905fa..91339f3dba 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -175,7 +175,7 @@ namespace OpenRCT2 } // Initial cash will eventually be removed - gameState.initialCash = gameState.park.cash; + gameState.scenarioOptions.initialCash = gameState.park.cash; } void Save(GameState_t& gameState, IStream& stream, int16_t compressionLevel) @@ -601,19 +601,19 @@ namespace OpenRCT2 cs.write(randState.s1); } - cs.readWrite(gameState.guestInitialHappiness); + cs.readWrite(gameState.scenarioOptions.guestInitialHappiness); if (version <= 18) { money16 tempGuestInitialCash{}; cs.readWrite(tempGuestInitialCash); - gameState.guestInitialCash = ToMoney64(tempGuestInitialCash); + gameState.scenarioOptions.guestInitialCash = ToMoney64(tempGuestInitialCash); } else { - cs.readWrite(gameState.guestInitialCash); + cs.readWrite(gameState.scenarioOptions.guestInitialCash); } - cs.readWrite(gameState.guestInitialHunger); - cs.readWrite(gameState.guestInitialThirst); + cs.readWrite(gameState.scenarioOptions.guestInitialHunger); + cs.readWrite(gameState.scenarioOptions.guestInitialThirst); cs.readWrite(gameState.nextGuestNumber); cs.readWriteVector(gameState.peepSpawns, [&cs](PeepSpawn& spawn) { diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 413024bfb8..660c3a74fd 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1509,7 +1509,7 @@ namespace OpenRCT2::RCT1 gameState.park.maxBankLoan = ToMoney64(_s4.MaxLoan); // It's more like 1.33%, but we can only use integers. Can be fixed once we have our own save format. gameState.park.bankLoanInterestRate = 1; - gameState.initialCash = ToMoney64(_s4.Cash); + gameState.scenarioOptions.initialCash = ToMoney64(_s4.Cash); gameState.park.companyValue = ToMoney64(_s4.CompanyValue); gameState.park.value = CorrectRCT1ParkValue(_s4.ParkValue); @@ -2309,10 +2309,10 @@ namespace OpenRCT2::RCT1 News::importNewsItems(gameState, recentMessages, archivedMessages); // Initial guest status - gameState.guestInitialCash = ToMoney64(_s4.GuestInitialCash); - gameState.guestInitialHunger = _s4.GuestInitialHunger; - gameState.guestInitialThirst = _s4.GuestInitialThirst; - gameState.guestInitialHappiness = _s4.GuestInitialHappiness; + gameState.scenarioOptions.guestInitialCash = ToMoney64(_s4.GuestInitialCash); + gameState.scenarioOptions.guestInitialHunger = _s4.GuestInitialHunger; + gameState.scenarioOptions.guestInitialThirst = _s4.GuestInitialThirst; + gameState.scenarioOptions.guestInitialHappiness = _s4.GuestInitialHappiness; gameState.park.guestGenerationProbability = _s4.GuestGenerationProbability; diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index d7e8292981..16852a7bcc 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -379,7 +379,7 @@ namespace OpenRCT2::RCT2 ImportEntities(); ConvertPeepAnimationTypeToObjects(gameState); - gameState.initialCash = ToMoney64(_s6.InitialCash); + gameState.scenarioOptions.initialCash = ToMoney64(_s6.InitialCash); gameState.park.bankLoan = ToMoney64(_s6.CurrentLoan); gameState.park.flags = _s6.ParkFlags & ~PARK_FLAGS_NO_MONEY_SCENARIO; @@ -460,14 +460,14 @@ namespace OpenRCT2::RCT2 gameState.researchProgress = _s6.ResearchProgress; gameState.researchExpectedDay = _s6.NextResearchExpectedDay; gameState.researchExpectedMonth = _s6.NextResearchExpectedMonth; - gameState.guestInitialHappiness = _s6.GuestInitialHappiness; + gameState.scenarioOptions.guestInitialHappiness = _s6.GuestInitialHappiness; gameState.park.size = _s6.ParkSize; gameState.park.guestGenerationProbability = _s6.GuestGenerationProbability; gameState.park.totalRideValueForMoney = _s6.TotalRideValueForMoney; gameState.park.maxBankLoan = ToMoney64(_s6.MaximumLoan); - gameState.guestInitialCash = ToMoney64(_s6.GuestInitialCash); - gameState.guestInitialHunger = _s6.GuestInitialHunger; - gameState.guestInitialThirst = _s6.GuestInitialThirst; + gameState.scenarioOptions.guestInitialCash = ToMoney64(_s6.GuestInitialCash); + gameState.scenarioOptions.guestInitialHunger = _s6.GuestInitialHunger; + gameState.scenarioOptions.guestInitialThirst = _s6.GuestInitialThirst; gameState.scenarioObjective.Type = _s6.ObjectiveType; gameState.scenarioObjective.Year = _s6.ObjectiveYear; // Pad013580FA diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index 4c738a4c62..81f527cb6f 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -106,8 +106,8 @@ void ScenarioReset(GameState_t& gameState) gameState.park.rating = Park::CalculateParkRating(); gameState.park.value = Park::CalculateParkValue(); gameState.park.companyValue = Park::CalculateCompanyValue(); - gameState.park.historicalProfit = gameState.initialCash - gameState.park.bankLoan; - gameState.park.cash = gameState.initialCash; + gameState.park.historicalProfit = gameState.scenarioOptions.initialCash - gameState.park.bankLoan; + gameState.park.cash = gameState.scenarioOptions.initialCash; auto& objManager = GetContext()->GetObjectManager(); if (auto* textObject = objManager.GetLoadedObject(0); textObject != nullptr) @@ -718,7 +718,7 @@ ObjectiveStatus Objective::CheckGuestsAndRating() const { News::AddItemToQueue(News::ItemType::graph, STR_PARK_HAS_BEEN_CLOSED_DOWN, 0, {}); gameState.park.flags &= ~PARK_FLAGS_PARK_OPEN; - gameState.guestInitialHappiness = 50; + gameState.scenarioOptions.guestInitialHappiness = 50; return ObjectiveStatus::Failure; } } diff --git a/src/openrct2/scripting/bindings/world/ScPark.cpp b/src/openrct2/scripting/bindings/world/ScPark.cpp index 00a683c134..e91e56f414 100644 --- a/src/openrct2/scripting/bindings/world/ScPark.cpp +++ b/src/openrct2/scripting/bindings/world/ScPark.cpp @@ -161,22 +161,22 @@ namespace OpenRCT2::Scripting money64 ScPark::guestInitialCash_get() const { - return getGameState().guestInitialCash; + return getGameState().scenarioOptions.guestInitialCash; } uint8_t ScPark::guestInitialHappiness_get() const { - return getGameState().guestInitialHappiness; + return getGameState().scenarioOptions.guestInitialHappiness; } uint8_t ScPark::guestInitialHunger_get() const { - return getGameState().guestInitialHunger; + return getGameState().scenarioOptions.guestInitialHunger; } uint8_t ScPark::guestInitialThirst_get() const { - return getGameState().guestInitialThirst; + return getGameState().scenarioOptions.guestInitialThirst; } money64 ScPark::value_get() const diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index cf02a13123..551938012b 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -309,10 +309,10 @@ namespace OpenRCT2::Park ResearchCategory::Water, ResearchCategory::Shop, ResearchCategory::SceneryGroup); gameState.researchFundingLevel = RESEARCH_FUNDING_NORMAL; - gameState.guestInitialCash = 50.00_GBP; - gameState.guestInitialHappiness = Park::CalculateGuestInitialHappiness(50); - gameState.guestInitialHunger = 200; - gameState.guestInitialThirst = 200; + gameState.scenarioOptions.guestInitialCash = 50.00_GBP; + gameState.scenarioOptions.guestInitialHappiness = Park::CalculateGuestInitialHappiness(50); + gameState.scenarioOptions.guestInitialHunger = 200; + gameState.scenarioOptions.guestInitialThirst = 200; gameState.scenarioObjective.Type = OBJECTIVE_GUESTS_BY; gameState.scenarioObjective.Year = 4; gameState.scenarioObjective.NumGuests = 1000; From f5f3199dfeb49d1ac6fdbc98e6d89620752de5a7 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Fri, 22 Aug 2025 16:05:38 +0200 Subject: [PATCH 2/4] Move scenario objective/category/name/details into Scenario::Options --- src/openrct2-ui/input/Shortcuts.cpp | 2 +- .../windows/EditorBottomToolbar.cpp | 2 +- .../windows/EditorScenarioOptions.cpp | 153 ++++++++++-------- src/openrct2-ui/windows/Finances.cpp | 2 +- src/openrct2-ui/windows/Park.cpp | 11 +- src/openrct2-ui/windows/SavePrompt.cpp | 2 +- src/openrct2-ui/windows/TopToolbar.cpp | 2 +- src/openrct2/Editor.cpp | 6 +- src/openrct2/GameState.h | 9 +- src/openrct2/actions/CheatSetAction.cpp | 2 +- src/openrct2/actions/RideCreateAction.cpp | 2 +- src/openrct2/park/ParkFile.cpp | 14 +- src/openrct2/rct1/S4Importer.cpp | 18 +-- src/openrct2/rct2/S6Importer.cpp | 26 +-- src/openrct2/scenario/Scenario.cpp | 14 +- .../scripting/bindings/world/ScScenario.hpp | 76 ++++----- src/openrct2/world/Park.cpp | 10 +- 17 files changed, 182 insertions(+), 169 deletions(-) diff --git a/src/openrct2-ui/input/Shortcuts.cpp b/src/openrct2-ui/input/Shortcuts.cpp index 5a8fee1d22..5228a9e4f2 100644 --- a/src/openrct2-ui/input/Shortcuts.cpp +++ b/src/openrct2-ui/input/Shortcuts.cpp @@ -420,7 +420,7 @@ static void ShortcutQuickSaveGame() auto intent = Intent(WindowClass::Loadsave); intent.PutEnumExtra(INTENT_EXTRA_LOADSAVE_ACTION, LoadSaveAction::save); intent.PutEnumExtra(INTENT_EXTRA_LOADSAVE_TYPE, LoadSaveType::landscape); - intent.PutExtra(INTENT_EXTRA_PATH, getGameState().scenarioName); + intent.PutExtra(INTENT_EXTRA_PATH, getGameState().scenarioOptions.name); ContextOpenIntent(&intent); } } diff --git a/src/openrct2-ui/windows/EditorBottomToolbar.cpp b/src/openrct2-ui/windows/EditorBottomToolbar.cpp index 2fc5711cd5..702c7f2576 100644 --- a/src/openrct2-ui/windows/EditorBottomToolbar.cpp +++ b/src/openrct2-ui/windows/EditorBottomToolbar.cpp @@ -311,7 +311,7 @@ namespace OpenRCT2::Ui::Windows auto intent = Intent(WindowClass::Loadsave); intent.PutEnumExtra(INTENT_EXTRA_LOADSAVE_ACTION, LoadSaveAction::save); intent.PutEnumExtra(INTENT_EXTRA_LOADSAVE_TYPE, LoadSaveType::scenario); - intent.PutExtra(INTENT_EXTRA_PATH, gameState.scenarioName); + intent.PutExtra(INTENT_EXTRA_PATH, gameState.scenarioOptions.name); intent.PutExtra(INTENT_EXTRA_CALLBACK, reinterpret_cast(SaveScenarioCallback)); ContextOpenIntent(&intent); } diff --git a/src/openrct2-ui/windows/EditorScenarioOptions.cpp b/src/openrct2-ui/windows/EditorScenarioOptions.cpp index 65545a5359..05b666e8bc 100644 --- a/src/openrct2-ui/windows/EditorScenarioOptions.cpp +++ b/src/openrct2-ui/windows/EditorScenarioOptions.cpp @@ -683,7 +683,9 @@ namespace OpenRCT2::Ui::Windows void SetObjective(int32_t objective) { auto& gameState = getGameState(); - gameState.scenarioObjective.Type = objective; + auto& scenarioOptions = gameState.scenarioOptions; + + scenarioOptions.objective.Type = objective; Invalidate(); // Set default objective arguments @@ -695,30 +697,30 @@ namespace OpenRCT2::Ui::Windows case OBJECTIVE_10_ROLLERCOASTERS: break; case OBJECTIVE_GUESTS_BY: - gameState.scenarioObjective.Year = 3; - gameState.scenarioObjective.NumGuests = 1500; + scenarioOptions.objective.Year = 3; + scenarioOptions.objective.NumGuests = 1500; break; case OBJECTIVE_PARK_VALUE_BY: - gameState.scenarioObjective.Year = 3; - gameState.scenarioObjective.Currency = 50000.00_GBP; + scenarioOptions.objective.Year = 3; + scenarioOptions.objective.Currency = 50000.00_GBP; break; case OBJECTIVE_GUESTS_AND_RATING: - gameState.scenarioObjective.NumGuests = 2000; + scenarioOptions.objective.NumGuests = 2000; break; case OBJECTIVE_MONTHLY_RIDE_INCOME: - gameState.scenarioObjective.Currency = 10000.00_GBP; + scenarioOptions.objective.Currency = 10000.00_GBP; break; case OBJECTIVE_10_ROLLERCOASTERS_LENGTH: - gameState.scenarioObjective.MinimumLength = 1200; + scenarioOptions.objective.MinimumLength = 1200; break; case OBJECTIVE_FINISH_5_ROLLERCOASTERS: - gameState.scenarioObjective.MinimumExcitement = RideRating::make(6, 70); + scenarioOptions.objective.MinimumExcitement = RideRating::make(6, 70); break; case OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE: - gameState.scenarioObjective.Currency = 50000.00_GBP; + scenarioOptions.objective.Currency = 50000.00_GBP; break; case OBJECTIVE_MONTHLY_FOOD_INCOME: - gameState.scenarioObjective.Currency = 1000.00_GBP; + scenarioOptions.objective.Currency = 1000.00_GBP; break; } } @@ -726,10 +728,9 @@ namespace OpenRCT2::Ui::Windows void ShowObjectiveDropdown() { const auto& gameState = getGameState(); - int32_t numItems = 0, objectiveType; - Widget* dropdownWidget; + const auto& scenarioOptions = gameState.scenarioOptions; - dropdownWidget = &widgets[WIDX_OBJECTIVE]; + int32_t numItems = 0, objectiveType; for (auto i = 0; i < OBJECTIVE_COUNT; i++) { @@ -749,11 +750,12 @@ namespace OpenRCT2::Ui::Windows } } + Widget* dropdownWidget = &widgets[WIDX_OBJECTIVE]; WindowDropdownShowTextCustomWidth( { windowPos.x + dropdownWidget->left, windowPos.y + dropdownWidget->top }, dropdownWidget->height() + 1, colours[1], 0, Dropdown::Flag::StayOpen, numItems, dropdownWidget->width() - 3); - objectiveType = gameState.scenarioObjective.Type; + objectiveType = scenarioOptions.objective.Type; for (int32_t j = 0; j < numItems; j++) { if (gDropdownItems[j].args - STR_OBJECTIVE_DROPDOWN_NONE == objectiveType) @@ -766,81 +768,81 @@ namespace OpenRCT2::Ui::Windows void ShowCategoryDropdown() { - int32_t i; - Widget* dropdownWidget; - - dropdownWidget = &widgets[WIDX_CATEGORY]; - - for (i = EnumValue(ScenarioCategory::beginner); i <= EnumValue(ScenarioCategory::other); i++) + for (int32_t i = EnumValue(ScenarioCategory::beginner); i <= EnumValue(ScenarioCategory::other); i++) { gDropdownItems[i].format = STR_DROPDOWN_MENU_LABEL; gDropdownItems[i].args = kScenarioCategoryStringIds[i]; } + + Widget* dropdownWidget = &widgets[WIDX_CATEGORY]; WindowDropdownShowTextCustomWidth( { windowPos.x + dropdownWidget->left, windowPos.y + dropdownWidget->top }, dropdownWidget->height() + 1, colours[1], 0, Dropdown::Flag::StayOpen, 5, dropdownWidget->width() - 3); - Dropdown::SetChecked(EnumValue(getGameState().scenarioCategory), true); + + Dropdown::SetChecked(EnumValue(getGameState().scenarioOptions.category), true); } void Arg1Increase() { auto& gameState = getGameState(); - switch (gameState.scenarioObjective.Type) + auto& scenarioOptions = gameState.scenarioOptions; + + switch (scenarioOptions.objective.Type) { case OBJECTIVE_PARK_VALUE_BY: case OBJECTIVE_MONTHLY_RIDE_INCOME: case OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE: - if (gameState.scenarioObjective.Currency >= kObjectiveCurrencyLoanAndValueMax) + if (scenarioOptions.objective.Currency >= kObjectiveCurrencyLoanAndValueMax) { ContextShowError(STR_CANT_INCREASE_FURTHER, kStringIdNone, {}); } else { - gameState.scenarioObjective.Currency += kObjectiveCurrencyLoanAndValueAdjustment; + scenarioOptions.objective.Currency += kObjectiveCurrencyLoanAndValueAdjustment; Invalidate(); } break; case OBJECTIVE_MONTHLY_FOOD_INCOME: - if (gameState.scenarioObjective.Currency >= kObjectiveCurrencyFoodMax) + if (scenarioOptions.objective.Currency >= kObjectiveCurrencyFoodMax) { ContextShowError(STR_CANT_INCREASE_FURTHER, kStringIdNone, {}); } else { - gameState.scenarioObjective.Currency += kObjectiveCurrencyFoodAdjustment; + scenarioOptions.objective.Currency += kObjectiveCurrencyFoodAdjustment; Invalidate(); } break; case OBJECTIVE_10_ROLLERCOASTERS_LENGTH: - if (gameState.scenarioObjective.MinimumLength >= kObjectiveLengthMax) + if (scenarioOptions.objective.MinimumLength >= kObjectiveLengthMax) { ContextShowError(STR_CANT_INCREASE_FURTHER, kStringIdNone, {}); } else { - gameState.scenarioObjective.MinimumLength += kObjectiveLengthAdjustment; + scenarioOptions.objective.MinimumLength += kObjectiveLengthAdjustment; Invalidate(); } break; case OBJECTIVE_FINISH_5_ROLLERCOASTERS: - if (gameState.scenarioObjective.MinimumExcitement >= kObjectiveExcitementMax) + if (scenarioOptions.objective.MinimumExcitement >= kObjectiveExcitementMax) { ContextShowError(STR_CANT_INCREASE_FURTHER, kStringIdNone, {}); } else { - gameState.scenarioObjective.MinimumExcitement += kObjectiveExcitementAdjustment; + scenarioOptions.objective.MinimumExcitement += kObjectiveExcitementAdjustment; Invalidate(); } break; default: - if (gameState.scenarioObjective.NumGuests >= kObjectiveGuestsMax) + if (scenarioOptions.objective.NumGuests >= kObjectiveGuestsMax) { ContextShowError(STR_CANT_INCREASE_FURTHER, kStringIdNone, {}); } else { - gameState.scenarioObjective.NumGuests += kObjectiveGuestsAdjustment; + scenarioOptions.objective.NumGuests += kObjectiveGuestsAdjustment; Invalidate(); } break; @@ -850,62 +852,64 @@ namespace OpenRCT2::Ui::Windows void Arg1Decrease() { auto& gameState = getGameState(); - switch (gameState.scenarioObjective.Type) + auto& scenarioOptions = gameState.scenarioOptions; + + switch (scenarioOptions.objective.Type) { case OBJECTIVE_PARK_VALUE_BY: case OBJECTIVE_MONTHLY_RIDE_INCOME: case OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE: - if (gameState.scenarioObjective.Currency <= kObjectiveCurrencyLoanAndValueMin) + if (scenarioOptions.objective.Currency <= kObjectiveCurrencyLoanAndValueMin) { ContextShowError(STR_CANT_REDUCE_FURTHER, kStringIdNone, {}); } else { - gameState.scenarioObjective.Currency -= kObjectiveCurrencyLoanAndValueAdjustment; + scenarioOptions.objective.Currency -= kObjectiveCurrencyLoanAndValueAdjustment; Invalidate(); } break; case OBJECTIVE_MONTHLY_FOOD_INCOME: - if (gameState.scenarioObjective.Currency <= kObjectiveCurrencyFoodMin) + if (scenarioOptions.objective.Currency <= kObjectiveCurrencyFoodMin) { ContextShowError(STR_CANT_REDUCE_FURTHER, kStringIdNone, {}); } else { - gameState.scenarioObjective.Currency -= kObjectiveCurrencyFoodAdjustment; + scenarioOptions.objective.Currency -= kObjectiveCurrencyFoodAdjustment; Invalidate(); } break; case OBJECTIVE_10_ROLLERCOASTERS_LENGTH: - if (gameState.scenarioObjective.MinimumLength <= kObjectiveLengthMin) + if (scenarioOptions.objective.MinimumLength <= kObjectiveLengthMin) { ContextShowError(STR_CANT_REDUCE_FURTHER, kStringIdNone, {}); } else { - gameState.scenarioObjective.MinimumLength -= kObjectiveLengthAdjustment; + scenarioOptions.objective.MinimumLength -= kObjectiveLengthAdjustment; Invalidate(); } break; case OBJECTIVE_FINISH_5_ROLLERCOASTERS: - if (gameState.scenarioObjective.MinimumExcitement <= kObjectiveExcitementMin) + if (scenarioOptions.objective.MinimumExcitement <= kObjectiveExcitementMin) { ContextShowError(STR_CANT_REDUCE_FURTHER, kStringIdNone, {}); } else { - gameState.scenarioObjective.MinimumExcitement -= kObjectiveExcitementAdjustment; + scenarioOptions.objective.MinimumExcitement -= kObjectiveExcitementAdjustment; Invalidate(); } break; default: - if (gameState.scenarioObjective.NumGuests <= kObjectiveGuestsMin) + if (scenarioOptions.objective.NumGuests <= kObjectiveGuestsMin) { ContextShowError(STR_CANT_REDUCE_FURTHER, kStringIdNone, {}); } else { - gameState.scenarioObjective.NumGuests -= kObjectiveGuestsAdjustment; + scenarioOptions.objective.NumGuests -= kObjectiveGuestsAdjustment; Invalidate(); } break; @@ -915,13 +919,15 @@ namespace OpenRCT2::Ui::Windows void Arg2Increase() { auto& gameState = getGameState(); - if (gameState.scenarioObjective.Year >= kObjectiveYearMax) + auto& scenarioOptions = gameState.scenarioOptions; + + if (scenarioOptions.objective.Year >= kObjectiveYearMax) { ContextShowError(STR_CANT_INCREASE_FURTHER, kStringIdNone, {}); } else { - gameState.scenarioObjective.Year += kObjectiveYearAdjustment; + scenarioOptions.objective.Year += kObjectiveYearAdjustment; Invalidate(); } } @@ -929,13 +935,15 @@ namespace OpenRCT2::Ui::Windows void Arg2Decrease() { auto& gameState = getGameState(); - if (gameState.scenarioObjective.Year <= kObjectiveYearMin) + auto& scenarioOptions = gameState.scenarioOptions; + + if (scenarioOptions.objective.Year <= kObjectiveYearMin) { ContextShowError(STR_CANT_REDUCE_FURTHER, kStringIdNone, {}); } else { - gameState.scenarioObjective.Year -= kObjectiveYearAdjustment; + scenarioOptions.objective.Year -= kObjectiveYearAdjustment; Invalidate(); } } @@ -1009,7 +1017,7 @@ namespace OpenRCT2::Ui::Windows case WIDX_OBJECTIVE_DROPDOWN: // TODO: Don't rely on string ID order newObjectiveType = static_cast(gDropdownItems[dropdownIndex].args - STR_OBJECTIVE_DROPDOWN_NONE); - if (gameState.scenarioObjective.Type != newObjectiveType) + if (gameState.scenarioOptions.objective.Type != newObjectiveType) SetObjective(newObjectiveType); break; } @@ -1027,7 +1035,7 @@ namespace OpenRCT2::Ui::Windows OnPrepareDraw(); InvalidateWidget(WIDX_TAB_1); - objectiveType = getGameState().scenarioObjective.Type; + objectiveType = getGameState().scenarioOptions.objective.Type; // Check if objective is allowed by money and pay-per-ride settings. const bool objectiveAllowedByMoneyUsage = !(getGameState().park.flags & PARK_FLAGS_NO_MONEY) @@ -1052,7 +1060,7 @@ namespace OpenRCT2::Ui::Windows SetPressedTab(); - switch (gameState.scenarioObjective.Type) + switch (gameState.scenarioOptions.objective.Type) { case OBJECTIVE_GUESTS_BY: case OBJECTIVE_PARK_VALUE_BY: @@ -1096,7 +1104,7 @@ namespace OpenRCT2::Ui::Windows if (widgets[WIDX_OBJECTIVE_ARG_1_LABEL].type != WidgetType::empty) { // Objective argument 1 label - switch (gameState.scenarioObjective.Type) + switch (gameState.scenarioOptions.objective.Type) { case OBJECTIVE_GUESTS_BY: case OBJECTIVE_GUESTS_AND_RATING: @@ -1135,6 +1143,7 @@ namespace OpenRCT2::Ui::Windows void ObjectiveOnDraw(RenderTarget& rt) { const auto& gameState = getGameState(); + const auto& scenarioOptions = gameState.scenarioOptions; DrawWidgets(rt); DrawTabImages(rt); @@ -1142,7 +1151,7 @@ namespace OpenRCT2::Ui::Windows // Objective value auto screenCoords = windowPos + ScreenCoordsXY{ widgets[WIDX_OBJECTIVE].left + 1, widgets[WIDX_OBJECTIVE].top }; auto ft = Formatter(); - ft.Add(ObjectiveDropdownOptionNames[gameState.scenarioObjective.Type]); + ft.Add(ObjectiveDropdownOptionNames[scenarioOptions.objective.Type]); DrawTextBasic(rt, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft); if (widgets[WIDX_OBJECTIVE_ARG_1].type != WidgetType::empty) @@ -1154,31 +1163,31 @@ namespace OpenRCT2::Ui::Windows screenCoords = windowPos + ScreenCoordsXY{ widgets[WIDX_OBJECTIVE_ARG_1].left + 1, widgets[WIDX_OBJECTIVE_ARG_1].top }; ft = Formatter(); - switch (gameState.scenarioObjective.Type) + switch (scenarioOptions.objective.Type) { case OBJECTIVE_GUESTS_BY: case OBJECTIVE_GUESTS_AND_RATING: stringId = STR_WINDOW_COLOUR_2_COMMA32; - ft.Add(gameState.scenarioObjective.NumGuests); + ft.Add(scenarioOptions.objective.NumGuests); break; case OBJECTIVE_PARK_VALUE_BY: case OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE: case OBJECTIVE_MONTHLY_RIDE_INCOME: case OBJECTIVE_MONTHLY_FOOD_INCOME: stringId = STR_CURRENCY_FORMAT_LABEL; - ft.Add(gameState.scenarioObjective.Currency); + ft.Add(scenarioOptions.objective.Currency); break; case OBJECTIVE_10_ROLLERCOASTERS_LENGTH: stringId = STR_WINDOW_COLOUR_2_LENGTH; - ft.Add(gameState.scenarioObjective.MinimumLength); + ft.Add(scenarioOptions.objective.MinimumLength); break; case OBJECTIVE_FINISH_5_ROLLERCOASTERS: stringId = STR_WINDOW_COLOUR_2_COMMA2DP32; - ft.Add(gameState.scenarioObjective.MinimumExcitement); + ft.Add(scenarioOptions.objective.MinimumExcitement); break; default: stringId = STR_WINDOW_COLOUR_2_COMMA2DP32; - ft.Add(gameState.scenarioObjective.Currency); + ft.Add(scenarioOptions.objective.Currency); break; } DrawTextBasic(rt, screenCoords, stringId, ft, wColour2); @@ -1190,7 +1199,7 @@ namespace OpenRCT2::Ui::Windows screenCoords = windowPos + ScreenCoordsXY{ widgets[WIDX_OBJECTIVE_ARG_2].left + 1, widgets[WIDX_OBJECTIVE_ARG_2].top }; ft = Formatter(); - ft.Add((gameState.scenarioObjective.Year * MONTH_COUNT) - 1); + ft.Add((scenarioOptions.objective.Year * MONTH_COUNT) - 1); DrawTextBasic(rt, screenCoords, STR_WINDOW_OBJECTIVE_VALUE_DATE, ft); } } @@ -1218,12 +1227,12 @@ namespace OpenRCT2::Ui::Windows case WIDX_SCENARIO_NAME: WindowTextInputRawOpen( this, WIDX_SCENARIO_NAME, STR_SCENARIO_NAME, STR_ENTER_SCENARIO_NAME, {}, - gameState.scenarioName.c_str(), kScenarioNameMaxLength); + gameState.scenarioOptions.name.c_str(), kScenarioNameMaxLength); break; case WIDX_DETAILS: WindowTextInputRawOpen( this, WIDX_DETAILS, STR_PARK_SCENARIO_DETAILS, STR_ENTER_SCENARIO_DESCRIPTION, {}, - gameState.scenarioDetails.c_str(), kScenarioDetailsNameMaxLength); + gameState.scenarioOptions.details.c_str(), kScenarioDetailsNameMaxLength); break; } } @@ -1248,9 +1257,9 @@ namespace OpenRCT2::Ui::Windows case WIDX_CATEGORY_DROPDOWN: { auto& gameState = getGameState(); - if (gameState.scenarioCategory != static_cast(dropdownIndex)) + if (gameState.scenarioOptions.category != static_cast(dropdownIndex)) { - gameState.scenarioCategory = static_cast(dropdownIndex); + gameState.scenarioOptions.category = static_cast(dropdownIndex); Invalidate(); } break; @@ -1288,7 +1297,7 @@ namespace OpenRCT2::Ui::Windows auto ft = Formatter(); ft.Add(STR_STRING); - ft.Add(gameState.scenarioName.c_str()); + ft.Add(gameState.scenarioOptions.name.c_str()); DrawTextEllipsised(rt, screenCoords, widthToSet, STR_WINDOW_SCENARIO_NAME, ft); // Scenario details label @@ -1301,7 +1310,7 @@ namespace OpenRCT2::Ui::Windows ft = Formatter(); ft.Add(STR_STRING); - ft.Add(gameState.scenarioDetails.c_str()); + ft.Add(gameState.scenarioOptions.details.c_str()); DrawTextWrapped(rt, screenCoords, widthToSet, STR_BLACK_STRING, ft); // Scenario category label @@ -1311,7 +1320,7 @@ namespace OpenRCT2::Ui::Windows // Scenario category value screenCoords = windowPos + ScreenCoordsXY{ widgets[WIDX_CATEGORY].left + 1, widgets[WIDX_CATEGORY].top }; ft = Formatter(); - ft.Add(kScenarioCategoryStringIds[EnumValue(gameState.scenarioCategory)]); + ft.Add(kScenarioCategoryStringIds[EnumValue(gameState.scenarioOptions.category)]); DrawTextBasic(rt, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft); } @@ -1325,6 +1334,8 @@ namespace OpenRCT2::Ui::Windows return; auto& gameState = getGameState(); + auto& scenarioOptions = gameState.scenarioOptions; + switch (widgetIndex) { case WIDX_PARK_NAME: @@ -1332,18 +1343,18 @@ namespace OpenRCT2::Ui::Windows auto action = ParkSetNameAction(std::string(text)); GameActions::Execute(&action); - if (gameState.scenarioName.empty()) + if (scenarioOptions.name.empty()) { - gameState.scenarioName = gameState.park.name; + scenarioOptions.name = gameState.park.name; } break; } case WIDX_SCENARIO_NAME: - gameState.scenarioName = text; + scenarioOptions.name = text; Invalidate(); break; case WIDX_DETAILS: - gameState.scenarioDetails = text; + scenarioOptions.details = text; Invalidate(); break; } diff --git a/src/openrct2-ui/windows/Finances.cpp b/src/openrct2-ui/windows/Finances.cpp index 66f2744310..255e57c71c 100644 --- a/src/openrct2-ui/windows/Finances.cpp +++ b/src/openrct2-ui/windows/Finances.cpp @@ -636,7 +636,7 @@ namespace OpenRCT2::Ui::Windows DrawTextBasic(rt, windowPos + ScreenCoordsXY{ 8, titleBarBottom + 280 }, stringId, ft); // Objective related financial information - if (gameState.scenarioObjective.Type == OBJECTIVE_MONTHLY_FOOD_INCOME) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_MONTHLY_FOOD_INCOME) { auto lastMonthProfit = FinanceGetLastMonthShopProfit(); ft = Formatter(); diff --git a/src/openrct2-ui/windows/Park.cpp b/src/openrct2-ui/windows/Park.cpp index ecb5cb9a48..bd6caa44a0 100644 --- a/src/openrct2-ui/windows/Park.cpp +++ b/src/openrct2-ui/windows/Park.cpp @@ -521,7 +521,7 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_OPEN_LIGHT].image = ImageId(openLightImage); // Only allow closing of park for guest / rating objective - if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_AND_RATING) disabled_widgets |= (1uLL << WIDX_OPEN_OR_CLOSE) | (1uLL << WIDX_CLOSE_LIGHT) | (1uLL << WIDX_OPEN_LIGHT); else disabled_widgets &= ~((1uLL << WIDX_OPEN_OR_CLOSE) | (1uLL << WIDX_CLOSE_LIGHT) | (1uLL << WIDX_OPEN_LIGHT)); @@ -545,7 +545,7 @@ namespace OpenRCT2::Ui::Windows if (ThemeGetFlags() & UITHEME_FLAG_USE_LIGHTS_PARK) { widgets[WIDX_OPEN_OR_CLOSE].type = WidgetType::empty; - if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_AND_RATING) { widgets[WIDX_CLOSE_LIGHT].type = WidgetType::flatBtn; widgets[WIDX_OPEN_LIGHT].type = WidgetType::flatBtn; @@ -1073,7 +1073,7 @@ namespace OpenRCT2::Ui::Windows + ScreenCoordsXY{ widgets[WIDX_PAGE_BACKGROUND].left + 4, widgets[WIDX_PAGE_BACKGROUND].top + 7 }; auto ft = Formatter(); ft.Add(STR_STRING); - ft.Add(gameState.scenarioDetails.c_str()); + ft.Add(gameState.scenarioOptions.details.c_str()); screenCoords.y += DrawTextWrapped(rt, screenCoords, 222, STR_BLACK_STRING, ft); screenCoords.y += 5; @@ -1083,9 +1083,10 @@ namespace OpenRCT2::Ui::Windows // Objective ft = Formatter(); - formatObjective(ft, gameState.scenarioObjective); + formatObjective(ft, gameState.scenarioOptions.objective); - screenCoords.y += DrawTextWrapped(rt, screenCoords, 221, kObjectiveNames[gameState.scenarioObjective.Type], ft); + screenCoords.y += DrawTextWrapped( + rt, screenCoords, 221, kObjectiveNames[gameState.scenarioOptions.objective.Type], ft); screenCoords.y += 5; // Objective outcome diff --git a/src/openrct2-ui/windows/SavePrompt.cpp b/src/openrct2-ui/windows/SavePrompt.cpp index 80905e110c..53103df32d 100644 --- a/src/openrct2-ui/windows/SavePrompt.cpp +++ b/src/openrct2-ui/windows/SavePrompt.cpp @@ -169,7 +169,7 @@ namespace OpenRCT2::Ui::Windows intent = std::make_unique(WindowClass::Loadsave); intent->PutEnumExtra(INTENT_EXTRA_LOADSAVE_ACTION, LoadSaveAction::save); intent->PutEnumExtra(INTENT_EXTRA_LOADSAVE_TYPE, LoadSaveType::landscape); - intent->PutExtra(INTENT_EXTRA_PATH, getGameState().scenarioName); + intent->PutExtra(INTENT_EXTRA_PATH, getGameState().scenarioOptions.name); } else { diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 328ce337a2..80b33e5f4c 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -465,7 +465,7 @@ namespace OpenRCT2::Ui::Windows auto intent = Intent(WindowClass::Loadsave); intent.PutEnumExtra(INTENT_EXTRA_LOADSAVE_ACTION, LoadSaveAction::save); intent.PutEnumExtra(INTENT_EXTRA_LOADSAVE_TYPE, LoadSaveType::landscape); - intent.PutExtra(INTENT_EXTRA_PATH, getGameState().scenarioName); + intent.PutExtra(INTENT_EXTRA_PATH, getGameState().scenarioOptions.name); ContextOpenIntent(&intent); } else diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 231275ef07..769180d0fa 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -112,14 +112,14 @@ namespace OpenRCT2::Editor gLegacyScene = LegacyScene::scenarioEditor; gameState.editorStep = EditorStep::ObjectSelection; gameState.park.flags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; - gameState.scenarioCategory = ScenarioCategory::other; + gameState.scenarioOptions.category = ScenarioCategory::other; ObjectListLoad(); ViewportInitAll(); WindowBase* mainWindow = OpenEditorWindows(); mainWindow->SetViewportLocation(TileCoordsXYZ{ 75, 75, 14 }.ToCoordsXYZ()); LoadPalette(); gScreenAge = 0; - gameState.scenarioName = LanguageGetString(STR_MY_NEW_SCENARIO); + gameState.scenarioOptions.name = LanguageGetString(STR_MY_NEW_SCENARIO); GameLoadScripts(); GameNotifyMapChanged(); @@ -156,7 +156,7 @@ namespace OpenRCT2::Editor gLegacyScene = LegacyScene::scenarioEditor; gameState.editorStep = EditorStep::OptionsSelection; - gameState.scenarioCategory = ScenarioCategory::other; + gameState.scenarioOptions.category = ScenarioCategory::other; ViewportInitAll(); OpenEditorWindows(); FinaliseMainView(); diff --git a/src/openrct2/GameState.h b/src/openrct2/GameState.h index 773fadf284..68443f9826 100644 --- a/src/openrct2/GameState.h +++ b/src/openrct2/GameState.h @@ -34,6 +34,11 @@ namespace OpenRCT2::Scenario { struct Options { + Objective objective; + ScenarioCategory category; + std::string name; + std::string details; + money64 initialCash; money64 guestInitialCash; @@ -60,7 +65,6 @@ namespace OpenRCT2 uint32_t nextGuestNumber; - Objective scenarioObjective; uint16_t scenarioParkRatingWarningDays; money64 scenarioCompletedCompanyValue; money64 scenarioCompanyValueRecord; @@ -72,9 +76,6 @@ namespace OpenRCT2 EditorStep editorStep; - ScenarioCategory scenarioCategory; - std::string scenarioName; - std::string scenarioDetails; std::string scenarioCompletedBy; std::string scenarioFileName; diff --git a/src/openrct2/actions/CheatSetAction.cpp b/src/openrct2/actions/CheatSetAction.cpp index 5437d02f78..01bcebe969 100644 --- a/src/openrct2/actions/CheatSetAction.cpp +++ b/src/openrct2/actions/CheatSetAction.cpp @@ -234,7 +234,7 @@ GameActions::Result CheatSetAction::Execute() const ParkSetOpen(!Park::IsOpen(gameState.park)); break; case CheatType::HaveFun: - gameState.scenarioObjective.Type = OBJECTIVE_HAVE_FUN; + gameState.scenarioOptions.objective.Type = OBJECTIVE_HAVE_FUN; break; case CheatType::SetForcedParkRating: Park::SetForcedRating(_param1); diff --git a/src/openrct2/actions/RideCreateAction.cpp b/src/openrct2/actions/RideCreateAction.cpp index 4bcfdab712..4490b7bc0f 100644 --- a/src/openrct2/actions/RideCreateAction.cpp +++ b/src/openrct2/actions/RideCreateAction.cpp @@ -226,7 +226,7 @@ GameActions::Result RideCreateAction::Execute() const ride->price[1] = GetShopItemDescriptor(rideEntry->shop_item[1]).DefaultPrice; } - if (gameState.scenarioObjective.Type == OBJECTIVE_BUILD_THE_BEST) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_BUILD_THE_BEST) { ride->price[0] = 0; } diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index 91339f3dba..f4f77c85c6 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -484,15 +484,15 @@ namespace OpenRCT2 void ReadWriteScenarioChunk(GameState_t& gameState, OrcaStream& os) { os.readWriteChunk(ParkFileChunkType::SCENARIO, [&gameState, &os](OrcaStream::ChunkStream& cs) { - cs.readWrite(gameState.scenarioCategory); - ReadWriteStringTable(cs, gameState.scenarioName, "en-GB"); + cs.readWrite(gameState.scenarioOptions.category); + ReadWriteStringTable(cs, gameState.scenarioOptions.name, "en-GB"); ReadWriteStringTable(cs, gameState.park.name, "en-GB"); - ReadWriteStringTable(cs, gameState.scenarioDetails, "en-GB"); + ReadWriteStringTable(cs, gameState.scenarioOptions.details, "en-GB"); - cs.readWrite(gameState.scenarioObjective.Type); - cs.readWrite(gameState.scenarioObjective.Year); - cs.readWrite(gameState.scenarioObjective.NumGuests); - cs.readWrite(gameState.scenarioObjective.Currency); + cs.readWrite(gameState.scenarioOptions.objective.Type); + cs.readWrite(gameState.scenarioOptions.objective.Year); + cs.readWrite(gameState.scenarioOptions.objective.NumGuests); + cs.readWrite(gameState.scenarioOptions.objective.Currency); cs.readWrite(gameState.scenarioParkRatingWarningDays); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 660c3a74fd..39c1ccd344 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -358,7 +358,7 @@ namespace OpenRCT2::RCT1 gameStateInitAll(gameState, { mapSize, mapSize }); gameState.editorStep = EditorStep::ObjectSelection; gameState.park.flags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; - gameState.scenarioCategory = ScenarioCategory::other; + gameState.scenarioOptions.category = ScenarioCategory::other; } std::string GetRCT1ScenarioName() @@ -2447,8 +2447,8 @@ namespace OpenRCT2::RCT1 } } - gameState.scenarioName = std::move(name); - gameState.scenarioDetails = std::move(details); + gameState.scenarioOptions.name = std::move(name); + gameState.scenarioOptions.details = std::move(details); if (_isScenario && !parkName.empty()) { auto& park = getGameState().park; @@ -2458,21 +2458,21 @@ namespace OpenRCT2::RCT1 void ImportScenarioObjective(GameState_t& gameState) { - gameState.scenarioObjective.Type = _s4.ScenarioObjectiveType; - gameState.scenarioObjective.Year = _s4.ScenarioObjectiveYears; - gameState.scenarioObjective.NumGuests = _s4.ScenarioObjectiveNumGuests; + gameState.scenarioOptions.objective.Type = _s4.ScenarioObjectiveType; + gameState.scenarioOptions.objective.Year = _s4.ScenarioObjectiveYears; + gameState.scenarioOptions.objective.NumGuests = _s4.ScenarioObjectiveNumGuests; // RCT1 used a different way of calculating the park value. // This is corrected here, but since scenario_objective_currency doubles as minimum excitement rating, // we need to check the goal to avoid affecting scenarios like Volcania. if (_s4.ScenarioObjectiveType == OBJECTIVE_PARK_VALUE_BY) - gameState.scenarioObjective.Currency = CorrectRCT1ParkValue(_s4.ScenarioObjectiveCurrency); + gameState.scenarioOptions.objective.Currency = CorrectRCT1ParkValue(_s4.ScenarioObjectiveCurrency); else - gameState.scenarioObjective.Currency = ToMoney64(_s4.ScenarioObjectiveCurrency); + gameState.scenarioOptions.objective.Currency = ToMoney64(_s4.ScenarioObjectiveCurrency); // This does not seem to be saved in the objective arguments, so look up the ID from the available rides instead. if (_s4.ScenarioObjectiveType == OBJECTIVE_BUILD_THE_BEST) - gameState.scenarioObjective.RideId = GetBuildTheBestRideId(); + gameState.scenarioOptions.objective.RideId = GetBuildTheBestRideId(); } void ImportSavedView(GameState_t& gameState) diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 16852a7bcc..9301e6769f 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -350,7 +350,7 @@ namespace OpenRCT2::RCT2 Initialise(gameState); gameState.editorStep = _s6.Info.EditorStep; - gameState.scenarioCategory = _s6.Info.Category; + gameState.scenarioOptions.category = _s6.Info.Category; // Some scenarios have their scenario details in UTF-8, due to earlier bugs in OpenRCT2. auto loadMaybeUTF8 = [](std::string_view str) -> std::string { @@ -359,14 +359,14 @@ namespace OpenRCT2::RCT2 if (_s6.Header.Type == S6_TYPE_SCENARIO) { - gameState.scenarioName = loadMaybeUTF8(_s6.Info.Name); - gameState.scenarioDetails = loadMaybeUTF8(_s6.Info.Details); + gameState.scenarioOptions.name = loadMaybeUTF8(_s6.Info.Name); + gameState.scenarioOptions.details = loadMaybeUTF8(_s6.Info.Details); } else { // Saved games do not have an info chunk - gameState.scenarioName = loadMaybeUTF8(_s6.ScenarioName); - gameState.scenarioDetails = loadMaybeUTF8(_s6.ScenarioDescription); + gameState.scenarioOptions.name = loadMaybeUTF8(_s6.ScenarioName); + gameState.scenarioOptions.details = loadMaybeUTF8(_s6.ScenarioDescription); } gameState.date = OpenRCT2::Date{ _s6.ElapsedMonths, _s6.CurrentDay }; @@ -468,16 +468,16 @@ namespace OpenRCT2::RCT2 gameState.scenarioOptions.guestInitialCash = ToMoney64(_s6.GuestInitialCash); gameState.scenarioOptions.guestInitialHunger = _s6.GuestInitialHunger; gameState.scenarioOptions.guestInitialThirst = _s6.GuestInitialThirst; - gameState.scenarioObjective.Type = _s6.ObjectiveType; - gameState.scenarioObjective.Year = _s6.ObjectiveYear; + gameState.scenarioOptions.objective.Type = _s6.ObjectiveType; + gameState.scenarioOptions.objective.Year = _s6.ObjectiveYear; // Pad013580FA - gameState.scenarioObjective.Currency = _s6.ObjectiveCurrency; + gameState.scenarioOptions.objective.Currency = _s6.ObjectiveCurrency; // In RCT2, the ride string IDs start at index STR_0002 and are directly mappable. // This is not always the case in OpenRCT2, so we use the actual ride ID. - if (gameState.scenarioObjective.Type == OBJECTIVE_BUILD_THE_BEST) - gameState.scenarioObjective.RideId = _s6.ObjectiveGuests - kRCT2RideStringStart; + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_BUILD_THE_BEST) + gameState.scenarioOptions.objective.RideId = _s6.ObjectiveGuests - kRCT2RideStringStart; else - gameState.scenarioObjective.NumGuests = _s6.ObjectiveGuests; + gameState.scenarioOptions.objective.NumGuests = _s6.ObjectiveGuests; ImportMarketingCampaigns(); gameState.park.currentExpenditure = ToMoney64(_s6.CurrentExpenditure); @@ -641,8 +641,8 @@ namespace OpenRCT2::RCT2 { // Scenario details gameState.scenarioCompletedBy = RCT2StringToUTF8(gameState.scenarioCompletedBy, RCT2LanguageId::EnglishUK); - gameState.scenarioName = RCT2StringToUTF8(gameState.scenarioName, RCT2LanguageId::EnglishUK); - gameState.scenarioDetails = RCT2StringToUTF8(gameState.scenarioDetails, RCT2LanguageId::EnglishUK); + gameState.scenarioOptions.name = RCT2StringToUTF8(gameState.scenarioOptions.name, RCT2LanguageId::EnglishUK); + gameState.scenarioOptions.details = RCT2StringToUTF8(gameState.scenarioOptions.details, RCT2LanguageId::EnglishUK); } void ImportRides() diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index 81f527cb6f..0daafc0baa 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -84,7 +84,7 @@ void ScenarioBegin(GameState_t& gameState) GameLoadInit(); ScenarioReset(gameState); - if (gameState.scenarioObjective.Type != OBJECTIVE_NONE && !gLoadKeepWindowsOpen) + if (gameState.scenarioOptions.objective.Type != OBJECTIVE_NONE && !gLoadKeepWindowsOpen) ContextOpenWindowView(WV_PARK_OBJECTIVE); gScreenAge = 0; @@ -112,9 +112,9 @@ void ScenarioReset(GameState_t& gameState) auto& objManager = GetContext()->GetObjectManager(); if (auto* textObject = objManager.GetLoadedObject(0); textObject != nullptr) { - gameState.scenarioName = textObject->GetScenarioName(); + gameState.scenarioOptions.name = textObject->GetScenarioName(); gameState.park.name = textObject->GetParkName(); - gameState.scenarioDetails = textObject->GetScenarioDetails(); + gameState.scenarioOptions.details = textObject->GetScenarioDetails(); } // Set the last saved game path @@ -285,7 +285,7 @@ static void ScenarioDayUpdate(GameState_t& gameState) { FinanceUpdateDailyProfit(); PeepUpdateDaysInQueue(); - switch (gameState.scenarioObjective.Type) + switch (gameState.scenarioOptions.objective.Type) { case OBJECTIVE_10_ROLLERCOASTERS: case OBJECTIVE_GUESTS_AND_RATING: @@ -526,7 +526,7 @@ uint32_t ScenarioRandMax(uint32_t max) */ static ResultWithMessage ScenarioPrepareRidesForSave(GameState_t& gameState) { - int32_t isFiveCoasterObjective = gameState.scenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS; + int32_t isFiveCoasterObjective = gameState.scenarioOptions.objective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS; uint8_t rcs = 0; for (auto& ride : GetRideManager()) @@ -592,7 +592,7 @@ ResultWithMessage ScenarioPrepareForSave(GameState_t& gameState) return { false, prepareRidesResult.Message }; } - if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_AND_RATING) gameState.park.flags |= PARK_FLAGS_PARK_OPEN; ScenarioReset(gameState); @@ -858,7 +858,7 @@ bool AllowEarlyCompletion() static void ScenarioCheckObjective(GameState_t& gameState) { - auto status = gameState.scenarioObjective.Check(gameState); + auto status = gameState.scenarioOptions.objective.Check(gameState); if (status == ObjectiveStatus::Success) { ScenarioSuccess(gameState); diff --git a/src/openrct2/scripting/bindings/world/ScScenario.hpp b/src/openrct2/scripting/bindings/world/ScScenario.hpp index 7d9a7d2e31..1dbe99f188 100644 --- a/src/openrct2/scripting/bindings/world/ScScenario.hpp +++ b/src/openrct2/scripting/bindings/world/ScScenario.hpp @@ -41,22 +41,22 @@ namespace OpenRCT2::Scripting private: std::string type_get() { - return std::string(ScenarioObjectiveTypeMap[getGameState().scenarioObjective.Type]); + return std::string(ScenarioObjectiveTypeMap[getGameState().scenarioOptions.objective.Type]); } void type_set(const std::string& value) { ThrowIfGameStateNotMutable(); - getGameState().scenarioObjective.Type = ScenarioObjectiveTypeMap[value]; + getGameState().scenarioOptions.objective.Type = ScenarioObjectiveTypeMap[value]; } uint16_t guests_get() { auto& gameState = getGameState(); - if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_BY - || gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_BY + || gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_AND_RATING) { - return gameState.scenarioObjective.NumGuests; + return gameState.scenarioOptions.objective.NumGuests; } return 0; } @@ -65,20 +65,20 @@ namespace OpenRCT2::Scripting { ThrowIfGameStateNotMutable(); auto& gameState = getGameState(); - if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_BY - || gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_BY + || gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_AND_RATING) { - gameState.scenarioObjective.NumGuests = value; + gameState.scenarioOptions.objective.NumGuests = value; } } uint8_t year_get() { const auto& gameState = getGameState(); - if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_BY - || gameState.scenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_BY + || gameState.scenarioOptions.objective.Type == OBJECTIVE_PARK_VALUE_BY) { - return gameState.scenarioObjective.Year; + return gameState.scenarioOptions.objective.Year; } return 0; } @@ -87,19 +87,19 @@ namespace OpenRCT2::Scripting { auto& gameState = getGameState(); ThrowIfGameStateNotMutable(); - if (gameState.scenarioObjective.Type == OBJECTIVE_GUESTS_BY - || gameState.scenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_GUESTS_BY + || gameState.scenarioOptions.objective.Type == OBJECTIVE_PARK_VALUE_BY) { - gameState.scenarioObjective.Year = value; + gameState.scenarioOptions.objective.Year = value; } } uint16_t length_get() { const auto& gameState = getGameState(); - if (gameState.scenarioObjective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH) { - return gameState.scenarioObjective.NumGuests; + return gameState.scenarioOptions.objective.NumGuests; } return 0; } @@ -108,18 +108,18 @@ namespace OpenRCT2::Scripting { ThrowIfGameStateNotMutable(); auto& gameState = getGameState(); - if (gameState.scenarioObjective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH) { - gameState.scenarioObjective.NumGuests = value; + gameState.scenarioOptions.objective.NumGuests = value; } } money64 excitement_get() { const auto& gameState = getGameState(); - if (gameState.scenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS) { - return gameState.scenarioObjective.Currency; + return gameState.scenarioOptions.objective.Currency; } return 0; } @@ -128,19 +128,19 @@ namespace OpenRCT2::Scripting { ThrowIfGameStateNotMutable(); auto& gameState = getGameState(); - if (gameState.scenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS) { - gameState.scenarioObjective.Currency = value; + gameState.scenarioOptions.objective.Currency = value; } } money64 parkValue_get() { const auto& gameState = getGameState(); - if (gameState.scenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY - || gameState.scenarioObjective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_PARK_VALUE_BY + || gameState.scenarioOptions.objective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE) { - return gameState.scenarioObjective.Currency; + return gameState.scenarioOptions.objective.Currency; } return 0; } @@ -149,20 +149,20 @@ namespace OpenRCT2::Scripting { ThrowIfGameStateNotMutable(); auto& gameState = getGameState(); - if (gameState.scenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY - || gameState.scenarioObjective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_PARK_VALUE_BY + || gameState.scenarioOptions.objective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE) { - gameState.scenarioObjective.Currency = value; + gameState.scenarioOptions.objective.Currency = value; } } money64 monthlyIncome_get() { const auto& gameState = getGameState(); - if (gameState.scenarioObjective.Type == OBJECTIVE_MONTHLY_RIDE_INCOME - || gameState.scenarioObjective.Type == OBJECTIVE_MONTHLY_FOOD_INCOME) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_MONTHLY_RIDE_INCOME + || gameState.scenarioOptions.objective.Type == OBJECTIVE_MONTHLY_FOOD_INCOME) { - return gameState.scenarioObjective.Currency; + return gameState.scenarioOptions.objective.Currency; } return 0; } @@ -171,10 +171,10 @@ namespace OpenRCT2::Scripting { ThrowIfGameStateNotMutable(); auto& gameState = getGameState(); - if (gameState.scenarioObjective.Type == OBJECTIVE_PARK_VALUE_BY - || gameState.scenarioObjective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE) + if (gameState.scenarioOptions.objective.Type == OBJECTIVE_PARK_VALUE_BY + || gameState.scenarioOptions.objective.Type == OBJECTIVE_REPAY_LOAN_AND_PARK_VALUE) { - gameState.scenarioObjective.Currency = value; + gameState.scenarioOptions.objective.Currency = value; } } @@ -198,24 +198,24 @@ namespace OpenRCT2::Scripting public: std::string name_get() { - return getGameState().scenarioName; + return getGameState().scenarioOptions.name; } void name_set(const std::string& value) { ThrowIfGameStateNotMutable(); - getGameState().scenarioName = value; + getGameState().scenarioOptions.name = value; } std::string details_get() { - return getGameState().scenarioDetails; + return getGameState().scenarioOptions.details; } void details_set(const std::string& value) { ThrowIfGameStateNotMutable(); - getGameState().scenarioDetails = value; + getGameState().scenarioOptions.details = value; } std::string completedBy_get() diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index 551938012b..de828b183e 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -313,9 +313,9 @@ namespace OpenRCT2::Park gameState.scenarioOptions.guestInitialHappiness = Park::CalculateGuestInitialHappiness(50); gameState.scenarioOptions.guestInitialHunger = 200; gameState.scenarioOptions.guestInitialThirst = 200; - gameState.scenarioObjective.Type = OBJECTIVE_GUESTS_BY; - gameState.scenarioObjective.Year = 4; - gameState.scenarioObjective.NumGuests = 1000; + gameState.scenarioOptions.objective.Type = OBJECTIVE_GUESTS_BY; + gameState.scenarioOptions.objective.Year = 4; + gameState.scenarioOptions.objective.NumGuests = 1000; gameState.landPrice = 90.00_GBP; gameState.constructionRightsPrice = 40.00_GBP; gameState.park.flags = PARK_FLAGS_NO_MONEY | PARK_FLAGS_SHOW_REAL_GUEST_NAMES; @@ -323,8 +323,8 @@ namespace OpenRCT2::Park FinanceResetHistory(); AwardReset(); - gameState.scenarioName.clear(); - gameState.scenarioDetails = String::toStd(LanguageGetString(STR_NO_DETAILS_YET)); + gameState.scenarioOptions.name.clear(); + gameState.scenarioOptions.details = String::toStd(LanguageGetString(STR_NO_DETAILS_YET)); } void Update(GameState_t& gameState, const Date& date) From 19dd05c32fd76467b00cf92626c1e519257efe00 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Fri, 22 Aug 2025 16:10:12 +0200 Subject: [PATCH 3/4] Move landPrice/constructionRightsPrice into Scenario::Options --- .../windows/EditorScenarioOptions.cpp | 24 +++++++++++-------- src/openrct2/GameState.h | 4 ++-- src/openrct2/actions/LandBuyRightsAction.cpp | 4 ++-- src/openrct2/actions/LandSetRightsAction.cpp | 8 +++---- .../actions/ScenarioSetSettingAction.cpp | 4 ++-- src/openrct2/interface/InteractiveConsole.cpp | 5 ++-- src/openrct2/park/ParkFile.cpp | 8 +++---- src/openrct2/rct1/S4Importer.cpp | 4 ++-- src/openrct2/rct2/S6Importer.cpp | 4 ++-- .../scripting/bindings/world/ScPark.cpp | 8 +++---- src/openrct2/world/Park.cpp | 4 ++-- 11 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/openrct2-ui/windows/EditorScenarioOptions.cpp b/src/openrct2-ui/windows/EditorScenarioOptions.cpp index 05b666e8bc..f1c58af133 100644 --- a/src/openrct2-ui/windows/EditorScenarioOptions.cpp +++ b/src/openrct2-ui/windows/EditorScenarioOptions.cpp @@ -2083,13 +2083,15 @@ namespace OpenRCT2::Ui::Windows void LandMouseDown(WidgetIndex widgetIndex) { auto& gameState = getGameState(); + auto& scenarioOptions = gameState.scenarioOptions; + switch (widgetIndex) { case WIDX_LAND_COST_INCREASE: - if (gameState.landPrice < 200.00_GBP) + if (scenarioOptions.landPrice < 200.00_GBP) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::CostToBuyLand, gameState.landPrice + 1.00_GBP); + ScenarioSetSetting::CostToBuyLand, scenarioOptions.landPrice + 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -2099,10 +2101,10 @@ namespace OpenRCT2::Ui::Windows Invalidate(); break; case WIDX_LAND_COST_DECREASE: - if (gameState.landPrice > 5.00_GBP) + if (scenarioOptions.landPrice > 5.00_GBP) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::CostToBuyLand, gameState.landPrice - 1.00_GBP); + ScenarioSetSetting::CostToBuyLand, scenarioOptions.landPrice - 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -2112,10 +2114,11 @@ namespace OpenRCT2::Ui::Windows Invalidate(); break; case WIDX_CONSTRUCTION_RIGHTS_COST_INCREASE: - if (gameState.constructionRightsPrice < 200.00_GBP) + if (scenarioOptions.constructionRightsPrice < 200.00_GBP) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::CostToBuyConstructionRights, gameState.constructionRightsPrice + 1.00_GBP); + ScenarioSetSetting::CostToBuyConstructionRights, + scenarioOptions.constructionRightsPrice + 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -2125,10 +2128,11 @@ namespace OpenRCT2::Ui::Windows Invalidate(); break; case WIDX_CONSTRUCTION_RIGHTS_COST_DECREASE: - if (gameState.constructionRightsPrice > 5.00_GBP) + if (scenarioOptions.constructionRightsPrice > 5.00_GBP) { auto scenarioSetSetting = ScenarioSetSettingAction( - ScenarioSetSetting::CostToBuyConstructionRights, gameState.constructionRightsPrice - 1.00_GBP); + ScenarioSetSetting::CostToBuyConstructionRights, + scenarioOptions.constructionRightsPrice - 1.00_GBP); GameActions::Execute(&scenarioSetSetting); } else @@ -2185,7 +2189,7 @@ namespace OpenRCT2::Ui::Windows // Cost to buy land value screenCoords = windowPos + ScreenCoordsXY{ landCostWidget.left + 1, landCostWidget.top }; auto ft = Formatter(); - ft.Add(gameState.landPrice); + ft.Add(gameState.scenarioOptions.landPrice); auto colour = !IsWidgetDisabled(WIDX_LAND_COST) ? wColour2 : wColour2.withFlag(ColourFlag::inset, true); DrawTextBasic(rt, screenCoords, STR_CURRENCY_FORMAT_LABEL, ft, colour); } @@ -2197,7 +2201,7 @@ namespace OpenRCT2::Ui::Windows screenCoords = windowPos + ScreenCoordsXY{ constructionRightsCostWidget.left + 1, constructionRightsCostWidget.top }; auto ft = Formatter(); - ft.Add(gameState.constructionRightsPrice); + ft.Add(gameState.scenarioOptions.constructionRightsPrice); auto colour = !IsWidgetDisabled(WIDX_CONSTRUCTION_RIGHTS_COST) ? wColour2 : wColour2.withFlag(ColourFlag::inset, true); DrawTextBasic(rt, screenCoords, STR_CURRENCY_FORMAT_LABEL, ft, colour); diff --git a/src/openrct2/GameState.h b/src/openrct2/GameState.h index 68443f9826..bee27d83c6 100644 --- a/src/openrct2/GameState.h +++ b/src/openrct2/GameState.h @@ -40,6 +40,8 @@ namespace OpenRCT2::Scenario std::string details; money64 initialCash; + money64 landPrice; + money64 constructionRightsPrice; money64 guestInitialCash; uint8_t guestInitialHappiness; @@ -71,8 +73,6 @@ namespace OpenRCT2 random_engine_t scenarioRand; TileCoordsXY mapSize; - money64 landPrice; - money64 constructionRightsPrice; EditorStep editorStep; diff --git a/src/openrct2/actions/LandBuyRightsAction.cpp b/src/openrct2/actions/LandBuyRightsAction.cpp index ec59bdd5c7..eb503e6201 100644 --- a/src/openrct2/actions/LandBuyRightsAction.cpp +++ b/src/openrct2/actions/LandBuyRightsAction.cpp @@ -143,7 +143,7 @@ GameActions::Result LandBuyRightsAction::MapBuyLandRightsForTile(const CoordsXY& surfaceElement->SetOwnership(OWNERSHIP_OWNED); Park::UpdateFencesAroundTile(loc); } - res.Cost = getGameState().landPrice; + res.Cost = getGameState().scenarioOptions.landPrice; return res; case LandBuyRightSetting::BuyConstructionRights: // 2 @@ -165,7 +165,7 @@ GameActions::Result LandBuyRightsAction::MapBuyLandRightsForTile(const CoordsXY& uint16_t baseZ = surfaceElement->GetBaseZ(); MapInvalidateTile({ loc, baseZ, baseZ + 16 }); } - res.Cost = getGameState().constructionRightsPrice; + res.Cost = getGameState().scenarioOptions.constructionRightsPrice; return res; default: diff --git a/src/openrct2/actions/LandSetRightsAction.cpp b/src/openrct2/actions/LandSetRightsAction.cpp index ac8a1da0c2..0b7bc0861f 100644 --- a/src/openrct2/actions/LandSetRightsAction.cpp +++ b/src/openrct2/actions/LandSetRightsAction.cpp @@ -193,23 +193,23 @@ GameActions::Result LandSetRightsAction::MapBuyLandRightsForTile(const CoordsXY& { // Buying land if (!(currentOwnership & OWNERSHIP_OWNED) && (_ownership & OWNERSHIP_OWNED)) - res.Cost = gameState.landPrice; + res.Cost = gameState.scenarioOptions.landPrice; // Buying construction rights if (!(currentOwnership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED) && (_ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)) - res.Cost = gameState.constructionRightsPrice; + res.Cost = gameState.scenarioOptions.constructionRightsPrice; } else { // Selling land if ((currentOwnership & OWNERSHIP_OWNED) && !(_ownership & OWNERSHIP_OWNED)) - res.Cost = -gameState.landPrice; + res.Cost = -gameState.scenarioOptions.landPrice; // Selling construction rights if ((currentOwnership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED) && !(_ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED)) - res.Cost = -gameState.constructionRightsPrice; + res.Cost = -gameState.scenarioOptions.constructionRightsPrice; } if (isExecuting) diff --git a/src/openrct2/actions/ScenarioSetSettingAction.cpp b/src/openrct2/actions/ScenarioSetSettingAction.cpp index 699df23200..b2cd442cbd 100644 --- a/src/openrct2/actions/ScenarioSetSettingAction.cpp +++ b/src/openrct2/actions/ScenarioSetSettingAction.cpp @@ -145,10 +145,10 @@ GameActions::Result ScenarioSetSettingAction::Execute() const } break; case ScenarioSetSetting::CostToBuyLand: - gameState.landPrice = std::clamp(_value, 5.00_GBP, 200.00_GBP); + gameState.scenarioOptions.landPrice = std::clamp(_value, 5.00_GBP, 200.00_GBP); break; case ScenarioSetSetting::CostToBuyConstructionRights: - gameState.constructionRightsPrice = std::clamp(_value, 5.00_GBP, 200.00_GBP); + gameState.scenarioOptions.constructionRightsPrice = std::clamp(_value, 5.00_GBP, 200.00_GBP); break; case ScenarioSetSetting::ParkChargeMethod: if (gLegacyScene == LegacyScene::scenarioEditor) diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index b3fc3973f1..43ff25f3a0 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -581,11 +581,12 @@ static void ConsoleCommandGet(InteractiveConsole& console, const arguments_t& ar } else if (argv[0] == "land_rights_cost") { - console.WriteLine(FormatString("land_rights_cost {CURRENCY2DP}", gameState.landPrice)); + console.WriteLine(FormatString("land_rights_cost {CURRENCY2DP}", gameState.scenarioOptions.landPrice)); } else if (argv[0] == "construction_rights_cost") { - console.WriteLine(FormatString("construction_rights_cost {CURRENCY2DP}", gameState.constructionRightsPrice)); + console.WriteLine( + FormatString("construction_rights_cost {CURRENCY2DP}", gameState.scenarioOptions.constructionRightsPrice)); } else if (argv[0] == "guest_initial_happiness") { diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index f4f77c85c6..5c8ccac126 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -629,13 +629,13 @@ namespace OpenRCT2 money16 tempConstructionRightPrice{}; cs.readWrite(tempLandPrice); cs.readWrite(tempConstructionRightPrice); - gameState.landPrice = ToMoney64(tempLandPrice); - gameState.constructionRightsPrice = ToMoney64(tempConstructionRightPrice); + gameState.scenarioOptions.landPrice = ToMoney64(tempLandPrice); + gameState.scenarioOptions.constructionRightsPrice = ToMoney64(tempConstructionRightPrice); } else { - cs.readWrite(gameState.landPrice); - cs.readWrite(gameState.constructionRightsPrice); + cs.readWrite(gameState.scenarioOptions.landPrice); + cs.readWrite(gameState.scenarioOptions.constructionRightsPrice); } cs.readWrite(gameState.grassSceneryTileLoopPosition); cs.readWrite(gameState.widePathTileLoopPosition); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 39c1ccd344..2cf11a3cf2 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1501,8 +1501,8 @@ namespace OpenRCT2::RCT1 void ImportFinance(GameState_t& gameState) { gameState.park.entranceFee = _s4.ParkEntranceFee; - gameState.landPrice = ToMoney64(_s4.LandPrice); - gameState.constructionRightsPrice = ToMoney64(_s4.ConstructionRightsPrice); + gameState.scenarioOptions.landPrice = ToMoney64(_s4.LandPrice); + gameState.scenarioOptions.constructionRightsPrice = ToMoney64(_s4.ConstructionRightsPrice); gameState.park.cash = ToMoney64(_s4.Cash); gameState.park.bankLoan = ToMoney64(_s4.Loan); diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 9301e6769f..75cd155ba5 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -511,8 +511,8 @@ namespace OpenRCT2::RCT2 } } - gameState.landPrice = ToMoney64(_s6.LandPrice); - gameState.constructionRightsPrice = ToMoney64(_s6.ConstructionRightsPrice); + gameState.scenarioOptions.landPrice = ToMoney64(_s6.LandPrice); + gameState.scenarioOptions.constructionRightsPrice = ToMoney64(_s6.ConstructionRightsPrice); // unk_01358774 // Pad01358776 // _s6.CdKey diff --git a/src/openrct2/scripting/bindings/world/ScPark.cpp b/src/openrct2/scripting/bindings/world/ScPark.cpp index e91e56f414..85ec31110a 100644 --- a/src/openrct2/scripting/bindings/world/ScPark.cpp +++ b/src/openrct2/scripting/bindings/world/ScPark.cpp @@ -254,22 +254,22 @@ namespace OpenRCT2::Scripting money64 ScPark::landPrice_get() const { - return getGameState().landPrice; + return getGameState().scenarioOptions.landPrice; } void ScPark::landPrice_set(money64 value) { ThrowIfGameStateNotMutable(); - getGameState().landPrice = value; + getGameState().scenarioOptions.landPrice = value; } money64 ScPark::constructionRightsPrice_get() const { - return getGameState().constructionRightsPrice; + return getGameState().scenarioOptions.constructionRightsPrice; } void ScPark::constructionRightsPrice_set(money64 value) { ThrowIfGameStateNotMutable(); - getGameState().constructionRightsPrice = value; + getGameState().scenarioOptions.constructionRightsPrice = value; } int16_t ScPark::casualtyPenalty_get() const diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index de828b183e..344272f601 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -316,8 +316,8 @@ namespace OpenRCT2::Park gameState.scenarioOptions.objective.Type = OBJECTIVE_GUESTS_BY; gameState.scenarioOptions.objective.Year = 4; gameState.scenarioOptions.objective.NumGuests = 1000; - gameState.landPrice = 90.00_GBP; - gameState.constructionRightsPrice = 40.00_GBP; + gameState.scenarioOptions.landPrice = 90.00_GBP; + gameState.scenarioOptions.constructionRightsPrice = 40.00_GBP; gameState.park.flags = PARK_FLAGS_NO_MONEY | PARK_FLAGS_SHOW_REAL_GUEST_NAMES; ResetHistories(gameState); FinanceResetHistory(); From 4535061f3653e94d3d0379f9b01ff1688e38e355 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Fri, 22 Aug 2025 17:43:44 +0200 Subject: [PATCH 4/4] Move ScenarioOptions struct into its own header file --- src/openrct2/GameState.h | 23 +--------------- src/openrct2/libopenrct2.vcxproj | 1 + src/openrct2/scenario/ScenarioOptions.h | 35 +++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 src/openrct2/scenario/ScenarioOptions.h diff --git a/src/openrct2/GameState.h b/src/openrct2/GameState.h index bee27d83c6..8cb4c56255 100644 --- a/src/openrct2/GameState.h +++ b/src/openrct2/GameState.h @@ -19,7 +19,7 @@ #include "management/NewsItem.h" #include "ride/Ride.h" #include "ride/RideRatings.h" -#include "scenario/Scenario.h" +#include "scenario/ScenarioOptions.h" #include "world/Banner.h" #include "world/Climate.h" #include "world/Location.hpp" @@ -30,29 +30,8 @@ #include #include -namespace OpenRCT2::Scenario -{ - struct Options - { - Objective objective; - ScenarioCategory category; - std::string name; - std::string details; - - money64 initialCash; - money64 landPrice; - money64 constructionRightsPrice; - - money64 guestInitialCash; - uint8_t guestInitialHappiness; - uint8_t guestInitialHunger; - uint8_t guestInitialThirst; - }; -} // namespace OpenRCT2::Scenario - namespace OpenRCT2 { - struct GameState_t { Park::ParkData park{}; diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 961671dc82..f23c1d52c0 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -548,6 +548,7 @@ + diff --git a/src/openrct2/scenario/ScenarioOptions.h b/src/openrct2/scenario/ScenarioOptions.h new file mode 100644 index 0000000000..b8b7292186 --- /dev/null +++ b/src/openrct2/scenario/ScenarioOptions.h @@ -0,0 +1,35 @@ +/***************************************************************************** + * Copyright (c) 2014-2025 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../core/Money.hpp" +#include "Scenario.h" + +#include + +namespace OpenRCT2::Scenario +{ + struct Options + { + Objective objective; + ScenarioCategory category; + std::string name; + std::string details; + + money64 initialCash; + money64 landPrice; + money64 constructionRightsPrice; + + money64 guestInitialCash; + uint8_t guestInitialHappiness; + uint8_t guestInitialHunger; + uint8_t guestInitialThirst; + }; +} // namespace OpenRCT2::Scenario