1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-25 15:54:31 +01:00

Move gSamePriceThroughoutPark to GameState_t

This commit is contained in:
Jan Kelemen
2024-03-05 22:31:27 +01:00
parent 33a5ee2160
commit ee4e8d0323
8 changed files with 19 additions and 17 deletions

View File

@@ -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()

View File

@@ -101,6 +101,7 @@ namespace OpenRCT2
colour_t StaffHandymanColour;
colour_t StaffMechanicColour;
colour_t StaffSecurityColour;
uint64_t SamePriceThroughoutPark{};
uint8_t ResearchFundingLevel;
uint8_t ResearchPriorities;

View File

@@ -73,7 +73,7 @@ GameActions::Result ParkSetParameterAction::Execute() const
}
break;
case ParkParameter::SamePriceInPark:
gSamePriceThroughoutPark = _value;
gameState.SamePriceThroughoutPark = _value;
WindowInvalidateByClass(WindowClass::Ride);
break;
default:

View File

@@ -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)

View File

@@ -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;
}
}

View File

@@ -403,7 +403,8 @@ namespace RCT2
// Pad013587FC
gParkRatingCasualtyPenalty = _s6.ParkRatingCasualtyPenalty;
gameState.MapSize = { _s6.MapSize, _s6.MapSize };
gSamePriceThroughoutPark = _s6.SamePriceThroughout | (static_cast<uint64_t>(_s6.SamePriceThroughoutExtended) << 32);
gameState.SamePriceThroughoutPark = _s6.SamePriceThroughout
| (static_cast<uint64_t>(_s6.SamePriceThroughoutExtended) << 32);
gameState.SuggestedGuestMaximum = _s6.SuggestedMaxGuests;
gameState.ScenarioParkRatingWarningDays = _s6.ParkRatingWarningDays;
gLastEntranceStyle = _s6.LastEntranceStyle;

View File

@@ -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

View File

@@ -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);