From 612e268e5f9d27b373613b9bc0302ba4e5a1151e Mon Sep 17 00:00:00 2001 From: Ted John Date: Mon, 30 Jan 2017 22:06:24 +0000 Subject: [PATCH] Allow SC4s to be loaded by title seq player --- src/openrct2/rct1/S4Importer.cpp | 1 - src/openrct2/title/TitleSequencePlayer.cpp | 48 ++++++++++++++++++---- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 2724a4279d..89dbed9611 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -227,7 +227,6 @@ private: uint16 mapSize = _s4.map_size == 0 ? 128 : _s4.map_size; // Do map initialisation, same kind of stuff done when loading scenario editor - audio_stop_all_music_and_sounds(); GetObjectManager()->UnloadAll(); game_init_all(mapSize); gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION; diff --git a/src/openrct2/title/TitleSequencePlayer.cpp b/src/openrct2/title/TitleSequencePlayer.cpp index 32029ed072..0505b531ef 100644 --- a/src/openrct2/title/TitleSequencePlayer.cpp +++ b/src/openrct2/title/TitleSequencePlayer.cpp @@ -22,6 +22,7 @@ #include "../core/Math.hpp" #include "../core/Path.hpp" #include "../core/String.hpp" +#include "../rct1/S4Importer.h" #include "../scenario/ScenarioRepository.h" #include "../scenario/ScenarioSources.h" #include "TitleSequence.h" @@ -352,12 +353,40 @@ private: bool LoadParkFromFile(const utf8 * path) { bool success = false; - bool isScenario = String::Equals(Path::GetExtension(path), ".sc6", true); - SDL_RWops * rw = SDL_RWFromFile(path, "rb"); - if (rw != nullptr) + const utf8 * extension = Path::GetExtension(path); + if (String::Equals(extension, ".sc4", true) || + String::Equals(extension, ".sv4", true)) { - success = LoadParkFromRW(rw, isScenario); - SDL_RWclose(rw); + try + { + bool isScenario = String::Equals(extension, ".sc4", true); + IS4Importer * s4Importer = CreateS4Importer(); + if (isScenario) + { + s4Importer->LoadScenario(path); + s4Importer->Import(); + } + else + { + s4Importer->LoadSavedGame(path); + s4Importer->Import(); + } + PrepareParkForPlayback(isScenario); + success = true; + } + catch (Exception) + { + } + } + else + { + bool isScenario = String::Equals(extension, ".sc6", true); + SDL_RWops * rw = SDL_RWFromFile(path, "rb"); + if (rw != nullptr) + { + success = LoadParkFromRW(rw, isScenario); + SDL_RWclose(rw); + } } return success; } @@ -366,11 +395,15 @@ private: { bool successfulLoad = isScenario ? scenario_load_rw(rw) : game_load_sv6(rw); - if (!successfulLoad) + if (successfulLoad) { - return false; + PrepareParkForPlayback(isScenario); } + return successfulLoad; + } + void PrepareParkForPlayback(bool isScenario) + { rct_window * w = window_get_main(); w->viewport_target_sprite = -1; w->saved_view_x = gSavedViewX; @@ -410,7 +443,6 @@ private: gfx_invalidate_screen(); gScreenAge = 0; gGameSpeed = 1; - return true; } /**