1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Move gTotalRideValueForMoney to GameState_t

This commit is contained in:
Harry Hopkinson
2024-02-08 09:39:28 +00:00
parent 6a9f9025ff
commit 6deac11916
10 changed files with 21 additions and 20 deletions

View File

@@ -54,6 +54,7 @@ namespace OpenRCT2
money64 WeeklyProfitAverageDividend;
uint64_t TotalAdmissions;
money64 TotalIncomeFromAdmissions;
money64 TotalRideValueForMoney;
uint16_t WeeklyProfitAverageDivisor;
money64 WeeklyProfitHistory[FINANCE_GRAPH_SIZE];
Objective ScenarioObjective;

View File

@@ -175,19 +175,21 @@ static bool AwardIsDeservedBestRollercoasters([[maybe_unused]] int32_t activeAwa
/** Entrance fee is 0.10 less than half of the total ride value. */
static bool AwardIsDeservedBestValue(int32_t activeAwardTypes)
{
auto& gameState = GetGameState();
if (activeAwardTypes & EnumToFlag(AwardType::WorstValue))
return false;
if (activeAwardTypes & EnumToFlag(AwardType::MostDisappointing))
return false;
if ((GetGameState().ParkFlags & PARK_FLAGS_NO_MONEY) || !ParkEntranceFeeUnlocked())
if ((gameState.ParkFlags & PARK_FLAGS_NO_MONEY) || !ParkEntranceFeeUnlocked())
return false;
if (gTotalRideValueForMoney < 10.00_GBP)
if (gameState.TotalRideValueForMoney < 10.00_GBP)
return false;
if (ParkGetEntranceFee() + 0.10_GBP >= gTotalRideValueForMoney / 2)
if (ParkGetEntranceFee() + 0.10_GBP >= gameState.TotalRideValueForMoney / 2)
return false;
return true;
@@ -229,15 +231,17 @@ static bool AwardIsDeservedMostBeautiful(int32_t activeAwardTypes)
/** Entrance fee is more than total ride value. */
static bool AwardIsDeservedWorstValue(int32_t activeAwardTypes)
{
auto& gameState = GetGameState();
if (activeAwardTypes & EnumToFlag(AwardType::BestValue))
return false;
if (GetGameState().ParkFlags & PARK_FLAGS_NO_MONEY)
if (gameState.ParkFlags & PARK_FLAGS_NO_MONEY)
return false;
const auto parkEntranceFee = ParkGetEntranceFee();
if (parkEntranceFee == 0.00_GBP)
return false;
if (parkEntranceFee <= gTotalRideValueForMoney)
if (parkEntranceFee <= gameState.TotalRideValueForMoney)
return false;
return true;
}

View File

@@ -901,11 +901,11 @@ namespace OpenRCT2
{
money16 legacyTotalRideValueForMoney = 0;
cs.ReadWrite(legacyTotalRideValueForMoney);
gTotalRideValueForMoney = legacyTotalRideValueForMoney;
gameState.TotalRideValueForMoney = legacyTotalRideValueForMoney;
}
else
{
cs.ReadWrite(gTotalRideValueForMoney);
cs.ReadWrite(gameState.TotalRideValueForMoney);
}
cs.ReadWrite(gameState.NumGuestsInParkLastWeek);
cs.ReadWrite(gGuestChangeModifier);

View File

@@ -2213,7 +2213,7 @@ namespace RCT1
}
gameState.ParkSize = _s4.ParkSize;
gTotalRideValueForMoney = _s4.TotalRideValueForMoney;
gameState.TotalRideValueForMoney = _s4.TotalRideValueForMoney;
gSamePriceThroughoutPark = 0;
if (_gameVersion == FILE_VERSION_RCT1_LL)
{

View File

@@ -339,7 +339,7 @@ namespace RCT2
gameState.GuestInitialHappiness = _s6.GuestInitialHappiness;
gameState.ParkSize = _s6.ParkSize;
_guestGenerationProbability = _s6.GuestGenerationProbability;
gTotalRideValueForMoney = _s6.TotalRideValueForMoney;
gameState.TotalRideValueForMoney = _s6.TotalRideValueForMoney;
gMaxBankLoan = ToMoney64(_s6.MaximumLoan);
gameState.GuestInitialCash = ToMoney64(_s6.GuestInitialCash);
gameState.GuestInitialHunger = _s6.GuestInitialHunger;

View File

@@ -1012,8 +1012,6 @@ void RideDelete(RideId id);
const RideObjectEntry* GetRideEntryByIndex(ObjectEntryIndex index);
std::string_view GetRideEntryName(ObjectEntryIndex index);
extern money64 gTotalRideValueForMoney;
extern const StringId ColourSchemeNames[4];
extern ObjectEntryIndex gLastEntranceStyle;

View File

@@ -50,8 +50,6 @@
using namespace OpenRCT2::TrackMetaData;
money64 gTotalRideValueForMoney;
money64 _currentTrackPrice;
uint32_t _currentTrackCurve;

View File

@@ -235,9 +235,9 @@ void ScenarioSuccessSubmitName(GameState_t& gameState, const char* name)
*/
static void ScenarioCheckEntranceFeeTooHigh()
{
const auto max_fee = AddClamp_money64(gTotalRideValueForMoney, gTotalRideValueForMoney / 2);
const auto& gameState = GetGameState();
const auto max_fee = AddClamp_money64(gameState.TotalRideValueForMoney, gameState.TotalRideValueForMoney / 2);
if ((gameState.ParkFlags & PARK_FLAGS_PARK_OPEN) && ParkGetEntranceFee() > max_fee)
{
if (!gameState.ParkEntrances.empty())

View File

@@ -202,7 +202,7 @@ namespace OpenRCT2::Scripting
money64 ScPark::totalRideValueForMoney_get() const
{
return gTotalRideValueForMoney;
return GetGameState().TotalRideValueForMoney;
}
uint32_t ScPark::totalAdmissions_get() const

View File

@@ -260,7 +260,7 @@ void Park::Initialise()
gGuestChangeModifier = 0;
gameState.ParkRating = 0;
_guestGenerationProbability = 0;
gTotalRideValueForMoney = 0;
gameState.TotalRideValueForMoney = 0;
_suggestedGuestMaximum = 0;
gameState.ResearchLastItem = std::nullopt;
gMarketingCampaigns.clear();
@@ -319,7 +319,7 @@ void Park::Update(const Date& date)
gameState.ParkRating = CalculateParkRating();
gameState.ParkValue = CalculateParkValue();
gCompanyValue = CalculateCompanyValue();
gTotalRideValueForMoney = CalculateTotalRideValueForMoney();
gameState.TotalRideValueForMoney = CalculateTotalRideValueForMoney();
_suggestedGuestMaximum = CalculateSuggestedMaxGuests();
_guestGenerationProbability = CalculateGuestGenerationProbability();
@@ -622,11 +622,11 @@ uint32_t Park::CalculateGuestGenerationProbability() const
// Penalty for overpriced entrance fee relative to total ride value
auto entranceFee = ParkGetEntranceFee();
if (entranceFee > gTotalRideValueForMoney)
if (entranceFee > gameState.TotalRideValueForMoney)
{
probability /= 4;
// Extra penalty for very overpriced entrance fee
if (entranceFee / 2 > gTotalRideValueForMoney)
if (entranceFee / 2 > gameState.TotalRideValueForMoney)
{
probability /= 4;
}