Skip to content

Commit

Permalink
OpenRCT2#21193: Move gParkSize to GameState_t
Browse files Browse the repository at this point in the history
  • Loading branch information
Broxzier committed Jan 24, 2024
1 parent fb420f6 commit f26d813
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/openrct2-ui/windows/Park.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ class ParkWindow final : public Window
+ ScreenCoordsXY{ widgets[WIDX_PAGE_BACKGROUND].left + 4, widgets[WIDX_PAGE_BACKGROUND].top + 4 };

// Draw park size
auto parkSize = gParkSize * 10;
auto parkSize = GetGameState().ParkSize * 10;
auto stringIndex = STR_PARK_SIZE_METRIC_LABEL;
if (gConfigGeneral.MeasurementFormat == MeasurementFormat::Imperial)
{
Expand Down
1 change: 1 addition & 0 deletions src/openrct2/GameState.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace OpenRCT2
uint64_t ParkFlags;
uint16_t ParkRating;
money64 ParkEntranceFee;
uint32_t ParkSize;
ClimateType Climate;
ClimateState ClimateCurrent;
ClimateState ClimateNext;
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/park/ParkFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ namespace OpenRCT2
}
cs.ReadWrite(gParkValue);
cs.ReadWrite(gCompanyValue);
cs.ReadWrite(gParkSize);
cs.ReadWrite(gameState.ParkSize);
cs.ReadWrite(gNumGuestsInPark);
cs.ReadWrite(gNumGuestsHeadingForPark);
cs.ReadWrite(gameState.ParkRating);
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/rct1/S4Importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,7 @@ namespace RCT1
gameState.ParkFlags |= PARK_FLAGS_UNLOCK_ALL_PRICES;
}

gParkSize = _s4.ParkSize;
gameState.ParkSize = _s4.ParkSize;
gTotalRideValueForMoney = _s4.TotalRideValueForMoney;
gSamePriceThroughoutPark = 0;
if (_gameVersion == FILE_VERSION_RCT1_LL)
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/rct2/S6Importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ namespace RCT2
gResearchExpectedDay = _s6.NextResearchExpectedDay;
gResearchExpectedMonth = _s6.NextResearchExpectedMonth;
gameState.GuestInitialHappiness = _s6.GuestInitialHappiness;
gParkSize = _s6.ParkSize;
gameState.ParkSize = _s6.ParkSize;
_guestGenerationProbability = _s6.GuestGenerationProbability;
gTotalRideValueForMoney = _s6.TotalRideValueForMoney;
gMaxBankLoan = ToMoney64(_s6.MaximumLoan);
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/scripting/bindings/world/ScPark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ namespace OpenRCT2::Scripting

uint16_t ScPark::parkSize_get() const
{
return gParkSize;
return GetGameState().ParkSize;
}

std::string ScPark::name_get() const
Expand Down
13 changes: 7 additions & 6 deletions src/openrct2/world/Park.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

using namespace OpenRCT2;

uint32_t gParkSize;
money64 gLandPrice;
money64 gConstructionRightsPrice;

Expand Down Expand Up @@ -336,7 +335,7 @@ void Park::Update(const Date& date)
// Every ~102 seconds
if (currentTicks % 4096 == 0)
{
gParkSize = CalculateParkSize();
gameState.ParkSize = CalculateParkSize();
WindowInvalidateByClass(WindowClass::ParkInformation);
}

Expand All @@ -359,9 +358,10 @@ uint32_t Park::CalculateParkSize() const
}
} while (TileElementIteratorNext(&it));

if (tiles != gParkSize)
auto& gameState = GetGameState();
if (tiles != gameState.ParkSize)
{
gParkSize = tiles;
gameState.ParkSize = tiles;
WindowInvalidateByClass(WindowClass::ParkInformation);
}

Expand Down Expand Up @@ -794,10 +794,11 @@ int32_t ParkIsOpen()

uint32_t ParkCalculateSize()
{
auto& gameState = GetGameState();
auto tiles = GetContext()->GetGameState()->GetPark().CalculateParkSize();
if (tiles != gParkSize)
if (tiles != gameState.ParkSize)
{
gParkSize = tiles;
gameState.ParkSize = tiles;
WindowInvalidateByClass(WindowClass::ParkInformation);
}
return tiles;
Expand Down
1 change: 0 additions & 1 deletion src/openrct2/world/Park.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ namespace OpenRCT2
};
} // namespace OpenRCT2

extern uint32_t gParkSize;
extern money64 gLandPrice;
extern money64 gConstructionRightsPrice;

Expand Down

0 comments on commit f26d813

Please sign in to comment.