1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 20:43:04 +01:00

#21193: Move gParkEntranceFee to GameState_t (#21256)

This commit is contained in:
Hielke Morsink
2024-01-24 13:45:01 +01:00
committed by GitHub
parent b200ce02ef
commit fb420f6516
14 changed files with 33 additions and 30 deletions

View File

@@ -1055,10 +1055,10 @@ private:
Invalidate();
break;
case WIDX_ENTRY_PRICE_INCREASE:
if (gParkEntranceFee < MAX_ENTRANCE_FEE)
if (gameState.ParkEntranceFee < MAX_ENTRANCE_FEE)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::ParkChargeEntryFee, gParkEntranceFee + 1.00_GBP);
ScenarioSetSetting::ParkChargeEntryFee, gameState.ParkEntranceFee + 1.00_GBP);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -1068,10 +1068,10 @@ private:
Invalidate();
break;
case WIDX_ENTRY_PRICE_DECREASE:
if (gParkEntranceFee > 0.00_GBP)
if (gameState.ParkEntranceFee > 0.00_GBP)
{
auto scenarioSetSetting = ScenarioSetSettingAction(
ScenarioSetSetting::ParkChargeEntryFee, gParkEntranceFee - 1.00_GBP);
ScenarioSetSetting::ParkChargeEntryFee, gameState.ParkEntranceFee - 1.00_GBP);
GameActions::Execute(&scenarioSetSetting);
}
else
@@ -1202,6 +1202,7 @@ private:
WindowDrawWidgets(*this, dpi);
DrawTabImages(dpi);
const auto& gameState = GetGameState();
const auto& landCostWidget = widgets[WIDX_LAND_COST];
if (landCostWidget.type != WindowWidgetType::Empty)
{
@@ -1237,7 +1238,6 @@ private:
// Pay for park or rides label
screenCoords = windowPos + ScreenCoordsXY{ payForParkOrRidesWidget.left + 1, payForParkOrRidesWidget.top };
auto& gameState = GetGameState();
auto ft = Formatter();
// Pay for park and/or rides value
if (gameState.ParkFlags & PARK_FLAGS_UNLOCK_ALL_PRICES)
@@ -1260,7 +1260,7 @@ private:
// Entry price value
screenCoords = windowPos + ScreenCoordsXY{ entryPriceWidget.left + 1, entryPriceWidget.top };
auto ft = Formatter();
ft.Add<money64>(gParkEntranceFee);
ft.Add<money64>(gameState.ParkEntranceFee);
DrawTextBasic(dpi, screenCoords, STR_CURRENCY_FORMAT_LABEL, ft);
}
@@ -1272,7 +1272,7 @@ private:
// Climate value
screenCoords = windowPos + ScreenCoordsXY{ climateWidget.left + 1, climateWidget.top };
auto ft = Formatter();
ft.Add<StringId>(ClimateNames[static_cast<uint8_t>(GetGameState().Climate)]);
ft.Add<StringId>(ClimateNames[static_cast<uint8_t>(gameState.Climate)]);
DrawTextBasic(dpi, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft);
}

View File

@@ -823,18 +823,19 @@ private:
void OnMouseDownPrice(WidgetIndex widgetIndex)
{
const auto& gameState = GetGameState();
switch (widgetIndex)
{
case WIDX_INCREASE_PRICE:
{
const auto newFee = std::min(MAX_ENTRANCE_FEE, gParkEntranceFee + 1.00_GBP);
const auto newFee = std::min(MAX_ENTRANCE_FEE, gameState.ParkEntranceFee + 1.00_GBP);
auto gameAction = ParkSetEntranceFeeAction(newFee);
GameActions::Execute(&gameAction);
break;
}
case WIDX_DECREASE_PRICE:
{
const auto newFee = std::max(0.00_GBP, gParkEntranceFee - 1.00_GBP);
const auto newFee = std::max(0.00_GBP, gameState.ParkEntranceFee - 1.00_GBP);
auto gameAction = ParkSetEntranceFeeAction(newFee);
GameActions::Execute(&gameAction);
break;

View File

@@ -325,7 +325,7 @@ namespace Editor
{
gameState.ParkFlags |= PARK_FLAGS_NO_MONEY;
if (gParkEntranceFee == 0)
if (gameState.ParkEntranceFee == 0)
{
gameState.ParkFlags |= PARK_FLAGS_PARK_FREE_ENTRY;
}

View File

@@ -27,6 +27,7 @@ namespace OpenRCT2
uint32_t CurrentTicks{};
uint64_t ParkFlags;
uint16_t ParkRating;
money64 ParkEntranceFee;
ClimateType Climate;
ClimateState ClimateCurrent;
ClimateState ClimateNext;

View File

@@ -57,7 +57,7 @@ GameActions::Result ParkSetEntranceFeeAction::Query() const
GameActions::Result ParkSetEntranceFeeAction::Execute() const
{
gParkEntranceFee = _fee;
GetGameState().ParkEntranceFee = _fee;
WindowInvalidateByClass(WindowClass::ParkInformation);
return GameActions::Result();
}

View File

@@ -210,7 +210,8 @@ GameActions::Result RideCreateAction::Execute() const
price = 0;
}
if (!(GetGameState().ParkFlags & PARK_FLAGS_NO_MONEY))
const auto& gameState = GetGameState();
if (!(gameState.ParkFlags & PARK_FLAGS_NO_MONEY))
{
for (auto i = 0; i < RCT2::ObjectLimits::MaxShopItemsPerRideEntry; i++)
{
@@ -219,7 +220,7 @@ GameActions::Result RideCreateAction::Execute() const
if (rideEntry->shop_item[0] == ShopItem::None)
{
if (!ParkRidePricesUnlocked() || gParkEntranceFee > 0)
if (!ParkRidePricesUnlocked() || gameState.ParkEntranceFee > 0)
{
ride->price[0] = 0;
}

View File

@@ -157,19 +157,19 @@ GameActions::Result ScenarioSetSettingAction::Execute() const
{
gameState.ParkFlags |= PARK_FLAGS_PARK_FREE_ENTRY;
gameState.ParkFlags &= ~PARK_FLAGS_UNLOCK_ALL_PRICES;
gParkEntranceFee = 0.00_GBP;
gameState.ParkEntranceFee = 0.00_GBP;
}
else if (_value == 1)
{
gameState.ParkFlags &= ~PARK_FLAGS_PARK_FREE_ENTRY;
gameState.ParkFlags &= ~PARK_FLAGS_UNLOCK_ALL_PRICES;
gParkEntranceFee = 10.00_GBP;
gameState.ParkEntranceFee = 10.00_GBP;
}
else
{
gameState.ParkFlags |= PARK_FLAGS_PARK_FREE_ENTRY;
gameState.ParkFlags |= PARK_FLAGS_UNLOCK_ALL_PRICES;
gParkEntranceFee = 10.00_GBP;
gameState.ParkEntranceFee = 10.00_GBP;
}
}
else
@@ -194,7 +194,7 @@ GameActions::Result ScenarioSetSettingAction::Execute() const
}
break;
case ScenarioSetSetting::ParkChargeEntryFee:
gParkEntranceFee = std::clamp<money64>(_value, 0.00_GBP, MAX_ENTRANCE_FEE);
gameState.ParkEntranceFee = std::clamp<money64>(_value, 0.00_GBP, MAX_ENTRANCE_FEE);
WindowInvalidateByClass(WindowClass::ParkInformation);
break;
case ScenarioSetSetting::ForbidTreeRemoval:

View File

@@ -811,11 +811,11 @@ namespace OpenRCT2
{
money16 tempParkEntranceFee{};
cs.ReadWrite(tempParkEntranceFee);
gParkEntranceFee = ToMoney64(tempParkEntranceFee);
gameState.ParkEntranceFee = ToMoney64(tempParkEntranceFee);
}
else
{
cs.ReadWrite(gParkEntranceFee);
cs.ReadWrite(gameState.ParkEntranceFee);
}
cs.ReadWrite(gStaffHandymanColour);

View File

@@ -1391,7 +1391,7 @@ namespace RCT1
void ImportFinance(GameState_t& gameState)
{
gParkEntranceFee = _s4.ParkEntranceFee;
gameState.ParkEntranceFee = _s4.ParkEntranceFee;
gLandPrice = ToMoney64(_s4.LandPrice);
gConstructionRightsPrice = ToMoney64(_s4.ConstructionRightsPrice);

View File

@@ -274,7 +274,7 @@ namespace RCT2
gameState.ParkFlags &= ~PARK_FLAGS_NO_MONEY;
}
gParkEntranceFee = _s6.ParkEntranceFee;
gameState.ParkEntranceFee = _s6.ParkEntranceFee;
// rct1_park_entranceX
// rct1_park_entrance_y
// Pad013573EE

View File

@@ -183,7 +183,7 @@ void ScenarioReset()
if (gameState.ParkFlags & PARK_FLAGS_NO_MONEY)
{
gameState.ParkFlags |= PARK_FLAGS_PARK_OPEN;
gParkEntranceFee = 0;
gameState.ParkEntranceFee = 0;
}
gameState.ParkFlags |= PARK_FLAGS_SPRITES_INITIALISED;

View File

@@ -118,15 +118,16 @@ namespace OpenRCT2::Scripting
money64 ScPark::entranceFee_get() const
{
return gParkEntranceFee;
return GetGameState().ParkEntranceFee;
}
void ScPark::entranceFee_set(money64 value)
{
ThrowIfGameStateNotMutable();
if (gParkEntranceFee != value)
auto& gameState = GetGameState();
if (gameState.ParkEntranceFee != value)
{
gParkEntranceFee = value;
gameState.ParkEntranceFee = value;
WindowInvalidateByClass(WindowClass::ParkInformation);
}
}

View File

@@ -46,7 +46,6 @@
using namespace OpenRCT2;
money64 gParkEntranceFee;
uint32_t gParkSize;
money64 gLandPrice;
money64 gConstructionRightsPrice;
@@ -191,7 +190,8 @@ int32_t ParkGetForcedRating()
money64 ParkGetEntranceFee()
{
if (GetGameState().ParkFlags & PARK_FLAGS_NO_MONEY)
const auto& gameState = GetGameState();
if (gameState.ParkFlags & PARK_FLAGS_NO_MONEY)
{
return 0;
}
@@ -199,7 +199,7 @@ money64 ParkGetEntranceFee()
{
return 0;
}
return gParkEntranceFee;
return gameState.ParkEntranceFee;
}
bool ParkRidePricesUnlocked()
@@ -277,7 +277,7 @@ void Park::Initialise()
SetAllSceneryItemsInvented();
gParkEntranceFee = 10.00_GBP;
gameState.ParkEntranceFee = 10.00_GBP;
gPeepSpawns.clear();
ParkEntranceReset();

View File

@@ -92,7 +92,6 @@ namespace OpenRCT2
};
} // namespace OpenRCT2
extern money64 gParkEntranceFee;
extern uint32_t gParkSize;
extern money64 gLandPrice;
extern money64 gConstructionRightsPrice;