From e77d9c0c30efb120b921f9fbc64191bef581a513 Mon Sep 17 00:00:00 2001 From: orbifant <24986292+orbifant@users.noreply.github.com> Date: Sat, 1 Mar 2025 20:51:10 +0100 Subject: [PATCH] Fix #23743: Park with > 32k guests goal not in scenario list Creating the scenario cache file tried to read the guest count as signed 16 bit value which doesn't work for values > 32k. In addition ObjectiveArg3 (variable to store guest count) is an signed value, unable to store 50k guests. --- distribution/changelog.txt | 1 + src/openrct2/park/ParkFile.cpp | 3 ++- src/openrct2/rct2/RCT2.h | 12 ++++++------ src/openrct2/scenario/ScenarioRepository.h | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index c0f85f550f..1332f44619 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -2,6 +2,7 @@ ------------------------------------------------------------------------ - Fix: [#4225] Ride Construction window offers non-existent banked sloped to level curve (original bug). - Fix: [#10379] Banners outside the park can be renamed and modified (original bug). +- Fix: [#23743] Parks with guest goals over 32767 do not appear in the scenario list. - Fix: [#23844] Sound effects keep playing when loading another save. - Fix: [#23897] Reverse Freefall Coaster slope up to vertical track piece does not draw a vertical tunnel. diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index aacc65d5d5..df533002e3 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -224,9 +224,10 @@ namespace OpenRCT2 ReadWriteStringTable(cs, scenarioDetails, "en-GB"); entry.Details = scenarioDetails; + // wrong order is intentional here due to ReadWriteScenarioChunk writing guests first entry.ObjectiveType = cs.Read(); entry.ObjectiveArg1 = cs.Read(); - entry.ObjectiveArg3 = cs.Read(); + entry.ObjectiveArg3 = cs.Read(); entry.ObjectiveArg2 = cs.Read(); entry.SourceGame = ScenarioSource::Other; diff --git a/src/openrct2/rct2/RCT2.h b/src/openrct2/rct2/RCT2.h index c8b74202dd..89844ee812 100644 --- a/src/openrct2/rct2/RCT2.h +++ b/src/openrct2/rct2/RCT2.h @@ -393,7 +393,7 @@ namespace OpenRCT2::RCT2 int8_t ObjectiveType; int8_t ObjectiveArg1; int32_t objectiveArg2; - int16_t objectiveArg3; + uint16_t objectiveArg3; char Name[64]; char Details[256]; int32_t Flags; @@ -758,11 +758,11 @@ namespace OpenRCT2::RCT2 struct S6Info { ::EditorStep EditorStep; - uint8_t Category; // 0x01 - uint8_t ObjectiveType; // 0x02 - uint8_t ObjectiveArg1; // 0x03 - int32_t ObjectiveArg2; // 0x04 - int16_t ObjectiveArg3; // 0x08 + uint8_t Category; // 0x01 + uint8_t ObjectiveType; // 0x02 + uint8_t ObjectiveArg1; // 0x03 + int32_t ObjectiveArg2; // 0x04 + uint16_t ObjectiveArg3; // 0x08 uint8_t Pad00A[0x3E]; char Name[64]; // 0x48 char Details[256]; // 0x88 diff --git a/src/openrct2/scenario/ScenarioRepository.h b/src/openrct2/scenario/ScenarioRepository.h index a78103ac3b..2f2d823f87 100644 --- a/src/openrct2/scenario/ScenarioRepository.h +++ b/src/openrct2/scenario/ScenarioRepository.h @@ -52,9 +52,9 @@ struct ScenarioIndexEntry // Objective uint8_t ObjectiveType; - uint8_t ObjectiveArg1; - int64_t ObjectiveArg2; - int16_t ObjectiveArg3; + uint8_t ObjectiveArg1; // years + int64_t ObjectiveArg2; // money or excitement + uint16_t ObjectiveArg3; // guests or rideID or coasterLength ScenarioHighscoreEntry* Highscore = nullptr; u8string InternalName; // Untranslated name