1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 21:13:05 +01:00

Move gCurrentProfit to GameState_t (#21485)

This commit is contained in:
Harry Hopkinson
2024-03-01 08:47:30 +00:00
committed by GitHub
parent 37104ed4f8
commit 42844d1667
9 changed files with 12 additions and 14 deletions

View File

@@ -742,10 +742,10 @@ public:
// Weekly profit
auto ft = Formatter();
ft.Add<money64>(gCurrentProfit);
ft.Add<money64>(gameState.CurrentProfit);
DrawTextBasic(
dpi, graphTopLeft - ScreenCoordsXY{ 0, 11 },
gCurrentProfit >= 0 ? STR_FINANCES_WEEKLY_PROFIT_POSITIVE : STR_FINANCES_WEEKLY_PROFIT_LOSS, ft);
gameState.CurrentProfit >= 0 ? STR_FINANCES_WEEKLY_PROFIT_POSITIVE : STR_FINANCES_WEEKLY_PROFIT_LOSS, ft);
// Graph
GfxFillRectInset(dpi, { graphTopLeft, graphBottomRight }, colours[1], INSET_RECT_F_30);

View File

@@ -475,7 +475,7 @@ public:
switch (widgetIndex)
{
case WIDX_MONEY:
ft.Add<money64>(gCurrentProfit);
ft.Add<money64>(gameState.CurrentProfit);
ft.Add<money64>(gameState.ParkValue);
break;
case WIDX_PARK_RATING:

View File

@@ -43,6 +43,7 @@ namespace OpenRCT2
money64 CompanyValue;
money64 ConstructionRightsPrice;
money64 CurrentExpenditure;
money64 CurrentProfit;
uint8_t ParkRatingHistory[32];
ClimateType Climate;
ClimateState ClimateCurrent;

View File

@@ -39,7 +39,6 @@ static constexpr int32_t dword_988E60[static_cast<int32_t>(ExpenditureType::Coun
1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0,
};
money64 gCurrentProfit;
money64 gHistoricalProfit;
money64 gCashHistory[FINANCE_GRAPH_SIZE];
money64 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][static_cast<int32_t>(ExpenditureType::Count)];
@@ -220,7 +219,7 @@ void FinanceInit()
}
gameState.CurrentExpenditure = 0;
gCurrentProfit = 0;
gameState.CurrentProfit = 0;
gameState.WeeklyProfitAverageDividend = 0;
gameState.WeeklyProfitAverageDivisor = 0;
@@ -251,7 +250,7 @@ void FinanceUpdateDailyProfit()
PROFILED_FUNCTION();
auto& gameState = GetGameState();
gCurrentProfit = 7 * gameState.CurrentExpenditure;
gameState.CurrentProfit = 7 * gameState.CurrentExpenditure;
gameState.CurrentExpenditure = 0; // Reset daily expenditure
money64 current_profit = 0;
@@ -285,10 +284,10 @@ void FinanceUpdateDailyProfit()
// This is not equivalent to / 4 due to rounding of negative numbers
current_profit = current_profit >> 2;
gCurrentProfit += current_profit;
gameState.CurrentProfit += current_profit;
// These are related to weekly profit graph
gameState.WeeklyProfitAverageDividend += gCurrentProfit;
gameState.WeeklyProfitAverageDividend += gameState.CurrentProfit;
gameState.WeeklyProfitAverageDivisor += 1;
WindowInvalidateByClass(WindowClass::Finances);

View File

@@ -38,8 +38,6 @@ constexpr uint8_t MaxBankLoanInterestRate = 255;
extern const money64 research_cost_table[RESEARCH_FUNDING_COUNT];
extern money64 gCurrentProfit;
/**
* The total profit for the entire scenario that precedes
* the current financial table.

View File

@@ -892,7 +892,7 @@ namespace OpenRCT2
cs.ReadWrite(gameState.ParkRating);
cs.ReadWrite(gParkRatingCasualtyPenalty);
cs.ReadWrite(gameState.CurrentExpenditure);
cs.ReadWrite(gCurrentProfit);
cs.ReadWrite(gameState.CurrentProfit);
cs.ReadWrite(gameState.WeeklyProfitAverageDividend);
cs.ReadWrite(gameState.WeeklyProfitAverageDivisor);
cs.ReadWrite(gameState.TotalAdmissions);

View File

@@ -1404,7 +1404,7 @@ namespace RCT1
gameState.CompanyValue = ToMoney64(_s4.CompanyValue);
gameState.ParkValue = CorrectRCT1ParkValue(_s4.ParkValue);
gCurrentProfit = ToMoney64(_s4.Profit);
gameState.CurrentProfit = ToMoney64(_s4.Profit);
for (size_t i = 0; i < Limits::FinanceGraphSize; i++)
{

View File

@@ -357,7 +357,7 @@ namespace RCT2
ImportMarketingCampaigns();
gameState.CurrentExpenditure = ToMoney64(_s6.CurrentExpenditure);
gCurrentProfit = ToMoney64(_s6.CurrentProfit);
gameState.CurrentProfit = ToMoney64(_s6.CurrentProfit);
gameState.WeeklyProfitAverageDividend = ToMoney64(_s6.WeeklyProfitAverageDividend);
gameState.WeeklyProfitAverageDivisor = _s6.WeeklyProfitAverageDivisor;
// Pad0135833A

View File

@@ -135,7 +135,7 @@ void ScenarioReset(GameState_t& gameState)
gScenarioSavePath = Path::Combine(savePath, park.Name + u8".park");
gameState.CurrentExpenditure = 0;
gCurrentProfit = 0;
gameState.CurrentProfit = 0;
gameState.WeeklyProfitAverageDividend = 0;
gameState.WeeklyProfitAverageDivisor = 0;
gameState.TotalAdmissions = 0;