From 7d6bfa19ea456c0ac102d36ab28b41b300e86b34 Mon Sep 17 00:00:00 2001 From: Robert Jordan Date: Fri, 13 Oct 2017 04:00:42 -0400 Subject: [PATCH] Fix #6452: scenario text truncated when switching architectures `ScenarioFileIndex`'s `Serialize` and `Deserialize` now read and write each individual value of a `scenario_index_entry` instead of the entire struct at once. Thus the difference in pointer sizes of `highscore` on different architecture builds will not cause issues with `scenarios.idx`. --- distribution/changelog.txt | 1 + src/openrct2/scenario/ScenarioRepository.cpp | 45 ++++++++++++++++---- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 455bc5b994..aa07a60793 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -42,6 +42,7 @@ - Fix: [#6423] Importing parks containing names with Polish characters. - Fix: [#6423] Polish characters now correctly drawn when using the sprite font. - Fix: [#6445] Guests' favourite ride improperly set when importing from RCT1 or AA. +- Fix: [#6452] Scenario text cut off when switching between 32 and 64-bit builds. - Fix: Infinite loop when removing scenery elements with >127 base height. - Fix: Ghosting of transparent map elements when the viewport is moved in OpenGL mode. - Fix: Clear IME buffer after committing composed text. diff --git a/src/openrct2/scenario/ScenarioRepository.cpp b/src/openrct2/scenario/ScenarioRepository.cpp index efce36d9d2..ff15ce8d8d 100644 --- a/src/openrct2/scenario/ScenarioRepository.cpp +++ b/src/openrct2/scenario/ScenarioRepository.cpp @@ -123,7 +123,7 @@ class ScenarioFileIndex final : public FileIndex { private: static constexpr uint32 MAGIC_NUMBER = 0x58444953; // SIDX - static constexpr uint16 VERSION = 1; + static constexpr uint16 VERSION = 2; static constexpr auto PATTERN = "*.sc4;*.sc6"; public: @@ -157,18 +157,45 @@ protected: void Serialise(IStream * stream, const scenario_index_entry &item) const override { - // HACK: Zero highscore pointer - auto copy = item; - copy.highscore = nullptr; - stream->WriteValue(copy); + stream->Write(item.path, sizeof(item.path)); + stream->WriteValue(item.timestamp); + + stream->WriteValue(item.category); + stream->WriteValue(item.source_game); + stream->WriteValue(item.source_index); + stream->WriteValue(item.sc_id); + + stream->WriteValue(item.objective_type); + stream->WriteValue(item.objective_arg_1); + stream->WriteValue(item.objective_arg_2); + stream->WriteValue(item.objective_arg_3); + + stream->Write(item.name, sizeof(item.name)); + stream->Write(item.details, sizeof(item.details)); } scenario_index_entry Deserialise(IStream * stream) const override { - auto result = stream->ReadValue(); - // HACK: Zero highscore pointer - result.highscore = nullptr; - return result; + scenario_index_entry item; + + stream->Read(item.path, sizeof(item.path)); + item.timestamp = stream->ReadValue(); + + item.category = stream->ReadValue(); + item.source_game = stream->ReadValue(); + item.source_index = stream->ReadValue(); + item.sc_id = stream->ReadValue(); + + item.objective_type = stream->ReadValue(); + item.objective_arg_1 = stream->ReadValue(); + item.objective_arg_2 = stream->ReadValue(); + item.objective_arg_3 = stream->ReadValue(); + item.highscore = nullptr; + + stream->Read(item.name, sizeof(item.name)); + stream->Read(item.details, sizeof(item.details)); + + return item; } private: