From bf986e43c6c947ca45c782de4cf2aabd87b58464 Mon Sep 17 00:00:00 2001 From: Henry Cheng <39224097+jazzysoggy@users.noreply.github.com> Date: Fri, 6 Jan 2023 06:05:04 -0500 Subject: [PATCH] Fix #18970: Trying to load a non-park save will now display context error (#19007) Fix https://github.com/OpenRCT2/OpenRCT2/issues/18970 --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/LoadSave.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 79eebbb6ee..eee751d6be 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -7,6 +7,7 @@ - Improved: [#18749] Ability to have 4 active awards for more than one month in a row. - Improved: [#18826] [Plugin] Added all actions and their documentation to plugin API. - Improved: [#18945] Languages can now fall back to other languages than English. +- Improved: [#18970] Trying to load a non-park save will now display a context error. - Fix: [#18467] “Selected only” Object Selection filter is active in Track Designs Manager, and cannot be toggled. - Fix: [#18905] Ride Construction window theme is not applied correctly. - Fix: [#18911] Mini Golf station does not draw correctly from all angles. diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index a051017358..cc9bfaa744 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -269,9 +269,18 @@ static void Select(const char* path) { case (LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME): SetAndSaveConfigPath(gConfigGeneral.LastSaveGameDirectory, pathBuffer); - InvokeCallback(MODAL_RESULT_OK, pathBuffer); - window_close_by_class(WindowClass::Loadsave); - gfx_invalidate_screen(); + if (OpenRCT2::GetContext()->LoadParkFromFile(pathBuffer)) + { + InvokeCallback(MODAL_RESULT_OK, pathBuffer); + window_close_by_class(WindowClass::Loadsave); + gfx_invalidate_screen(); + } + else + { + // Not the best message... + ContextShowError(STR_LOAD_GAME, STR_FAILED_TO_LOAD_FILE_CONTAINS_INVALID_DATA, {}); + InvokeCallback(MODAL_RESULT_FAIL, pathBuffer); + } break; case (LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME):