From d75295b0272d3ef2fdc91d18aca178d6a4571069 Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 30 Jun 2017 19:03:40 +0100 Subject: [PATCH] Move handle_park_load_failure into game.c --- src/openrct2/game.c | 16 ++++++++++++++++ src/openrct2/game.h | 1 + src/openrct2/util/util.c | 16 ---------------- src/openrct2/util/util.h | 1 - 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/openrct2/game.c b/src/openrct2/game.c index c0d347b520..e180737a03 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -1126,6 +1126,22 @@ bool game_load_save(const utf8 *path) } } +void handle_park_load_failure(park_load_result* result, const utf8* path) +{ + if (result->error == PARK_LOAD_ERROR_BAD_OBJECTS) + { + // 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)), result->object_validity); + } + else if (result->error != PARK_LOAD_ERROR_NONE) { + // If loading the SV6 or SV4 failed for a reason other than invalid objects + // the current park state will be corrupted so just go back to the title screen. + title_load(); + } + SafeFree(result); +} + void game_load_init() { rct_window *mainWindow; diff --git a/src/openrct2/game.h b/src/openrct2/game.h index 2e273160fb..9457e972fc 100644 --- a/src/openrct2/game.h +++ b/src/openrct2/game.h @@ -180,6 +180,7 @@ bool game_is_paused(); bool game_is_not_paused(); void save_game(); void save_game_as(); +void handle_park_load_failure(park_load_result* result, const utf8* path); void rct2_exit(); void rct2_exit_reason(rct_string_id title, rct_string_id body); void game_autosave(); diff --git a/src/openrct2/util/util.c b/src/openrct2/util/util.c index 26844f5e2d..90a7088c8a 100644 --- a/src/openrct2/util/util.c +++ b/src/openrct2/util/util.c @@ -549,19 +549,3 @@ size_t strcatftime(char * buffer, size_t bufferSize, const char * format, const } return 0; } - -void handle_park_load_failure(park_load_result* result, const utf8* path) -{ - if (result->error == PARK_LOAD_ERROR_BAD_OBJECTS) - { - // 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)), result->object_validity); - } - else if (result->error != PARK_LOAD_ERROR_NONE) { - // If loading the SV6 or SV4 failed for a reason other than invalid objects - // the current park state will be corrupted so just go back to the title screen. - title_load(); - } - SafeFree(result); -} \ No newline at end of file diff --git a/src/openrct2/util/util.h b/src/openrct2/util/util.h index 43e0da7261..1ada3c6a5d 100644 --- a/src/openrct2/util/util.h +++ b/src/openrct2/util/util.h @@ -66,5 +66,4 @@ money32 add_clamp_money32(money32 value, money32 value_to_add); size_t strcatftime(char * buffer, size_t bufferSize, const char * format, const struct tm * tp); -void handle_park_load_failure(park_load_result* result, const utf8* path); #endif