diff --git a/src/openrct2/OpenRCT2.cpp b/src/openrct2/OpenRCT2.cpp index 9de2e9cf6f..06f82fda1a 100644 --- a/src/openrct2/OpenRCT2.cpp +++ b/src/openrct2/OpenRCT2.cpp @@ -14,16 +14,18 @@ *****************************************************************************/ #pragma endregion +#include #include #include "core/Console.hpp" -#include "core/Guard.hpp" #include "core/File.h" #include "core/FileStream.hpp" +#include "core/Guard.hpp" #include "core/String.hpp" #include "FileClassifier.h" #include "network/network.h" #include "object/ObjectRepository.h" #include "OpenRCT2.h" +#include "ParkImporter.h" #include "platform/crash.h" #include "PlatformEnvironment.h" #include "ride/TrackDesignRepository.h" @@ -518,50 +520,59 @@ namespace OpenRCT2 ClassifiedFile info; if (TryClassifyFile(path, &info)) { - if (info.Type == FILE_TYPE::SAVED_GAME) + if (info.Type == FILE_TYPE::SAVED_GAME || + info.Type == FILE_TYPE::SCENARIO) { + std::unique_ptr parkImporter; if (info.Version <= 2) { - if (rct1_load_saved_game(path)) + parkImporter.reset(ParkImporter::CreateS4()); + } + else + { + parkImporter.reset(ParkImporter::CreateS6()); + } + + if (info.Type == FILE_TYPE::SAVED_GAME) + { + try { + parkImporter->LoadSavedGame(path); + parkImporter->Import(); + game_fix_save_vars(); + sprite_position_tween_reset(); + gScreenAge = 0; + gLastAutoSaveUpdate = AUTOSAVE_PAUSE; game_load_init(); return true; } + catch (const Exception &) + { + Console::Error::WriteLine("Error loading saved game."); + } } else { - if (game_load_save(path)) - { - gFirstTimeSave = 0; - return true; - } - } - Console::Error::WriteLine("Error loading saved game."); - } - else if (info.Type == FILE_TYPE::SCENARIO) - { - if (info.Version <= 2) - { - - if (rct1_load_scenario(path)) + try { + parkImporter->LoadScenario(path); + parkImporter->Import(); + game_fix_save_vars(); + sprite_position_tween_reset(); + gScreenAge = 0; + gLastAutoSaveUpdate = AUTOSAVE_PAUSE; scenario_begin(); return true; } - } - else - { - if (scenario_load_and_play_from_path(path)) + catch (const Exception &) { - return true; + Console::Error::WriteLine("Error loading scenario."); } } - Console::Error::WriteLine("Error loading scenario."); } else { Console::Error::WriteLine("Invalid file type."); - Console::Error::WriteLine("Invalid file type."); } } else