Skip to content

Commit

Permalink
OpenRCT2#21193: Move gParkValueHistory to GameState_t
Browse files Browse the repository at this point in the history
  • Loading branch information
Broxzier committed Jan 25, 2024
1 parent 0c10435 commit 99e1746
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/openrct2-ui/windows/Finances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ class FinancesWindow final : public Window
int32_t yAxisScale = 0;
for (int32_t i = 0; i < 64; i++)
{
auto balance = gParkValueHistory[i];
auto balance = gameState.ParkValueHistory[i];
if (balance == MONEY64_UNDEFINED)
continue;

Expand Down Expand Up @@ -723,7 +723,7 @@ class FinancesWindow final : public Window

// X axis labels and values
coords = graphTopLeft + ScreenCoordsXY{ 98, 17 };
Graph::Draw(dpi, gParkValueHistory, 64, coords, yAxisScale, 0);
Graph::Draw(dpi, gameState.ParkValueHistory, 64, coords, yAxisScale, 0);
}

#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 @@ -32,6 +32,7 @@ namespace OpenRCT2
money64 ParkEntranceFee;
uint32_t ParkSize;
money64 ParkValue;
money64 ParkValueHistory[FINANCE_GRAPH_SIZE];
ClimateType Climate;
ClimateState ClimateCurrent;
ClimateState ClimateNext;
Expand Down
3 changes: 1 addition & 2 deletions src/openrct2/management/Finance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ money64 gCurrentExpenditure;
money64 gCurrentProfit;
money64 gHistoricalProfit;
money64 gCashHistory[FINANCE_GRAPH_SIZE];
money64 gParkValueHistory[FINANCE_GRAPH_SIZE];
money64 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][static_cast<int32_t>(ExpenditureType::Count)];

/**
Expand Down Expand Up @@ -195,7 +194,7 @@ void FinanceResetHistory()
{
gCashHistory[i] = MONEY64_UNDEFINED;
gameState.WeeklyProfitHistory[i] = MONEY64_UNDEFINED;
gParkValueHistory[i] = MONEY64_UNDEFINED;
gameState.ParkValueHistory[i] = MONEY64_UNDEFINED;
}

for (uint32_t i = 0; i < EXPENDITURE_TABLE_MONTH_COUNT; ++i)
Expand Down
1 change: 0 additions & 1 deletion src/openrct2/management/Finance.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ extern money64 gCurrentProfit;
extern money64 gHistoricalProfit;

extern money64 gCashHistory[FINANCE_GRAPH_SIZE];
extern money64 gParkValueHistory[FINANCE_GRAPH_SIZE];
extern money64 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][static_cast<int32_t>(ExpenditureType::Count)];

bool FinanceCheckMoneyRequired(uint32_t flags);
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 @@ -935,7 +935,7 @@ namespace OpenRCT2
cs.ReadWrite(value);
return true;
});
cs.ReadWriteArray(gParkValueHistory, [&cs](money64& value) {
cs.ReadWriteArray(gameState.ParkValueHistory, [&cs](money64& 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 @@ -1409,7 +1409,7 @@ namespace RCT1
for (size_t i = 0; i < Limits::FinanceGraphSize; i++)
{
gCashHistory[i] = ToMoney64(_s4.CashHistory[i]);
gParkValueHistory[i] = CorrectRCT1ParkValue(_s4.ParkValueHistory[i]);
gameState.ParkValueHistory[i] = CorrectRCT1ParkValue(_s4.ParkValueHistory[i]);
gameState.WeeklyProfitHistory[i] = ToMoney64(_s4.WeeklyProfitHistory[i]);
}

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 @@ -366,7 +366,7 @@ namespace RCT2
{
gCashHistory[i] = ToMoney64(_s6.BalanceHistory[i]);
gameState.WeeklyProfitHistory[i] = ToMoney64(_s6.WeeklyProfitHistory[i]);
gParkValueHistory[i] = ToMoney64(_s6.ParkValueHistory[i]);
gameState.ParkValueHistory[i] = ToMoney64(_s6.ParkValueHistory[i]);
}

gameState.ScenarioCompletedCompanyValue = RCT12CompletedCompanyValueToOpenRCT2(_s6.CompletedCompanyValue);
Expand Down
4 changes: 3 additions & 1 deletion src/openrct2/world/Park.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

#include <algorithm>
#include <limits>
#include <type_traits>

using namespace OpenRCT2;

Expand Down Expand Up @@ -777,7 +778,8 @@ void Park::UpdateHistories()
gameState.WeeklyProfitAverageDivisor = 0;

// Update park value history
HistoryPushRecord<money64, std::size(gParkValueHistory)>(gParkValueHistory, gameState.ParkValue);
HistoryPushRecord<money64, std::extent_v<decltype(GameState_t::ParkValueHistory)>>(
gameState.ParkValueHistory, gameState.ParkValue);

// Invalidate relevant windows
auto intent = Intent(INTENT_ACTION_UPDATE_GUEST_COUNT);
Expand Down

0 comments on commit 99e1746

Please sign in to comment.