From 1578cd816a3c2cde9636f5bd441a56c700bb6286 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Sun, 3 Jul 2022 16:19:42 +0200 Subject: [PATCH 1/3] Fix #17493: Title sequence defaults to RCT1 Even while the default config value is "*OPENRCT2", the game failed to find this config ID and fell back to the first sequence in the list instead. --- src/openrct2/title/TitleSequenceManager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/openrct2/title/TitleSequenceManager.cpp b/src/openrct2/title/TitleSequenceManager.cpp index ce8033b052..e819c640e3 100644 --- a/src/openrct2/title/TitleSequenceManager.cpp +++ b/src/openrct2/title/TitleSequenceManager.cpp @@ -274,8 +274,7 @@ namespace TitleSequenceManager { for (const auto& pseq : TitleSequenceManager::PredefinedSequences) { - auto predefinedName = Path::GetFileNameWithoutExtension(pseq.Filename); - if (String::Equals(name, predefinedName, true)) + if (String::Equals(name, pseq.ConfigId, true)) { return true; } @@ -317,7 +316,7 @@ const utf8* title_sequence_manager_get_config_id(size_t index) return nullptr; } const auto& name = item->Name; - auto filename = Path::GetFileName(name); + const auto filename = Path::GetFileName(item->Path); for (const auto& pseq : TitleSequenceManager::PredefinedSequences) { if (String::Equals(filename, pseq.Filename, true)) From d06f564506ef233990698182f0de3606ac84c308 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Sun, 3 Jul 2022 16:20:23 +0200 Subject: [PATCH 2/3] Clean up some title sequence code --- src/openrct2-ui/scripting/ScTitleSequence.hpp | 2 +- src/openrct2/title/TitleSequenceManager.cpp | 13 ++----------- src/openrct2/title/TitleSequenceManager.h | 4 ++-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/openrct2-ui/scripting/ScTitleSequence.hpp b/src/openrct2-ui/scripting/ScTitleSequence.hpp index c2e61a04bf..04aa9a83fa 100644 --- a/src/openrct2-ui/scripting/ScTitleSequence.hpp +++ b/src/openrct2-ui/scripting/ScTitleSequence.hpp @@ -360,7 +360,7 @@ namespace OpenRCT2::Scripting const auto* item = GetItem(); if (item != nullptr) { - return item->PredefinedIndex != std::numeric_limits::max(); + return item->PredefinedIndex != PREDEFINED_INDEX_CUSTOM; } return {}; } diff --git a/src/openrct2/title/TitleSequenceManager.cpp b/src/openrct2/title/TitleSequenceManager.cpp index e819c640e3..da61dd419f 100644 --- a/src/openrct2/title/TitleSequenceManager.cpp +++ b/src/openrct2/title/TitleSequenceManager.cpp @@ -182,13 +182,9 @@ namespace TitleSequenceManager // Sort sequences by predefined index and then name std::sort( _items.begin(), _items.end(), [](const TitleSequenceManagerItem& a, const TitleSequenceManagerItem& b) -> bool { - if (a.PredefinedIndex < b.PredefinedIndex) + if (a.PredefinedIndex != b.PredefinedIndex) { - return true; - } - if (a.PredefinedIndex > b.PredefinedIndex) - { - return false; + return a.PredefinedIndex < b.PredefinedIndex; } return _strcmpi(a.Name.c_str(), b.Name.c_str()) < 0; }); @@ -366,11 +362,6 @@ size_t title_sequence_manager_get_index_for_name(const utf8* name) return SIZE_MAX; } -bool title_sequence_manager_is_name_reserved(const utf8* name) -{ - return TitleSequenceManager::IsNameReserved(name); -} - void title_sequence_manager_scan() { TitleSequenceManager::Scan(); diff --git a/src/openrct2/title/TitleSequenceManager.h b/src/openrct2/title/TitleSequenceManager.h index 17ff5b7932..c4fb3a236a 100644 --- a/src/openrct2/title/TitleSequenceManager.h +++ b/src/openrct2/title/TitleSequenceManager.h @@ -11,6 +11,7 @@ #include "../common.h" #include "../core/String.hpp" +#include #include struct TitleSequenceManagerItem @@ -32,7 +33,7 @@ namespace TitleSequenceManager void Scan(); } // namespace TitleSequenceManager -constexpr const size_t PREDEFINED_INDEX_CUSTOM = SIZE_MAX; +constexpr const size_t PREDEFINED_INDEX_CUSTOM = std::numeric_limits::max(); size_t title_sequence_manager_get_count(); const utf8* title_sequence_manager_get_name(size_t index); @@ -41,7 +42,6 @@ const utf8* title_sequence_manager_get_config_id(size_t index); size_t title_sequence_manager_get_predefined_index(size_t index); size_t title_sequence_manager_get_index_for_config_id(const utf8* configId); size_t title_sequence_manager_get_index_for_name(const utf8* name); -bool title_sequence_manager_is_name_reserved(const utf8* name); void title_sequence_manager_scan(); void title_sequence_manager_delete(size_t i); size_t title_sequence_manager_rename(size_t i, const utf8* name); From 43a98680ac7e196888097ba349180e4e58cc523e Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Sun, 3 Jul 2022 16:39:27 +0200 Subject: [PATCH 3/3] Fix: Fallback when selecting RCT1 titles while it's not installed --- src/openrct2-ui/title/TitleSequencePlayer.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/openrct2-ui/title/TitleSequencePlayer.cpp b/src/openrct2-ui/title/TitleSequencePlayer.cpp index cde1ca3c7a..c787687515 100644 --- a/src/openrct2-ui/title/TitleSequencePlayer.cpp +++ b/src/openrct2-ui/title/TitleSequencePlayer.cpp @@ -161,22 +161,32 @@ namespace OpenRCT2::Title if (!loadSuccess) { - auto message = std::string("Failed to load: \"") + scenarioName + " for the title sequence."; + auto message = std::string("Failed to load: \"") + scenarioName + "\" for the title sequence."; throw std::domain_error(message); } game_notify_map_changed(); } + + IncrementPosition(); } catch (std::exception& e) { const char* commandName = std::visit( [](auto&& command) { return std::decay_t::Name; }, currentCommand); Console::Error::WriteLine("%s (command %i) failed with error: %s", commandName, _position, e.what()); - Console::Error::WriteLine(" Skipping to the next command."); - } - IncrementPosition(); + if (TitleSequenceIsLoadCommand(currentCommand)) + { + Console::Error::WriteLine(" Skipping to the next load command."); + SkipToNextLoadCommand(); + } + else + { + Console::Error::WriteLine(" Skipping to the next command."); + IncrementPosition(); + } + } if (_position == entryPosition) {