Move _suggestedGuestMaximum to GameState_t

This commit is contained in:
Gymnasiast 2024-02-07 22:53:31 +01:00
parent 142d708cee
commit 61e8b6d206
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
7 changed files with 12 additions and 14 deletions

View File

@ -94,6 +94,10 @@ namespace OpenRCT2
* awards, approximately 1 guest per second can be generated (+60 guests in one minute).
*/
int32_t GuestGenerationProbability;
/**
* In a difficult guest generation scenario, no guests will be generated if over this value.
*/
uint32_t SuggestedGuestMaximum;
};
GameState_t& GetGameState();

View File

@ -668,7 +668,7 @@ namespace OpenRCT2
auto& gameState = GetGameState();
serialiser << gameState.GuestGenerationProbability;
serialiser << _suggestedGuestMaximum;
serialiser << gameState.SuggestedGuestMaximum;
serialiser << gConfigGeneral.ShowRealNamesOfGuests;
// To make this a little bit less volatile against updates

View File

@ -910,7 +910,7 @@ namespace OpenRCT2
cs.ReadWrite(gameState.NumGuestsInParkLastWeek);
cs.ReadWrite(gGuestChangeModifier);
cs.ReadWrite(gameState.GuestGenerationProbability);
cs.ReadWrite(_suggestedGuestMaximum);
cs.ReadWrite(gameState.SuggestedGuestMaximum);
cs.ReadWriteArray(gPeepWarningThrottle, [&cs](uint8_t& value) {
cs.ReadWrite(value);

View File

@ -404,7 +404,7 @@ namespace RCT2
gParkRatingCasualtyPenalty = _s6.ParkRatingCasualtyPenalty;
gMapSize = { _s6.MapSize, _s6.MapSize };
gSamePriceThroughoutPark = _s6.SamePriceThroughout | (static_cast<uint64_t>(_s6.SamePriceThroughoutExtended) << 32);
_suggestedGuestMaximum = _s6.SuggestedMaxGuests;
gameState.SuggestedGuestMaximum = _s6.SuggestedMaxGuests;
gameState.ScenarioParkRatingWarningDays = _s6.ParkRatingWarningDays;
gLastEntranceStyle = _s6.LastEntranceStyle;
// rct1_water_colour

View File

@ -139,7 +139,7 @@ namespace OpenRCT2::Scripting
uint32_t ScPark::suggestedGuestMaximum_get() const
{
return _suggestedGuestMaximum;
return GetGameState().SuggestedGuestMaximum;
}
int32_t ScPark::guestGenerationProbability_get() const

View File

@ -58,11 +58,6 @@ 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;
/**
* In a difficult guest generation scenario, no guests will be generated if over this value.
*/
uint32_t _suggestedGuestMaximum;
/**
* Choose a random peep spawn and iterates through until defined spawn is found.
*/
@ -253,7 +248,7 @@ void Park::Initialise()
gameState.ParkRating = 0;
gameState.GuestGenerationProbability = 0;
gameState.TotalRideValueForMoney = 0;
_suggestedGuestMaximum = 0;
gameState.SuggestedGuestMaximum = 0;
gameState.ResearchLastItem = std::nullopt;
gMarketingCampaigns.clear();
@ -312,7 +307,7 @@ void Park::Update(const Date& date)
gameState.ParkValue = CalculateParkValue();
gCompanyValue = CalculateCompanyValue();
gameState.TotalRideValueForMoney = CalculateTotalRideValueForMoney();
_suggestedGuestMaximum = CalculateSuggestedMaxGuests();
gameState.SuggestedGuestMaximum = CalculateSuggestedMaxGuests();
gameState.GuestGenerationProbability = CalculateGuestGenerationProbability();
WindowInvalidateByClass(WindowClass::Finances);
@ -596,7 +591,7 @@ uint32_t Park::CalculateGuestGenerationProbability() const
// The more guests, the lower the chance of a new one
uint32_t numGuests = gameState.NumGuestsInPark + gameState.NumGuestsHeadingForPark;
if (numGuests > _suggestedGuestMaximum)
if (numGuests > gameState.SuggestedGuestMaximum)
{
probability /= 4;
// Even lower for difficult guest generation
@ -671,7 +666,7 @@ void Park::GenerateGuests()
if (static_cast<int32_t>(ScenarioRand() & 0xFFFF) < gameState.GuestGenerationProbability)
{
bool difficultGeneration = (gameState.ParkFlags & PARK_FLAGS_DIFFICULT_GUEST_GENERATION) != 0;
if (!difficultGeneration || _suggestedGuestMaximum + 150 >= gameState.NumGuestsInPark)
if (!difficultGeneration || gameState.SuggestedGuestMaximum + 150 >= gameState.NumGuestsInPark)
{
GenerateGuest();
}

View File

@ -99,7 +99,6 @@ extern money64 gCompanyValue;
extern int16_t gParkRatingCasualtyPenalty;
extern uint32_t gGuestsInParkHistory[32];
extern uint32_t _suggestedGuestMaximum;
void ParkSetForcedRating(int32_t rating);
int32_t ParkGetForcedRating();