diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 5fcacffb73..642b3b26a1 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -5914,23 +5914,24 @@ private: static void UpdateSamePriceThroughoutFlags(ShopItem shop_item) { + const auto& gameState = GetGameState(); + const auto existingFlags = gameState.SamePriceThroughoutPark; + + auto newFlags = existingFlags; if (GetShopItemDescriptor(shop_item).IsPhoto()) { - auto newFlags = gSamePriceThroughoutPark; - if (gSamePriceThroughoutPark & EnumToFlag(shop_item)) + if (existingFlags & EnumToFlag(shop_item)) newFlags &= ~EnumsToFlags(ShopItem::Photo, ShopItem::Photo2, ShopItem::Photo3, ShopItem::Photo4); else newFlags |= EnumsToFlags(ShopItem::Photo, ShopItem::Photo2, ShopItem::Photo3, ShopItem::Photo4); - auto parkSetParameter = ParkSetParameterAction(ParkParameter::SamePriceInPark, newFlags); - GameActions::Execute(&parkSetParameter); } else { - auto newFlags = gSamePriceThroughoutPark; newFlags ^= EnumToFlag(shop_item); - auto parkSetParameter = ParkSetParameterAction(ParkParameter::SamePriceInPark, newFlags); - GameActions::Execute(&parkSetParameter); } + + auto parkSetParameter = ParkSetParameterAction(ParkParameter::SamePriceInPark, newFlags); + GameActions::Execute(&parkSetParameter); } void IncomeTogglePrimaryPrice() diff --git a/src/openrct2/GameState.h b/src/openrct2/GameState.h index 09034b7945..8018ef152e 100644 --- a/src/openrct2/GameState.h +++ b/src/openrct2/GameState.h @@ -101,6 +101,7 @@ namespace OpenRCT2 colour_t StaffHandymanColour; colour_t StaffMechanicColour; colour_t StaffSecurityColour; + uint64_t SamePriceThroughoutPark{}; uint8_t ResearchFundingLevel; uint8_t ResearchPriorities; diff --git a/src/openrct2/actions/ParkSetParameterAction.cpp b/src/openrct2/actions/ParkSetParameterAction.cpp index af35815c34..0da59e5072 100644 --- a/src/openrct2/actions/ParkSetParameterAction.cpp +++ b/src/openrct2/actions/ParkSetParameterAction.cpp @@ -73,7 +73,7 @@ GameActions::Result ParkSetParameterAction::Execute() const } break; case ParkParameter::SamePriceInPark: - gSamePriceThroughoutPark = _value; + gameState.SamePriceThroughoutPark = _value; WindowInvalidateByClass(WindowClass::Ride); break; default: diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index a71f89e5b0..6d609c902c 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -821,7 +821,7 @@ namespace OpenRCT2 cs.ReadWrite(gameState.StaffHandymanColour); cs.ReadWrite(gameState.StaffMechanicColour); cs.ReadWrite(gameState.StaffSecurityColour); - cs.ReadWrite(gSamePriceThroughoutPark); + cs.ReadWrite(gameState.SamePriceThroughoutPark); // Finances if (cs.GetMode() == OrcaStream::Mode::READING) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 970d5ee818..4c4c21f2d0 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2236,10 +2236,10 @@ namespace RCT1 gameState.ParkSize = _s4.ParkSize; gameState.TotalRideValueForMoney = _s4.TotalRideValueForMoney; - gSamePriceThroughoutPark = 0; + gameState.SamePriceThroughoutPark = 0; if (_gameVersion == FILE_VERSION_RCT1_LL) { - gSamePriceThroughoutPark = _s4.SamePriceThroughout; + gameState.SamePriceThroughoutPark = _s4.SamePriceThroughout; } } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 36f8b5e86a..0416d109e9 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -403,7 +403,8 @@ namespace RCT2 // Pad013587FC gParkRatingCasualtyPenalty = _s6.ParkRatingCasualtyPenalty; gameState.MapSize = { _s6.MapSize, _s6.MapSize }; - gSamePriceThroughoutPark = _s6.SamePriceThroughout | (static_cast(_s6.SamePriceThroughoutExtended) << 32); + gameState.SamePriceThroughoutPark = _s6.SamePriceThroughout + | (static_cast(_s6.SamePriceThroughoutExtended) << 32); gameState.SuggestedGuestMaximum = _s6.SuggestedMaxGuests; gameState.ScenarioParkRatingWarningDays = _s6.ParkRatingWarningDays; gLastEntranceStyle = _s6.LastEntranceStyle; diff --git a/src/openrct2/ride/ShopItem.cpp b/src/openrct2/ride/ShopItem.cpp index 1dd91d92ed..f85620c1a2 100644 --- a/src/openrct2/ride/ShopItem.cpp +++ b/src/openrct2/ride/ShopItem.cpp @@ -9,19 +9,20 @@ #include "ShopItem.h" +#include "../GameState.h" #include "../common.h" #include "../entity/Guest.h" #include "../localisation/StringIds.h" #include "../ride/RideEntry.h" #include "../sprites.h" +using namespace OpenRCT2; + ShopItem& operator++(ShopItem& d, int) { return d = (d == ShopItem::Count) ? ShopItem::Balloon : ShopItem(EnumValue(d) + 1); } -uint64_t gSamePriceThroughoutPark; - // clang-format off /** rct2: 0x00982164 (cost, base value, hot and cold value); 0x00982358 (default price) */ constexpr ShopItemDescriptor ShopItems[EnumValue(ShopItem::Count)] = { @@ -146,7 +147,7 @@ money64 ShopItemGetCommonPrice(Ride* forRide, const ShopItem shopItem) bool ShopItemHasCommonPrice(const ShopItem shopItem) { - return (gSamePriceThroughoutPark & EnumToFlag(shopItem)) != 0; + return (GetGameState().SamePriceThroughoutPark & EnumToFlag(shopItem)) != 0; } bool ShopItemDescriptor::IsFood() const diff --git a/src/openrct2/ride/ShopItem.h b/src/openrct2/ride/ShopItem.h index 241ecfae5f..9aa53277c5 100644 --- a/src/openrct2/ride/ShopItem.h +++ b/src/openrct2/ride/ShopItem.h @@ -128,8 +128,6 @@ enum SHOP_ITEM_FLAG_IS_RECOLOURABLE = (1 << 5), }; -extern uint64_t gSamePriceThroughoutPark; - money64 ShopItemGetCommonPrice(Ride* forRide, const ShopItem shopItem); bool ShopItemHasCommonPrice(const ShopItem shopItem);