Skip to content

Commit

Permalink
OpenRCT2#21193: Move gParkRatingHistory to GameState_t
Browse files Browse the repository at this point in the history
  • Loading branch information
Broxzier committed Feb 6, 2024
1 parent 9363a45 commit 695a171
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 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 @@ -728,7 +728,7 @@ class ParkWindow final : public Window
// Graph
screenPos = windowPos + ScreenCoordsXY{ widget->left + 47, widget->top + 26 };

Graph::Draw(dpi, gParkRatingHistory, 32, screenPos);
Graph::Draw(dpi, GetGameState().ParkRatingHistory, 32, screenPos);
}

#pragma endregion
Expand Down
1 change: 1 addition & 0 deletions src/openrct2/GameState.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace OpenRCT2
uint32_t ParkSize;
money64 ParkValue;
money64 ParkValueHistory[FINANCE_GRAPH_SIZE];
uint8_t ParkRatingHistory[32];
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 @@ -917,7 +917,7 @@ namespace OpenRCT2
return true;
});

cs.ReadWriteArray(gParkRatingHistory, [&cs](uint8_t& value) {
cs.ReadWriteArray(gameState.ParkRatingHistory, [&cs](uint8_t& value) {
cs.ReadWrite(value);
return true;
});
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 @@ -2131,7 +2131,7 @@ namespace RCT1

auto& park = OpenRCT2::GetContext()->GetGameState()->GetPark();
park.ResetHistories();
std::copy(std::begin(_s4.ParkRatingHistory), std::end(_s4.ParkRatingHistory), gParkRatingHistory);
std::copy(std::begin(_s4.ParkRatingHistory), std::end(_s4.ParkRatingHistory), gameState.ParkRatingHistory);
for (size_t i = 0; i < std::size(_s4.GuestsInParkHistory); i++)
{
if (_s4.GuestsInParkHistory[i] != RCT12ParkHistoryUndefined)
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 @@ -309,7 +309,7 @@ namespace RCT2

auto& park = OpenRCT2::GetContext()->GetGameState()->GetPark();
park.ResetHistories();
std::copy(std::begin(_s6.ParkRatingHistory), std::end(_s6.ParkRatingHistory), gParkRatingHistory);
std::copy(std::begin(_s6.ParkRatingHistory), std::end(_s6.ParkRatingHistory), gameState.ParkRatingHistory);
for (size_t i = 0; i < std::size(_s6.GuestsInParkHistory); i++)
{
if (_s6.GuestsInParkHistory[i] != RCT12ParkHistoryUndefined)
Expand Down
6 changes: 3 additions & 3 deletions src/openrct2/world/Park.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ money64 gTotalIncomeFromAdmissions;
money64 gCompanyValue;

int16_t gParkRatingCasualtyPenalty;
uint8_t gParkRatingHistory[32];
uint32_t gGuestsInParkHistory[32];

// If this value is more than or equal to 0, the park rating is forced to this value. Used for cheat
Expand Down Expand Up @@ -745,7 +744,8 @@ template<typename T, size_t TSize> static void HistoryPushRecord(T history[TSize

void Park::ResetHistories()
{
std::fill(std::begin(gParkRatingHistory), std::end(gParkRatingHistory), ParkRatingHistoryUndefined);
auto& gameState = GetGameState();
std::fill(std::begin(gameState.ParkRatingHistory), std::end(gameState.ParkRatingHistory), ParkRatingHistoryUndefined);
std::fill(std::begin(gGuestsInParkHistory), std::end(gGuestsInParkHistory), GuestsInParkHistoryUndefined);
}

Expand All @@ -767,7 +767,7 @@ void Park::UpdateHistories()
gameState.NumGuestsInParkLastWeek = gameState.NumGuestsInPark;

// Update park rating, guests in park and current cash history
HistoryPushRecord<uint8_t, 32>(gParkRatingHistory, gameState.ParkRating / 4);
HistoryPushRecord<uint8_t, 32>(gameState.ParkRatingHistory, gameState.ParkRating / 4);
HistoryPushRecord<uint32_t, 32>(gGuestsInParkHistory, gameState.NumGuestsInPark);
HistoryPushRecord<money64, std::size(gCashHistory)>(gCashHistory, FinanceGetCurrentCash() - gBankLoan);

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 @@ -101,7 +101,6 @@ extern money64 gTotalIncomeFromAdmissions;
extern money64 gCompanyValue;

extern int16_t gParkRatingCasualtyPenalty;
extern uint8_t gParkRatingHistory[32];
extern uint32_t gGuestsInParkHistory[32];
extern int32_t _guestGenerationProbability;
extern uint32_t _suggestedGuestMaximum;
Expand Down

0 comments on commit 695a171

Please sign in to comment.