mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-22 15:23:01 +01:00
Move gHistoricalProfit and gGuestsInParkHistory to GameState_t (#21513)
* Move gGuestsInParkHistory to GameState_t * Move gHistoricalProfit to GameState_t
This commit is contained in:
@@ -770,9 +770,11 @@ private:
|
||||
auto screenPos = windowPos;
|
||||
Widget* widget = &widgets[WIDX_PAGE_BACKGROUND];
|
||||
|
||||
const auto& gameState = OpenRCT2::GetGameState();
|
||||
|
||||
// Current value
|
||||
auto ft = Formatter();
|
||||
ft.Add<uint32_t>(OpenRCT2::GetGameState().NumGuestsInPark);
|
||||
ft.Add<uint32_t>(gameState.NumGuestsInPark);
|
||||
DrawTextBasic(dpi, screenPos + ScreenCoordsXY{ widget->left + 3, widget->top + 2 }, STR_GUESTS_IN_PARK_LABEL, ft);
|
||||
|
||||
// Graph border
|
||||
@@ -803,7 +805,7 @@ private:
|
||||
uint8_t cappedHistory[32];
|
||||
for (size_t i = 0; i < std::size(cappedHistory); i++)
|
||||
{
|
||||
auto value = gGuestsInParkHistory[i];
|
||||
auto value = gameState.GuestsInParkHistory[i];
|
||||
if (value != std::numeric_limits<uint32_t>::max())
|
||||
{
|
||||
cappedHistory[i] = static_cast<uint8_t>(std::min<uint32_t>(value, 5000) / 20);
|
||||
|
||||
@@ -42,10 +42,13 @@ namespace OpenRCT2
|
||||
money64 ParkValue;
|
||||
money64 ParkValueHistory[FINANCE_GRAPH_SIZE];
|
||||
money64 CompanyValue;
|
||||
// The total profit for the entire scenario that precedes the current financial table.
|
||||
money64 HistoricalProfit;
|
||||
money64 ConstructionRightsPrice;
|
||||
money64 CurrentExpenditure;
|
||||
money64 CurrentProfit;
|
||||
uint8_t ParkRatingHistory[32];
|
||||
uint32_t GuestsInParkHistory[32];
|
||||
ClimateType Climate;
|
||||
ClimateState ClimateCurrent;
|
||||
ClimateState ClimateNext;
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "../windows/Intent.h"
|
||||
#include "../world/Park.h"
|
||||
|
||||
#include <numeric>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
// Monthly research funding costs
|
||||
@@ -39,7 +41,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 gHistoricalProfit;
|
||||
money64 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][static_cast<int32_t>(ExpenditureType::Count)];
|
||||
|
||||
/**
|
||||
@@ -229,11 +230,10 @@ void FinanceInit()
|
||||
gameState.BankLoan = 10000.00_GBP;
|
||||
gameState.MaxBankLoan = 20000.00_GBP;
|
||||
|
||||
gHistoricalProfit = 0;
|
||||
|
||||
gameState.BankLoanInterestRate = 10;
|
||||
gameState.ParkValue = 0;
|
||||
gameState.CompanyValue = 0;
|
||||
gameState.HistoricalProfit = 0;
|
||||
gameState.ScenarioCompletedCompanyValue = kMoney64Undefined;
|
||||
gameState.TotalAdmissions = 0;
|
||||
gameState.TotalIncomeFromAdmissions = 0;
|
||||
@@ -322,12 +322,11 @@ void FinanceShiftExpenditureTable()
|
||||
// If EXPENDITURE_TABLE_MONTH_COUNT months have passed then is full, sum the oldest month
|
||||
if (GetDate().GetMonthsElapsed() >= EXPENDITURE_TABLE_MONTH_COUNT)
|
||||
{
|
||||
money64 sum = 0;
|
||||
for (uint32_t i = 0; i < static_cast<int32_t>(ExpenditureType::Count); i++)
|
||||
{
|
||||
sum += gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT - 1][i];
|
||||
}
|
||||
gHistoricalProfit += sum;
|
||||
const money64 sum = std::accumulate(
|
||||
std::cbegin(gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT - 1]),
|
||||
std::cend(gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT - 1]), money64{});
|
||||
|
||||
GetGameState().HistoricalProfit += sum;
|
||||
}
|
||||
|
||||
// Shift the table
|
||||
|
||||
@@ -38,12 +38,6 @@ constexpr uint8_t MaxBankLoanInterestRate = 255;
|
||||
|
||||
extern const money64 research_cost_table[RESEARCH_FUNDING_COUNT];
|
||||
|
||||
/**
|
||||
* The total profit for the entire scenario that precedes
|
||||
* the current financial table.
|
||||
*/
|
||||
extern money64 gHistoricalProfit;
|
||||
|
||||
extern money64 gExpenditureTable[EXPENDITURE_TABLE_MONTH_COUNT][static_cast<int32_t>(ExpenditureType::Count)];
|
||||
|
||||
bool FinanceCheckMoneyRequired(uint32_t flags);
|
||||
|
||||
@@ -851,7 +851,7 @@ namespace OpenRCT2
|
||||
}
|
||||
}
|
||||
}
|
||||
cs.ReadWrite(gHistoricalProfit);
|
||||
cs.ReadWrite(gameState.HistoricalProfit);
|
||||
|
||||
// Marketing
|
||||
cs.ReadWriteVector(gMarketingCampaigns, [&cs](MarketingCampaign& campaign) {
|
||||
@@ -922,7 +922,7 @@ namespace OpenRCT2
|
||||
return true;
|
||||
});
|
||||
|
||||
cs.ReadWriteArray(gGuestsInParkHistory, [&cs](uint32_t& value) {
|
||||
cs.ReadWriteArray(gameState.GuestsInParkHistory, [&cs](uint32_t& value) {
|
||||
cs.ReadWrite(value);
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -2156,7 +2156,7 @@ namespace RCT1
|
||||
{
|
||||
if (_s4.GuestsInParkHistory[i] != RCT12ParkHistoryUndefined)
|
||||
{
|
||||
gGuestsInParkHistory[i] = _s4.GuestsInParkHistory[i] * RCT12GuestsInParkHistoryFactor;
|
||||
gameState.GuestsInParkHistory[i] = _s4.GuestsInParkHistory[i] * RCT12GuestsInParkHistoryFactor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2171,12 +2171,14 @@ namespace RCT1
|
||||
}
|
||||
|
||||
// Number of guests history
|
||||
std::fill(std::begin(gGuestsInParkHistory), std::end(gGuestsInParkHistory), std::numeric_limits<uint32_t>::max());
|
||||
std::fill(
|
||||
std::begin(gameState.GuestsInParkHistory), std::end(gameState.GuestsInParkHistory),
|
||||
std::numeric_limits<uint32_t>::max());
|
||||
for (size_t i = 0; i < std::size(_s4.GuestsInParkHistory); i++)
|
||||
{
|
||||
if (_s4.GuestsInParkHistory[i] != std::numeric_limits<uint8_t>::max())
|
||||
{
|
||||
gGuestsInParkHistory[i] = _s4.GuestsInParkHistory[i] * 20;
|
||||
gameState.GuestsInParkHistory[i] = _s4.GuestsInParkHistory[i] * 20;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ namespace RCT2
|
||||
{
|
||||
if (_s6.GuestsInParkHistory[i] != RCT12ParkHistoryUndefined)
|
||||
{
|
||||
gGuestsInParkHistory[i] = _s6.GuestsInParkHistory[i] * RCT12GuestsInParkHistoryFactor;
|
||||
gameState.GuestsInParkHistory[i] = _s6.GuestsInParkHistory[i] * RCT12GuestsInParkHistoryFactor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ namespace RCT2
|
||||
gameState.ScenarioCompanyValueRecord = _s6.CompletedCompanyValueRecord;
|
||||
// _s6.LoanHash;
|
||||
// Pad013587CA
|
||||
gHistoricalProfit = ToMoney64(_s6.HistoricalProfit);
|
||||
gameState.HistoricalProfit = ToMoney64(_s6.HistoricalProfit);
|
||||
// Pad013587D4
|
||||
gameState.ScenarioCompletedBy = std::string_view(_s6.ScenarioCompletedName, sizeof(_s6.ScenarioCompletedName));
|
||||
gameState.Cash = ToMoney64(DECRYPT_MONEY(_s6.Cash));
|
||||
|
||||
@@ -104,7 +104,7 @@ void ScenarioReset(GameState_t& gameState)
|
||||
gameState.ParkRating = park.CalculateParkRating();
|
||||
gameState.ParkValue = park.CalculateParkValue();
|
||||
gameState.CompanyValue = park.CalculateCompanyValue();
|
||||
gHistoricalProfit = gameState.InitialCash - gameState.BankLoan;
|
||||
gameState.HistoricalProfit = gameState.InitialCash - gameState.BankLoan;
|
||||
gameState.Cash = gameState.InitialCash;
|
||||
|
||||
{
|
||||
|
||||
@@ -50,7 +50,6 @@ using namespace OpenRCT2;
|
||||
money64 gLandPrice;
|
||||
|
||||
int16_t gParkRatingCasualtyPenalty;
|
||||
uint32_t gGuestsInParkHistory[32];
|
||||
|
||||
// If this value is more than or equal to 0, the park rating is forced to this value. Used for cheat
|
||||
static int32_t _forcedParkRating = -1;
|
||||
@@ -729,7 +728,7 @@ void Park::ResetHistories()
|
||||
{
|
||||
auto& gameState = GetGameState();
|
||||
std::fill(std::begin(gameState.ParkRatingHistory), std::end(gameState.ParkRatingHistory), ParkRatingHistoryUndefined);
|
||||
std::fill(std::begin(gGuestsInParkHistory), std::end(gGuestsInParkHistory), GuestsInParkHistoryUndefined);
|
||||
std::fill(std::begin(gameState.GuestsInParkHistory), std::end(gameState.GuestsInParkHistory), GuestsInParkHistoryUndefined);
|
||||
}
|
||||
|
||||
void Park::UpdateHistories()
|
||||
@@ -751,7 +750,7 @@ 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<uint32_t, 32>(gameState.GuestsInParkHistory, gameState.NumGuestsInPark);
|
||||
|
||||
constexpr auto cashHistorySize = std::extent_v<decltype(GameState_t::CashHistory)>;
|
||||
HistoryPushRecord<money64, cashHistorySize>(gameState.CashHistory, FinanceGetCurrentCash() - gameState.BankLoan);
|
||||
|
||||
@@ -95,7 +95,6 @@ namespace OpenRCT2
|
||||
extern money64 gLandPrice;
|
||||
|
||||
extern int16_t gParkRatingCasualtyPenalty;
|
||||
extern uint32_t gGuestsInParkHistory[32];
|
||||
|
||||
void ParkSetForcedRating(int32_t rating);
|
||||
int32_t ParkGetForcedRating();
|
||||
|
||||
Reference in New Issue
Block a user