Move .weeklyProfit* into ParkData struct

This commit is contained in:
Aaron van Geffen committed 2025-08-13 22:03:14 +02:00
1 parent 68a4991971
commit 5d9de6292f
9 files changed
+27 -26

No files matched your search

+1 -1
View File
@@ -331,7 +331,7 @@ namespace OpenRCT2::Ui::Windows
case WINDOW_FINANCES_PAGE_PROFIT_GRAPH:
graphPageWidget = &widgets[WIDX_PAGE_BACKGROUND];
centredGraph = true;
_graphProps.series = getGameState().weeklyProfitHistory;
_graphProps.series = getGameState().park.weeklyProfitHistory;
break;
case WINDOW_FINANCES_PAGE_FINANCIAL_GRAPH:
graphPageWidget = &widgets[WIDX_PAGE_BACKGROUND];
-3
View File
@@ -55,12 +55,9 @@ namespace OpenRCT2
uint32_t numGuestsHeadingForPark;
uint32_t numGuestsInParkLastWeek;
money64 weeklyProfitAverageDividend;
uint64_t totalAdmissions;
money64 totalIncomeFromAdmissions;
money64 totalRideValueForMoney;
uint16_t weeklyProfitAverageDivisor;
money64 weeklyProfitHistory[kFinanceHistorySize];
Objective scenarioObjective;
uint16_t scenarioParkRatingWarningDays;
+5 -5
View File
@@ -189,7 +189,7 @@ void FinanceResetHistory()
for (auto i = 0; i < kFinanceHistorySize; i++)
{
gameState.park.cashHistory[i] = kMoney64Undefined;
gameState.weeklyProfitHistory[i] = kMoney64Undefined;
gameState.park.weeklyProfitHistory[i] = kMoney64Undefined;
gameState.park.ValueHistory[i] = kMoney64Undefined;
}
@@ -219,8 +219,8 @@ void FinanceInit()
gameState.park.currentExpenditure = 0;
gameState.park.currentProfit = 0;
gameState.weeklyProfitAverageDividend = 0;
gameState.weeklyProfitAverageDivisor = 0;
gameState.park.weeklyProfitAverageDividend = 0;
gameState.park.weeklyProfitAverageDivisor = 0;
gameState.initialCash = 10000.00_GBP; // Cheat detection
@@ -284,8 +284,8 @@ void FinanceUpdateDailyProfit()
gameState.park.currentProfit += current_profit;
// These are related to weekly profit graph
gameState.weeklyProfitAverageDividend += gameState.park.currentProfit;
gameState.weeklyProfitAverageDivisor += 1;
gameState.park.weeklyProfitAverageDividend += gameState.park.currentProfit;
gameState.park.weeklyProfitAverageDivisor += 1;
auto* windowMgr = Ui::GetWindowManager();
windowMgr->InvalidateByClass(WindowClass::Finances);
+3 -3
View File
@@ -985,8 +985,8 @@ namespace OpenRCT2
cs.ReadWrite(gameState.park.RatingCasualtyPenalty);
cs.ReadWrite(gameState.park.currentExpenditure);
cs.ReadWrite(gameState.park.currentProfit);
cs.ReadWrite(gameState.weeklyProfitAverageDividend);
cs.ReadWrite(gameState.weeklyProfitAverageDivisor);
cs.ReadWrite(gameState.park.weeklyProfitAverageDividend);
cs.ReadWrite(gameState.park.weeklyProfitAverageDivisor);
cs.ReadWrite(gameState.totalAdmissions);
cs.ReadWrite(gameState.totalIncomeFromAdmissions);
if (version <= 16)
@@ -1065,7 +1065,7 @@ namespace OpenRCT2
cs.ReadWrite(value);
return true;
});
cs.ReadWriteArray(gameState.weeklyProfitHistory, [&cs](money64& value) {
cs.ReadWriteArray(gameState.park.weeklyProfitHistory, [&cs](money64& value) {
cs.ReadWrite(value);
return true;
});
+1 -1
View File
@@ -1519,7 +1519,7 @@ namespace OpenRCT2::RCT1
{
gameState.park.cashHistory[i] = ToMoney64(_s4.CashHistory[i]);
gameState.park.ValueHistory[i] = CorrectRCT1ParkValue(_s4.ParkValueHistory[i]);
gameState.weeklyProfitHistory[i] = ToMoney64(_s4.WeeklyProfitHistory[i]);
gameState.park.weeklyProfitHistory[i] = ToMoney64(_s4.WeeklyProfitHistory[i]);
}
for (size_t i = 0; i < Limits::kExpenditureTableMonthCount; i++)
+3 -3
View File
@@ -482,8 +482,8 @@ namespace OpenRCT2::RCT2
gameState.park.currentExpenditure = ToMoney64(_s6.CurrentExpenditure);
gameState.park.currentProfit = ToMoney64(_s6.CurrentProfit);
gameState.weeklyProfitAverageDividend = ToMoney64(_s6.WeeklyProfitAverageDividend);
gameState.weeklyProfitAverageDivisor = _s6.WeeklyProfitAverageDivisor;
gameState.park.weeklyProfitAverageDividend = ToMoney64(_s6.WeeklyProfitAverageDividend);
gameState.park.weeklyProfitAverageDivisor = _s6.WeeklyProfitAverageDivisor;
// Pad0135833A
gameState.park.Value = ToMoney64(_s6.ParkValue);
@@ -491,7 +491,7 @@ namespace OpenRCT2::RCT2
for (size_t i = 0; i < Limits::kFinanceGraphSize; i++)
{
gameState.park.cashHistory[i] = ToMoney64(_s6.BalanceHistory[i]);
gameState.weeklyProfitHistory[i] = ToMoney64(_s6.WeeklyProfitHistory[i]);
gameState.park.weeklyProfitHistory[i] = ToMoney64(_s6.WeeklyProfitHistory[i]);
gameState.park.ValueHistory[i] = ToMoney64(_s6.ParkValueHistory[i]);
}
+2 -2
View File
@@ -126,8 +126,8 @@ void ScenarioReset(GameState_t& gameState)
gameState.park.currentExpenditure = 0;
gameState.park.currentProfit = 0;
gameState.weeklyProfitAverageDividend = 0;
gameState.weeklyProfitAverageDivisor = 0;
gameState.park.weeklyProfitAverageDividend = 0;
gameState.park.weeklyProfitAverageDivisor = 0;
gameState.totalAdmissions = 0;
gameState.totalIncomeFromAdmissions = 0;
+8 -8
View File
@@ -617,18 +617,18 @@ namespace OpenRCT2::Park
gameState.park.cashHistory, FinanceGetCurrentCash() - gameState.park.bankLoan);
// Update weekly profit history
auto currentWeeklyProfit = gameState.weeklyProfitAverageDividend;
if (gameState.weeklyProfitAverageDivisor != 0)
auto currentWeeklyProfit = gameState.park.weeklyProfitAverageDividend;
if (gameState.park.weeklyProfitAverageDivisor != 0)
{
currentWeeklyProfit /= gameState.weeklyProfitAverageDivisor;
currentWeeklyProfit /= gameState.park.weeklyProfitAverageDivisor;
}
constexpr auto profitHistorySize = std::extent_v<decltype(GameState_t::weeklyProfitHistory)>;
HistoryPushRecord<money64, profitHistorySize>(gameState.weeklyProfitHistory, currentWeeklyProfit);
gameState.weeklyProfitAverageDividend = 0;
gameState.weeklyProfitAverageDivisor = 0;
constexpr auto profitHistorySize = std::extent_v<decltype(ParkData::weeklyProfitHistory)>;
HistoryPushRecord<money64, profitHistorySize>(gameState.park.weeklyProfitHistory, currentWeeklyProfit);
gameState.park.weeklyProfitAverageDividend = 0;
gameState.park.weeklyProfitAverageDivisor = 0;
// Update park value history
constexpr auto parkValueHistorySize = std::extent_v<decltype(GameState_t::weeklyProfitHistory)>;
constexpr auto parkValueHistorySize = std::extent_v<decltype(ParkData::weeklyProfitHistory)>;
HistoryPushRecord<money64, parkValueHistorySize>(gameState.park.ValueHistory, gameState.park.Value);
// Invalidate relevant windows
+4
View File
@@ -70,6 +70,10 @@ namespace OpenRCT2::Park
money64 cash;
money64 cashHistory[kFinanceHistorySize];
uint16_t weeklyProfitAverageDivisor;
money64 weeklyProfitAverageDividend;
money64 weeklyProfitHistory[kFinanceHistorySize];
// The total profit for the entire scenario that precedes the current financial table.
money64 historicalProfit;
money64 currentProfit;