1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Merge pull request #21510 from jan-kelemen/gCashHistory_to_GameState_t

Move gCashHistory to GameState_t
This commit is contained in:
Matt
2024-03-03 11:36:31 +02:00
committed by GitHub
9 changed files with 11 additions and 9 deletions

View File

@@ -234,6 +234,7 @@ Appreciation for contributors who have provided substantial work, but are no lon
* Michael Bernardi (mrmbernardi)
* Aram Kazorian (aramk-hub)
* Harry Hopkinson (Harry-Hopkinson)
* Jan Kelemen (jan-kelemen)
## Toolchain
* (Balletie) - macOS

View File

@@ -635,7 +635,7 @@ public:
int32_t yAxisScale = 0;
for (int32_t i = 0; i < 64; i++)
{
auto balance = gCashHistory[i];
auto balance = gameState.CashHistory[i];
if (balance == kMoney64Undefined)
continue;
@@ -667,7 +667,7 @@ public:
// X axis labels and values
coords = graphTopLeft + ScreenCoordsXY{ 98, 17 };
Graph::Draw(dpi, gCashHistory, 64, coords, yAxisScale, 128);
Graph::Draw(dpi, gameState.CashHistory, 64, coords, yAxisScale, 128);
}
#pragma endregion

View File

@@ -51,6 +51,7 @@ namespace OpenRCT2
ClimateState ClimateNext;
uint16_t ClimateUpdateTimer;
money64 Cash;
money64 CashHistory[FINANCE_GRAPH_SIZE];
money64 InitialCash;
money64 GuestInitialCash;
uint8_t GuestInitialHappiness;

View File

@@ -40,7 +40,6 @@ static constexpr int32_t dword_988E60[static_cast<int32_t>(ExpenditureType::Coun
};
money64 gHistoricalProfit;
money64 gCashHistory[FINANCE_GRAPH_SIZE];
money64 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][static_cast<int32_t>(ExpenditureType::Count)];
/**
@@ -190,7 +189,7 @@ void FinanceResetHistory()
auto& gameState = GetGameState();
for (int32_t i = 0; i < FINANCE_GRAPH_SIZE; i++)
{
gCashHistory[i] = kMoney64Undefined;
gameState.CashHistory[i] = kMoney64Undefined;
gameState.WeeklyProfitHistory[i] = kMoney64Undefined;
gameState.ParkValueHistory[i] = kMoney64Undefined;
}

View File

@@ -44,7 +44,6 @@ extern const money64 research_cost_table[RESEARCH_FUNDING_COUNT];
*/
extern money64 gHistoricalProfit;
extern money64 gCashHistory[FINANCE_GRAPH_SIZE];
extern money64 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][static_cast<int32_t>(ExpenditureType::Count)];
bool FinanceCheckMoneyRequired(uint32_t flags);

View File

@@ -927,7 +927,7 @@ namespace OpenRCT2
return true;
});
cs.ReadWriteArray(gCashHistory, [&cs](money64& value) {
cs.ReadWriteArray(gameState.CashHistory, [&cs](money64& value) {
cs.ReadWrite(value);
return true;
});

View File

@@ -1441,7 +1441,7 @@ namespace RCT1
for (size_t i = 0; i < Limits::FinanceGraphSize; i++)
{
gCashHistory[i] = ToMoney64(_s4.CashHistory[i]);
gameState.CashHistory[i] = ToMoney64(_s4.CashHistory[i]);
gameState.ParkValueHistory[i] = CorrectRCT1ParkValue(_s4.ParkValueHistory[i]);
gameState.WeeklyProfitHistory[i] = ToMoney64(_s4.WeeklyProfitHistory[i]);
}

View File

@@ -366,7 +366,7 @@ namespace RCT2
for (size_t i = 0; i < Limits::FinanceGraphSize; i++)
{
gCashHistory[i] = ToMoney64(_s6.BalanceHistory[i]);
gameState.CashHistory[i] = ToMoney64(_s6.BalanceHistory[i]);
gameState.WeeklyProfitHistory[i] = ToMoney64(_s6.WeeklyProfitHistory[i]);
gameState.ParkValueHistory[i] = ToMoney64(_s6.ParkValueHistory[i]);
}

View File

@@ -752,7 +752,9 @@ void Park::UpdateHistories()
// Update park rating, guests in park and current cash history
HistoryPushRecord<uint8_t, 32>(gameState.ParkRatingHistory, gameState.ParkRating / 4);
HistoryPushRecord<uint32_t, 32>(gGuestsInParkHistory, gameState.NumGuestsInPark);
HistoryPushRecord<money64, std::size(gCashHistory)>(gCashHistory, FinanceGetCurrentCash() - gameState.BankLoan);
constexpr auto cashHistorySize = std::extent_v<decltype(GameState_t::CashHistory)>;
HistoryPushRecord<money64, cashHistorySize>(gameState.CashHistory, FinanceGetCurrentCash() - gameState.BankLoan);
// Update weekly profit history
auto currentWeeklyProfit = gameState.WeeklyProfitAverageDividend;