diff --git a/src/openrct2/GameState.h b/src/openrct2/GameState.h index 64c31a0949..021377f16e 100644 --- a/src/openrct2/GameState.h +++ b/src/openrct2/GameState.h @@ -42,6 +42,7 @@ namespace OpenRCT2 money64 ParkValueHistory[FINANCE_GRAPH_SIZE]; money64 CompanyValue; money64 ConstructionRightsPrice; + money64 CurrentExpenditure; uint8_t ParkRatingHistory[32]; ClimateType Climate; ClimateState ClimateCurrent; diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index 20013f0e78..0297384ee7 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -39,7 +39,6 @@ static constexpr int32_t dword_988E60[static_cast(ExpenditureType::Coun 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, }; -money64 gCurrentExpenditure; money64 gCurrentProfit; money64 gHistoricalProfit; money64 gCashHistory[FINANCE_GRAPH_SIZE]; @@ -88,7 +87,7 @@ void FinancePayment(money64 amount, ExpenditureType type) if (dword_988E60[static_cast(type)] & 1) { // Cumulative amount of money spent this day - gCurrentExpenditure -= amount; + gameState.CurrentExpenditure -= amount; } auto intent = Intent(INTENT_ACTION_UPDATE_CASH); @@ -220,7 +219,7 @@ void FinanceInit() gExpenditureTable[0][i] = 0; } - gCurrentExpenditure = 0; + gameState.CurrentExpenditure = 0; gCurrentProfit = 0; gameState.WeeklyProfitAverageDividend = 0; @@ -250,12 +249,12 @@ void FinanceInit() void FinanceUpdateDailyProfit() { PROFILED_FUNCTION(); + auto& gameState = GetGameState(); - gCurrentProfit = 7 * gCurrentExpenditure; - gCurrentExpenditure = 0; // Reset daily expenditure + gCurrentProfit = 7 * gameState.CurrentExpenditure; + gameState.CurrentExpenditure = 0; // Reset daily expenditure money64 current_profit = 0; - auto& gameState = GetGameState(); if (!(gameState.ParkFlags & PARK_FLAGS_NO_MONEY)) { diff --git a/src/openrct2/management/Finance.h b/src/openrct2/management/Finance.h index b49f84cfde..60bf6249c4 100644 --- a/src/openrct2/management/Finance.h +++ b/src/openrct2/management/Finance.h @@ -38,7 +38,6 @@ constexpr uint8_t MaxBankLoanInterestRate = 255; extern const money64 research_cost_table[RESEARCH_FUNDING_COUNT]; -extern money64 gCurrentExpenditure; extern money64 gCurrentProfit; /** diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index c6cf4d78fe..f430cec855 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -891,7 +891,7 @@ namespace OpenRCT2 cs.ReadWrite(gameState.NumGuestsHeadingForPark); cs.ReadWrite(gameState.ParkRating); cs.ReadWrite(gParkRatingCasualtyPenalty); - cs.ReadWrite(gCurrentExpenditure); + cs.ReadWrite(gameState.CurrentExpenditure); cs.ReadWrite(gCurrentProfit); cs.ReadWrite(gameState.WeeklyProfitAverageDividend); cs.ReadWrite(gameState.WeeklyProfitAverageDivisor); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 6257f30f4c..54f480ac76 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1420,7 +1420,7 @@ namespace RCT1 gExpenditureTable[i][j] = ToMoney64(_s4.Expenditure[i][j]); } } - gCurrentExpenditure = ToMoney64(_s4.TotalExpenditure); + gameState.CurrentExpenditure = ToMoney64(_s4.TotalExpenditure); gameState.ScenarioCompletedCompanyValue = RCT12CompletedCompanyValueToOpenRCT2(_s4.CompletedCompanyValue); gameState.TotalAdmissions = _s4.NumAdmissions; diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 7a89c5b07e..4f3d4581fb 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -356,7 +356,7 @@ namespace RCT2 gameState.ScenarioObjective.NumGuests = _s6.ObjectiveGuests; ImportMarketingCampaigns(); - gCurrentExpenditure = ToMoney64(_s6.CurrentExpenditure); + gameState.CurrentExpenditure = ToMoney64(_s6.CurrentExpenditure); gCurrentProfit = ToMoney64(_s6.CurrentProfit); gameState.WeeklyProfitAverageDividend = ToMoney64(_s6.WeeklyProfitAverageDividend); gameState.WeeklyProfitAverageDivisor = _s6.WeeklyProfitAverageDivisor; diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index 6efacfb696..8389365d3d 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -134,7 +134,7 @@ void ScenarioReset(GameState_t& gameState) auto savePath = env->GetDirectoryPath(DIRBASE::USER, DIRID::SAVE); gScenarioSavePath = Path::Combine(savePath, park.Name + u8".park"); - gCurrentExpenditure = 0; + gameState.CurrentExpenditure = 0; gCurrentProfit = 0; gameState.WeeklyProfitAverageDividend = 0; gameState.WeeklyProfitAverageDivisor = 0;