Move .numGuestsInPark, .guestsInParkHistory into ParkData struct

This commit is contained in:
Aaron van Geffen committed 2025-08-13 21:20:13 +02:00
1 parent b8bc487f19
commit e5ead99c83
16 files changed
+60 -57

No files matched your search

@@ -130,11 +130,12 @@ namespace OpenRCT2::Ui::Windows
const auto& widget = widgets[WIDX_GUESTS];
auto screenCoords = ScreenCoordsXY{ windowPos.x + widget.midX(), windowPos.y + widget.midY() - 6 };
StringId stringId = gameState.numGuestsInPark == 1 ? _guestCountFormatsSingular[gameState.guestChangeModifier]
: _guestCountFormats[gameState.guestChangeModifier];
StringId stringId = gameState.park.numGuestsInPark == 1
? _guestCountFormatsSingular[gameState.guestChangeModifier]
: _guestCountFormats[gameState.guestChangeModifier];
auto colour = GetHoverWidgetColour(WIDX_GUESTS);
auto ft = Formatter();
ft.Add<uint32_t>(gameState.numGuestsInPark);
ft.Add<uint32_t>(gameState.park.numGuestsInPark);
DrawTextBasic(rt, screenCoords, stringId, ft, { colour, TextAlignment::CENTRE });
}
+5 -5
View File
@@ -750,7 +750,7 @@ namespace OpenRCT2::Ui::Windows
WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_7);
const auto& gameState = getGameState();
_guestProps.series = gameState.guestsInParkHistory;
_guestProps.series = gameState.park.guestsInParkHistory;
const Widget* background = &widgets[WIDX_PAGE_BACKGROUND];
_guestGraphBounds = { windowPos + ScreenCoordsXY{ background->left + 4, background->top + 15 },
windowPos + ScreenCoordsXY{ background->right - 4, background->bottom - 4 } };
@@ -758,9 +758,9 @@ namespace OpenRCT2::Ui::Windows
// Calculate Y axis max and min
_guestProps.min = 0;
_guestProps.max = 5000;
for (size_t i = 0; i < std::size(gameState.guestsInParkHistory); i++)
for (size_t i = 0; i < std::size(gameState.park.guestsInParkHistory); i++)
{
auto value = gameState.guestsInParkHistory[i];
auto value = gameState.park.guestsInParkHistory[i];
if (value == kGuestsInParkHistoryUndefined)
continue;
while (value > _guestProps.max)
@@ -786,7 +786,7 @@ namespace OpenRCT2::Ui::Windows
// Current value
Formatter ft;
ft.Add<uint32_t>(getGameState().numGuestsInPark);
ft.Add<uint32_t>(getGameState().park.numGuestsInPark);
DrawTextBasic(rt, windowPos + ScreenCoordsXY{ widget->left + 3, widget->top + 2 }, STR_GUESTS_IN_PARK_LABEL, ft);
// Graph border
@@ -978,7 +978,7 @@ namespace OpenRCT2::Ui::Windows
// Draw number of guests in park
ft = Formatter();
ft.Add<uint32_t>(gameState.numGuestsInPark);
ft.Add<uint32_t>(gameState.park.numGuestsInPark);
DrawTextBasic(rt, screenCoords, STR_GUESTS_IN_PARK_LABEL, ft);
screenCoords.y += kListRowHeight;
+1 -1
View File
@@ -302,7 +302,7 @@ namespace OpenRCT2::Editor
ResetAllEntities();
UpdateConsolidatedPatrolAreas();
gameState.numGuestsInPark = 0;
gameState.park.numGuestsInPark = 0;
gameState.numGuestsHeadingForPark = 0;
gameState.numGuestsInParkLastWeek = 0;
gameState.guestChangeModifier = 0;
+3 -3
View File
@@ -218,12 +218,12 @@ static void FixGuestCount()
}
auto& gameState = getGameState();
if (gameState.numGuestsInPark != guestCount)
if (gameState.park.numGuestsInPark != guestCount)
{
LOG_WARNING("Corrected bad amount of guests in park: %u -> %u", gameState.numGuestsInPark, guestCount);
LOG_WARNING("Corrected bad amount of guests in park: %u -> %u", gameState.park.numGuestsInPark, guestCount);
}
gameState.numGuestsInPark = guestCount;
gameState.park.numGuestsInPark = guestCount;
}
static void FixPeepsWithInvalidRideReference()
+2 -4
View File
@@ -41,9 +41,6 @@ namespace OpenRCT2
uint32_t currentTicks{};
Date date;
money64 constructionRightsPrice;
uint32_t guestsInParkHistory[kGuestsInParkHistorySize];
WeatherState weatherCurrent;
WeatherState weatherNext;
uint16_t weatherUpdateTimer;
@@ -55,7 +52,7 @@ namespace OpenRCT2
uint8_t guestInitialThirst;
uint8_t guestChangeModifier;
uint32_t nextGuestNumber;
uint32_t numGuestsInPark;
uint32_t numGuestsHeadingForPark;
uint32_t numGuestsInParkLastWeek;
money64 weeklyProfitAverageDividend;
@@ -74,6 +71,7 @@ namespace OpenRCT2
random_engine_t scenarioRand;
TileCoordsXY mapSize;
money64 landPrice;
money64 constructionRightsPrice;
EditorStep editorStep;
+10 -10
View File
@@ -1041,7 +1041,7 @@ void PeepProblemWarningsUpdate()
// could maybe be packed into a loop, would lose a lot of clarity though
if (warningThrottle[0])
--warningThrottle[0];
else if (hungerCounter >= kPeepHungerWarningThreshold && hungerCounter >= gameState.numGuestsInPark / 16)
else if (hungerCounter >= kPeepHungerWarningThreshold && hungerCounter >= gameState.park.numGuestsInPark / 16)
{
warningThrottle[0] = 4;
if (Config::Get().notifications.GuestWarnings)
@@ -1053,7 +1053,7 @@ void PeepProblemWarningsUpdate()
if (warningThrottle[1])
--warningThrottle[1];
else if (thirstCounter >= kPeepThirstWarningThreshold && thirstCounter >= gameState.numGuestsInPark / 16)
else if (thirstCounter >= kPeepThirstWarningThreshold && thirstCounter >= gameState.park.numGuestsInPark / 16)
{
warningThrottle[1] = 4;
if (Config::Get().notifications.GuestWarnings)
@@ -1065,7 +1065,7 @@ void PeepProblemWarningsUpdate()
if (warningThrottle[2])
--warningThrottle[2];
else if (toiletCounter >= kPeepToiletWarningThreshold && toiletCounter >= gameState.numGuestsInPark / 16)
else if (toiletCounter >= kPeepToiletWarningThreshold && toiletCounter >= gameState.park.numGuestsInPark / 16)
{
warningThrottle[2] = 4;
if (Config::Get().notifications.GuestWarnings)
@@ -1077,7 +1077,7 @@ void PeepProblemWarningsUpdate()
if (warningThrottle[3])
--warningThrottle[3];
else if (litterCounter >= kPeepLitterWarningThreshold && litterCounter >= gameState.numGuestsInPark / 32)
else if (litterCounter >= kPeepLitterWarningThreshold && litterCounter >= gameState.park.numGuestsInPark / 32)
{
warningThrottle[3] = 4;
if (Config::Get().notifications.GuestWarnings)
@@ -1089,7 +1089,7 @@ void PeepProblemWarningsUpdate()
if (warningThrottle[4])
--warningThrottle[4];
else if (disgustCounter >= kPeepDisgustWarningThreshold && disgustCounter >= gameState.numGuestsInPark / 32)
else if (disgustCounter >= kPeepDisgustWarningThreshold && disgustCounter >= gameState.park.numGuestsInPark / 32)
{
warningThrottle[4] = 4;
if (Config::Get().notifications.GuestWarnings)
@@ -1101,7 +1101,7 @@ void PeepProblemWarningsUpdate()
if (warningThrottle[5])
--warningThrottle[5];
else if (vandalismCounter >= kPeepVandalismWarningThreshold && vandalismCounter >= gameState.numGuestsInPark / 32)
else if (vandalismCounter >= kPeepVandalismWarningThreshold && vandalismCounter >= gameState.park.numGuestsInPark / 32)
{
warningThrottle[5] = 4;
if (Config::Get().notifications.GuestWarnings)
@@ -2591,9 +2591,9 @@ void PeepUpdateNames()
void IncrementGuestsInPark()
{
auto& gameState = getGameState();
if (gameState.numGuestsInPark < UINT32_MAX)
if (gameState.park.numGuestsInPark < UINT32_MAX)
{
gameState.numGuestsInPark++;
gameState.park.numGuestsInPark++;
}
else
{
@@ -2617,9 +2617,9 @@ void IncrementGuestsHeadingForPark()
void DecrementGuestsInPark()
{
auto& gameState = getGameState();
if (gameState.numGuestsInPark > 0)
if (gameState.park.numGuestsInPark > 0)
{
gameState.numGuestsInPark--;
gameState.park.numGuestsInPark--;
}
else
{
+6 -6
View File
@@ -108,7 +108,7 @@ static bool AwardIsDeservedMostUntidy(int32_t activeAwardTypes)
}
}
return (negativeCount > getGameState().numGuestsInPark / 16);
return (negativeCount > getGameState().park.numGuestsInPark / 16);
}
/** More than 1/64 of the total guests must be thinking tidy thoughts and less than 6 guests thinking untidy thoughts. */
@@ -140,7 +140,7 @@ static bool AwardIsDeservedMostTidy(int32_t activeAwardTypes)
}
}
return (negativeCount <= 5 && positiveCount > getGameState().numGuestsInPark / 64);
return (negativeCount <= 5 && positiveCount > getGameState().park.numGuestsInPark / 64);
}
/** At least 6 open roller coasters. */
@@ -223,7 +223,7 @@ static bool AwardIsDeservedMostBeautiful(int32_t activeAwardTypes)
}
}
return (negativeCount <= 15 && positiveCount > getGameState().numGuestsInPark / 128);
return (negativeCount <= 15 && positiveCount > getGameState().park.numGuestsInPark / 128);
}
/** Entrance fee is more than total ride value. */
@@ -313,7 +313,7 @@ static bool AwardIsDeservedBestFood(int32_t activeAwardTypes)
}
}
if (shops < 7 || uniqueShops < 4 || shops < getGameState().numGuestsInPark / 128)
if (shops < 7 || uniqueShops < 4 || shops < getGameState().park.numGuestsInPark / 128)
return false;
// Count hungry peeps
@@ -358,7 +358,7 @@ static bool AwardIsDeservedWorstFood(int32_t activeAwardTypes)
}
}
if (uniqueShops > 2 || shops > getGameState().numGuestsInPark / 256)
if (uniqueShops > 2 || shops > getGameState().park.numGuestsInPark / 256)
return false;
// Count hungry peeps
@@ -390,7 +390,7 @@ static bool AwardIsDeservedBestToilets([[maybe_unused]] int32_t activeAwardTypes
return false;
// At least one open toilet for every 128 guests
if (numToilets < getGameState().numGuestsInPark / 128u)
if (numToilets < getGameState().park.numGuestsInPark / 128u)
return false;
// Count number of guests who are thinking they need the toilet
@@ -310,7 +310,7 @@ private:
{ "mapSize", mapSize },
{ "day", date.GetMonthTicks() },
{ "month", date.GetMonthsElapsed() },
{ "guests", gameState.numGuestsInPark },
{ "guests", gameState.park.numGuestsInPark },
{ "parkValue", gameState.park.Value },
};
+2 -2
View File
@@ -979,7 +979,7 @@ namespace OpenRCT2
cs.ReadWrite(gameState.park.Value);
cs.ReadWrite(gameState.park.companyValue);
cs.ReadWrite(gameState.park.Size);
cs.ReadWrite(gameState.numGuestsInPark);
cs.ReadWrite(gameState.park.numGuestsInPark);
cs.ReadWrite(gameState.numGuestsHeadingForPark);
cs.ReadWrite(gameState.park.Rating);
cs.ReadWrite(gameState.park.RatingCasualtyPenalty);
@@ -1056,7 +1056,7 @@ namespace OpenRCT2
});
}
cs.ReadWriteArray(gameState.guestsInParkHistory, [&cs](uint32_t& value) {
cs.ReadWriteArray(gameState.park.guestsInParkHistory, [&cs](uint32_t& value) {
cs.ReadWrite(value);
return true;
});
+1 -1
View File
@@ -40,7 +40,7 @@ namespace OpenRCT2
.parkUsesMoney = !(gameState.park.Flags & PARK_FLAGS_NO_MONEY),
.cash = gameState.park.cash,
.numRides = static_cast<uint16_t>(RideManager().size()),
.numGuests = static_cast<uint16_t>(gameState.numGuestsInPark),
.numGuests = static_cast<uint16_t>(gameState.park.numGuestsInPark),
};
if (auto image = generatePreviewMap(); image != std::nullopt)
+3 -3
View File
@@ -2277,7 +2277,7 @@ namespace OpenRCT2::RCT1
{
if (_s4.GuestsInParkHistory[i] != kRCT12ParkHistoryUndefined)
{
gameState.guestsInParkHistory[i] = _s4.GuestsInParkHistory[i] * kRCT12GuestsInParkHistoryFactor;
gameState.park.guestsInParkHistory[i] = _s4.GuestsInParkHistory[i] * kRCT12GuestsInParkHistoryFactor;
}
}
@@ -2293,13 +2293,13 @@ namespace OpenRCT2::RCT1
// Number of guests history
std::fill(
std::begin(gameState.guestsInParkHistory), std::end(gameState.guestsInParkHistory),
std::begin(gameState.park.guestsInParkHistory), std::end(gameState.park.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())
{
gameState.guestsInParkHistory[i] = _s4.GuestsInParkHistory[i] * 20;
gameState.park.guestsInParkHistory[i] = _s4.GuestsInParkHistory[i] * 20;
}
}
+2 -2
View File
@@ -407,7 +407,7 @@ namespace OpenRCT2::RCT2
// _s6.ResearchedTrackTypesA
// _s6.ResearchedTrackTypesB
gameState.numGuestsInPark = _s6.GuestsInPark;
gameState.park.numGuestsInPark = _s6.GuestsInPark;
gameState.numGuestsHeadingForPark = _s6.GuestsHeadingForPark;
for (size_t i = 0; i < Limits::kExpenditureTableMonthCount; i++)
@@ -438,7 +438,7 @@ namespace OpenRCT2::RCT2
{
if (_s6.GuestsInParkHistory[i] != kRCT12ParkHistoryUndefined)
{
gameState.guestsInParkHistory[i] = _s6.GuestsInParkHistory[i] * kRCT12GuestsInParkHistoryFactor;
gameState.park.guestsInParkHistory[i] = _s6.GuestsInParkHistory[i] * kRCT12GuestsInParkHistoryFactor;
}
}
+2 -2
View File
@@ -609,7 +609,7 @@ ObjectiveStatus Objective::CheckGuestsBy() const
if (currentMonthYear == MONTH_COUNT * Year || AllowEarlyCompletion())
{
if (parkRating >= 600 && getGameState().numGuestsInPark >= NumGuests)
if (parkRating >= 600 && getGameState().park.numGuestsInPark >= NumGuests)
{
return ObjectiveStatus::Success;
}
@@ -730,7 +730,7 @@ ObjectiveStatus Objective::CheckGuestsAndRating() const
}
if (gameState.park.Rating >= 700)
if (gameState.numGuestsInPark >= NumGuests)
if (gameState.park.numGuestsInPark >= NumGuests)
return ObjectiveStatus::Success;
return ObjectiveStatus::Undecided;
@@ -139,7 +139,7 @@ namespace OpenRCT2::Scripting
uint32_t ScPark::guests_get() const
{
return getGameState().numGuestsInPark;
return getGameState().park.numGuestsInPark;
}
uint32_t ScPark::suggestedGuestMaximum_get() const
+14 -13
View File
@@ -183,7 +183,7 @@ namespace OpenRCT2::Park
uint32_t probability = 50 + std::clamp(gameState.park.Rating - 200, 0, 650);
// The more guests, the lower the chance of a new one
uint32_t numGuests = gameState.numGuestsInPark + gameState.numGuestsHeadingForPark;
uint32_t numGuests = gameState.park.numGuestsInPark + gameState.numGuestsHeadingForPark;
if (numGuests > gameState.suggestedGuestMaximum)
{
probability /= 4;
@@ -235,7 +235,7 @@ namespace OpenRCT2::Park
if (static_cast<int32_t>(ScenarioRand() & 0xFFFF) < gameState.guestGenerationProbability)
{
bool difficultGeneration = (gameState.park.Flags & PARK_FLAGS_DIFFICULT_GUEST_GENERATION) != 0;
if (!difficultGeneration || gameState.suggestedGuestMaximum + 150 >= gameState.numGuestsInPark)
if (!difficultGeneration || gameState.suggestedGuestMaximum + 150 >= gameState.park.numGuestsInPark)
{
GenerateGuest();
}
@@ -281,7 +281,7 @@ namespace OpenRCT2::Park
gameState.staffHandymanColour = COLOUR_BRIGHT_RED;
gameState.staffMechanicColour = COLOUR_LIGHT_BLUE;
gameState.staffSecurityColour = COLOUR_YELLOW;
gameState.numGuestsInPark = 0;
gameState.park.numGuestsInPark = 0;
gameState.numGuestsInParkLastWeek = 0;
gameState.numGuestsHeadingForPark = 0;
gameState.guestChangeModifier = 0;
@@ -410,7 +410,7 @@ namespace OpenRCT2::Park
// Guests
{
// -150 to +3 based on a range of guests from 0 to 2000
result -= 150 - (std::min<int32_t>(2000, gameState.numGuestsInPark) / 13);
result -= 150 - (std::min<int32_t>(2000, gameState.park.numGuestsInPark) / 13);
// Find the number of happy peeps and the number of peeps who can't find the park exit
uint32_t happyGuestCount = 0;
@@ -432,9 +432,9 @@ namespace OpenRCT2::Park
// Peep happiness -500 to +0
result -= 500;
if (gameState.numGuestsInPark > 0)
if (gameState.park.numGuestsInPark > 0)
{
result += 2 * std::min(250u, (happyGuestCount * 300) / gameState.numGuestsInPark);
result += 2 * std::min(250u, (happyGuestCount * 300) / gameState.park.numGuestsInPark);
}
// Up to 25 guests can be lost without affecting the park rating.
@@ -520,7 +520,7 @@ namespace OpenRCT2::Park
}
// +7.00 per guest
result += static_cast<money64>(getGameState().numGuestsInPark) * 7.00_GBP;
result += static_cast<money64>(getGameState().park.numGuestsInPark) * 7.00_GBP;
return result;
}
@@ -586,13 +586,14 @@ namespace OpenRCT2::Park
std::fill(
std::begin(gameState.park.RatingHistory), std::end(gameState.park.RatingHistory), kParkRatingHistoryUndefined);
std::fill(
std::begin(gameState.guestsInParkHistory), std::end(gameState.guestsInParkHistory), kGuestsInParkHistoryUndefined);
std::begin(gameState.park.guestsInParkHistory), std::end(gameState.park.guestsInParkHistory),
kGuestsInParkHistoryUndefined);
}
void UpdateHistories(GameState_t& gameState)
{
uint8_t guestChangeModifier = 1;
int32_t changeInGuestsInPark = static_cast<int32_t>(gameState.numGuestsInPark)
int32_t changeInGuestsInPark = static_cast<int32_t>(gameState.park.numGuestsInPark)
- static_cast<int32_t>(gameState.numGuestsInParkLastWeek);
if (changeInGuestsInPark > -20)
{
@@ -603,15 +604,15 @@ namespace OpenRCT2::Park
}
}
gameState.guestChangeModifier = guestChangeModifier;
gameState.numGuestsInParkLastWeek = gameState.numGuestsInPark;
gameState.numGuestsInParkLastWeek = gameState.park.numGuestsInPark;
// Update park rating, guests in park and current cash history
constexpr auto ratingHistorySize = std::extent_v<decltype(ParkData::RatingHistory)>;
HistoryPushRecord<uint16_t, ratingHistorySize>(gameState.park.RatingHistory, gameState.park.Rating);
constexpr auto numGuestsHistorySize = std::extent_v<decltype(GameState_t::guestsInParkHistory)>;
HistoryPushRecord<uint32_t, numGuestsHistorySize>(gameState.guestsInParkHistory, gameState.numGuestsInPark);
constexpr auto numGuestsHistorySize = std::extent_v<decltype(ParkData::guestsInParkHistory)>;
HistoryPushRecord<uint32_t, numGuestsHistorySize>(gameState.park.guestsInParkHistory, gameState.park.numGuestsInPark);
constexpr auto cashHistorySize = std::extent_v<decltype(GameState_t::park.cashHistory)>;
constexpr auto cashHistorySize = std::extent_v<decltype(ParkData::cashHistory)>;
HistoryPushRecord<money64, cashHistorySize>(gameState.park.cashHistory, FinanceGetCurrentCash() - gameState.bankLoan);
// Update weekly profit history
+3
View File
@@ -77,5 +77,8 @@ namespace OpenRCT2::Park
money64 currentExpenditure;
money64 companyValue;
uint32_t guestsInParkHistory[kGuestsInParkHistorySize];
uint32_t numGuestsInPark;
};
} // namespace OpenRCT2::Park