diff --git a/src/editor.c b/src/editor.c index c6f9c267c1..12cebb9727 100644 --- a/src/editor.c +++ b/src/editor.c @@ -309,7 +309,14 @@ static int editor_load_landscape_from_sc4(const char *path) */ static int editor_read_s6(const char *path) { - if (!scenario_load(path)) { + bool loadResult; + const char *extension = path_get_extension(path); + if (_stricmp(extension, ".sc6") == 0) { + loadResult = scenario_load(path); + } else if (_stricmp(extension, ".sv6") == 0) { + loadResult = game_load_sv6_path(path); + } + if (!loadResult) { return 0; } diff --git a/src/game.h b/src/game.h index 23b53d2be7..f067af0dba 100644 --- a/src/game.h +++ b/src/game.h @@ -165,6 +165,7 @@ void game_increase_game_speed(); void game_reduce_game_speed(); void game_load_or_quit_no_save_prompt(); +bool game_load_sv6_path(const char * path); int game_load_sv6(SDL_RWops* rw); int game_load_network(SDL_RWops* rw); bool game_load_save(const utf8 *path); diff --git a/src/rct2/S6Importer.cpp b/src/rct2/S6Importer.cpp index 33fac05816..330d500023 100644 --- a/src/rct2/S6Importer.cpp +++ b/src/rct2/S6Importer.cpp @@ -400,6 +400,41 @@ extern "C" return result; } + bool game_load_sv6_path(const char * path) + { + bool result = false; + auto s6Importer = new S6Importer(); + try + { + s6Importer->FixIssues = true; + s6Importer->LoadSavedGame(path); + s6Importer->Import(); + + openrct2_reset_object_tween_locations(); + result = true; + } + catch (ObjectLoadException) + { + gErrorType = ERROR_TYPE_FILE_LOAD; + gErrorStringId = STR_GAME_SAVE_FAILED; + } + catch (IOException) + { + gErrorType = ERROR_TYPE_FILE_LOAD; + gErrorStringId = STR_GAME_SAVE_FAILED; + } + catch (Exception) + { + gErrorType = ERROR_TYPE_FILE_LOAD; + gErrorStringId = STR_FILE_CONTAINS_INVALID_DATA; + } + delete s6Importer; + + gScreenAge = 0; + gLastAutoSaveTick = SDL_GetTicks(); + return result; + } + /** * * rct2: 0x00676053