1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 01:22:25 +01:00

Fix for Attempt to decrement guests in park and guests heading for park below zero. #21172

Fix:
- Calling recompute peep functions when in title sequence
- Provided a way to ignore the warning for title sequence
This commit is contained in:
Jater Xu
2025-09-01 19:47:42 -07:00
parent e9456ae68a
commit 6fb00193ac
4 changed files with 12 additions and 8 deletions

View File

@@ -251,6 +251,7 @@ Appreciation for contributors who have provided substantial work, but are no lon
* (QuestionableDeer)
* David Sungaila (sungaila)
* Garrett Leach (GarrettLeach)
* Ruohao (Jater) Xu (jaterx)
## Toolchain
* (Balletie) - macOS

View File

@@ -326,6 +326,9 @@ namespace OpenRCT2::Title
// TODO: Have a separate GameState and exchange once loaded.
auto& gameState = getGameState();
parkImporter->Import(gameState);
GameFixSaveVars(true);
ReportProgress(100);
MapAnimations::MarkAllTiles();

View File

@@ -182,7 +182,7 @@ void RCT2StringToUTF8Self(char* buffer, size_t length)
}
}
static void FixGuestsHeadingToParkCount()
static void FixGuestsHeadingToParkCount(const bool bIgnoreWarning)
{
uint32_t guestsHeadingToPark = 0;
@@ -195,7 +195,7 @@ static void FixGuestsHeadingToParkCount()
}
auto& park = getGameState().park;
if (park.numGuestsHeadingForPark != guestsHeadingToPark)
if (!bIgnoreWarning && park.numGuestsHeadingForPark != guestsHeadingToPark)
{
LOG_WARNING(
"Corrected bad amount of guests heading to park: %u -> %u", park.numGuestsHeadingForPark, guestsHeadingToPark);
@@ -204,7 +204,7 @@ static void FixGuestsHeadingToParkCount()
park.numGuestsHeadingForPark = guestsHeadingToPark;
}
static void FixGuestCount()
static void FixGuestCount(const bool bIgnoreWarning)
{
// Recalculates peep count after loading a save to fix corrupted files
uint32_t guestCount = 0;
@@ -218,7 +218,7 @@ static void FixGuestCount()
}
auto& park = getGameState().park;
if (park.numGuestsInPark != guestCount)
if (!bIgnoreWarning && park.numGuestsInPark != guestCount)
{
LOG_WARNING("Corrected bad amount of guests in park: %u -> %u", park.numGuestsInPark, guestCount);
}
@@ -317,11 +317,11 @@ static void FixInvalidSurfaces()
// OpenRCT2 workaround to recalculate some values which are saved redundantly in the save to fix corrupted files.
// For example recalculate guest count by looking at all the guests instead of trusting the value in the file.
void GameFixSaveVars()
void GameFixSaveVars(const bool bShouldIgnoreWarning)
{
FixGuestsHeadingToParkCount();
FixGuestsHeadingToParkCount(bShouldIgnoreWarning);
FixGuestCount();
FixGuestCount(bShouldIgnoreWarning);
FixPeepsWithInvalidRideReference();

View File

@@ -174,7 +174,7 @@ void SaveGameCmd(u8string_view name = {});
void SaveGameWithName(u8string_view name);
void GameAutosave();
void RCT2StringToUTF8Self(char* buffer, size_t length);
void GameFixSaveVars();
void GameFixSaveVars(const bool bShouldIgnoreWarning = false);
void StartSilentRecord();
bool StopSilentRecord();
void PrepareMapForSave();