diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 124cd03fc6..2be5d6a8fd 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -287,7 +287,6 @@ namespace OpenRCT2 if (!parkLoaded) { Console::Error::WriteLine("Failed to load '%s'", gOpenRCT2StartupActionPath); - title_load(); break; } diff --git a/src/openrct2/game.c b/src/openrct2/game.c index e199c66c86..a13b54ea87 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -1128,10 +1128,15 @@ bool game_load_save(const utf8 *path) } } -void handle_park_load_failure(const ParkLoadResult * result, const utf8 * path) +void handle_park_load_failure_with_title_opt(const ParkLoadResult * result, const utf8 * path, bool loadTitleFirst) { if (ParkLoadResult_GetError(result) == PARK_LOAD_ERROR_MISSING_OBJECTS) { + // This option is used when loading parks from the command line + // to ensure that the title sequence loads before the window + if (loadTitleFirst) { + title_load(); + } // The path needs to be duplicated as it's a const here // which the window function doesn't like window_object_load_error_open(strndup(path, strnlen(path, MAX_PATH)), @@ -1144,6 +1149,11 @@ void handle_park_load_failure(const ParkLoadResult * result, const utf8 * path) } } +void handle_park_load_failure(const ParkLoadResult * result, const utf8 * path) +{ + handle_park_load_failure_with_title_opt(result, path, false); +} + void game_load_init() { rct_window *mainWindow; diff --git a/src/openrct2/game.h b/src/openrct2/game.h index 60614715f3..5b5b533bd9 100644 --- a/src/openrct2/game.h +++ b/src/openrct2/game.h @@ -179,6 +179,7 @@ bool game_is_paused(); bool game_is_not_paused(); void save_game(); void save_game_as(); +void handle_park_load_failure_with_title_opt(const ParkLoadResult * result, const utf8 * path, bool loadTitleFirst); void handle_park_load_failure(const ParkLoadResult * result, const utf8 * path); void rct2_exit(); void rct2_exit_reason(rct_string_id title, rct_string_id body); diff --git a/src/openrct2/rct2.c b/src/openrct2/rct2.c index 7179ef7dfb..4819822e9f 100644 --- a/src/openrct2/rct2.c +++ b/src/openrct2/rct2.c @@ -334,10 +334,17 @@ bool rct2_open_file(const char *path) extension++; if (_stricmp(extension, "sv6") == 0) { - if (game_load_save(path)) { + ParkLoadResult * result = game_load_sv6_path(path); + if (ParkLoadResult_GetError(result) == PARK_LOAD_ERROR_OK) { + ParkLoadResult_Delete(result); gFirstTimeSaving = false; return true; } + else { + handle_park_load_failure_with_title_opt(result, path, true); + ParkLoadResult_Delete(result); + return false; + } } else if (_stricmp(extension, "sc6") == 0) { // TODO scenario install ParkLoadResult * result = scenario_load_and_play_from_path(path); @@ -345,7 +352,7 @@ bool rct2_open_file(const char *path) ParkLoadResult_Delete(result); return true; } else { - handle_park_load_failure(result, path); + handle_park_load_failure_with_title_opt(result, path, true); ParkLoadResult_Delete(result); return false; } @@ -353,15 +360,29 @@ bool rct2_open_file(const char *path) // TODO track design install return true; } else if (_stricmp(extension, "sv4") == 0) { - if (rct1_load_saved_game(path)) { + ParkLoadResult * result = rct1_load_saved_game(path); + if (ParkLoadResult_GetError(result) == PARK_LOAD_ERROR_OK) { + ParkLoadResult_Delete(result); game_load_init(); return true; } + else { + handle_park_load_failure_with_title_opt(result, path, true); + ParkLoadResult_Delete(result); + return false; + } } else if (_stricmp(extension, "sc4") == 0) { - if (rct1_load_scenario(path)) { + ParkLoadResult * result = rct1_load_scenario(path); + if (ParkLoadResult_GetError(result) == PARK_LOAD_ERROR_OK) { + ParkLoadResult_Delete(result); scenario_begin(); return true; } + else { + handle_park_load_failure_with_title_opt(result, path, true); + ParkLoadResult_Delete(result); + return false; + } } return false;