diff --git a/src/openrct2/GameState.h b/src/openrct2/GameState.h index 696139f2a5..619cc76e50 100644 --- a/src/openrct2/GameState.h +++ b/src/openrct2/GameState.h @@ -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; diff --git a/src/openrct2/management/Award.cpp b/src/openrct2/management/Award.cpp index cc228fa5bf..47053fd241 100644 --- a/src/openrct2/management/Award.cpp +++ b/src/openrct2/management/Award.cpp @@ -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; } diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index fadad2a4b8..51ca24d7d5 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -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); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 95888fa274..9b88590f7d 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -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) { diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 853e015ee9..bde2cb5fc2 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -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; diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 4576c7e8ae..17fc656124 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -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; diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index 6184a20dae..80e463b23c 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -50,8 +50,6 @@ using namespace OpenRCT2::TrackMetaData; -money64 gTotalRideValueForMoney; - money64 _currentTrackPrice; uint32_t _currentTrackCurve; diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index d5f0fa37f3..b7d8e7ee02 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -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()) diff --git a/src/openrct2/scripting/bindings/world/ScPark.cpp b/src/openrct2/scripting/bindings/world/ScPark.cpp index 223056de93..9e46c30389 100644 --- a/src/openrct2/scripting/bindings/world/ScPark.cpp +++ b/src/openrct2/scripting/bindings/world/ScPark.cpp @@ -202,7 +202,7 @@ namespace OpenRCT2::Scripting money64 ScPark::totalRideValueForMoney_get() const { - return gTotalRideValueForMoney; + return GetGameState().TotalRideValueForMoney; } uint32_t ScPark::totalAdmissions_get() const diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index e22986298b..a112a630fe 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -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; }