From aa69593064bc7f28703591ffc07e425723e84739 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Mon, 19 Jul 2021 10:12:03 -0400 Subject: [PATCH] Close #12626: Allow completing RCTC scenarios with RCT2 saves --- contributors.md | 1 + distribution/changelog.txt | 1 + src/openrct2/scenario/ScenarioRepository.cpp | 25 +++++++++++++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/contributors.md b/contributors.md index 94aa5b8ea4..4213c6d9ad 100644 --- a/contributors.md +++ b/contributors.md @@ -171,6 +171,7 @@ The following people are not part of the development team, but have been contrib * (zrowny) * Emre Aydin (aemreaydin) * Daniel Karandikar (DKarandikar) +* Struan Clark (xtruan) ## Toolchain * (Balletie) - macOS diff --git a/distribution/changelog.txt b/distribution/changelog.txt index b42e99a77c..ebb91fefa9 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,5 +1,6 @@ 0.3.4+ (in development) ------------------------------------------------------------------------ +- Improved: [#12626] Allow using RCT2 saves to mark RCT Classic (.sea) parks as finished and vice versa. 0.3.4 (2021-07-19) ------------------------------------------------------------------------ diff --git a/src/openrct2/scenario/ScenarioRepository.cpp b/src/openrct2/scenario/ScenarioRepository.cpp index 27abf48eb3..9f9aefcd48 100644 --- a/src/openrct2/scenario/ScenarioRepository.cpp +++ b/src/openrct2/scenario/ScenarioRepository.cpp @@ -423,6 +423,25 @@ public: Scan(language); scenario_index_entry* scenario = GetByFilename(scenarioFileName); + + // Check if this is an RCTC scenario that corresponds to a known RCT1/2 scenario or vice versa, see #12626 + if (scenario == nullptr) + { + const std::string scenarioBaseName = String::ToStd(Path::GetFileNameWithoutExtension(scenarioFileName)); + const std::string scenarioExtension = String::ToStd(Path::GetExtension(scenarioFileName)); + + if (String::Equals(scenarioExtension, ".sea", true)) + { + // Get scenario using RCT2 style name of RCTC scenario + scenario = GetByFilename((scenarioBaseName + ".sc6").c_str()); + } + else if (String::Equals(scenarioExtension, ".sc6", true)) + { + // Get scenario using RCTC style name of RCT2 scenario + scenario = GetByFilename((scenarioBaseName + ".sea").c_str()); + } + } + if (scenario != nullptr) { // Check if record company value has been broken or the highscore is the same but no name is registered @@ -705,10 +724,10 @@ private: { for (auto& highscore : _highscores) { - scenario_index_entry* scenerio = GetByFilename(highscore->fileName); - if (scenerio != nullptr) + scenario_index_entry* scenario = GetByFilename(highscore->fileName); + if (scenario != nullptr) { - scenerio->highscore = highscore; + scenario->highscore = highscore; } } }