From 3d8ec4e39362b75dd6f341e2da55e62db488567c Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Mon, 30 Oct 2017 16:11:45 +0100 Subject: [PATCH] Warn when loading incompatible RCTC saves --- data/language/en-GB.txt | 1 + src/openrct2/ParkImporter.cpp | 22 ++++++++++++++++++++-- src/openrct2/ParkImporter.h | 5 +++++ src/openrct2/game.c | 16 +++++++++++++++- src/openrct2/localisation/string_ids.h | 2 ++ src/openrct2/rct2/S6Importer.cpp | 5 +++++ 6 files changed, 48 insertions(+), 3 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 50ed16dc73..356c75827e 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -4466,6 +4466,7 @@ STR_6154 :It is not recommended to run OpenRCT2 with elevated permissions. STR_6155 :Neither KDialog nor Zenity are installed. Please install one, or configure from the command line. STR_6156 :Name is reserved STR_6157 :Console +STR_6158 :Failed to load this file...{NEWLINE}Incompatible RCTC version: {COMMA16} ############# # Scenarios # diff --git a/src/openrct2/ParkImporter.cpp b/src/openrct2/ParkImporter.cpp index 3fe174a906..13b3b8d62f 100644 --- a/src/openrct2/ParkImporter.cpp +++ b/src/openrct2/ParkImporter.cpp @@ -22,13 +22,21 @@ #include "ParkImporter.h" ParkLoadResult::ParkLoadResult(PARK_LOAD_ERROR error) - : Error(error) + : Error(error), + Flag(0) { } ParkLoadResult::ParkLoadResult(PARK_LOAD_ERROR error, const std::vector &missingObjects) : Error(error), - MissingObjects(missingObjects) + MissingObjects(missingObjects), + Flag(0) +{ +} + +ParkLoadResult::ParkLoadResult(PARK_LOAD_ERROR error, const uint8 flag) + : Error(error), + Flag(flag) { } @@ -52,6 +60,11 @@ ParkLoadResult ParkLoadResult::CreateUnknown() return ParkLoadResult(PARK_LOAD_ERROR::PARK_LOAD_ERROR_UNKNOWN); } +ParkLoadResult ParkLoadResult::CreateUnsupportedRCTCflag(uint8 classic_flag) +{ + return ParkLoadResult(PARK_LOAD_ERROR::PARK_LOAD_ERROR_UNSUPPORTED_RCTC_FLAG, classic_flag); +} + extern "C" { PARK_LOAD_ERROR ParkLoadResult_GetError(const ParkLoadResult * t) @@ -64,6 +77,11 @@ extern "C" return t->MissingObjects.size(); } + uint8 ParkLoadResult_GetFlag(const ParkLoadResult * t) + { + return t->Flag; + } + const rct_object_entry * ParkLoadResult_GetMissingObjects(const ParkLoadResult * t) { return t->MissingObjects.data(); diff --git a/src/openrct2/ParkImporter.h b/src/openrct2/ParkImporter.h index f112e8246f..c8ef39ccda 100644 --- a/src/openrct2/ParkImporter.h +++ b/src/openrct2/ParkImporter.h @@ -25,6 +25,7 @@ typedef enum PARK_LOAD_ERROR PARK_LOAD_ERROR_OK, PARK_LOAD_ERROR_MISSING_OBJECTS, PARK_LOAD_ERROR_INVALID_EXTENSION, + PARK_LOAD_ERROR_UNSUPPORTED_RCTC_FLAG, PARK_LOAD_ERROR_UNKNOWN = 255 } PARK_LOAD_ERROR; @@ -44,15 +45,18 @@ struct ParkLoadResult final public: const PARK_LOAD_ERROR Error; const std::vector MissingObjects; + const uint8 Flag; static ParkLoadResult CreateOK(); static ParkLoadResult CreateInvalidExtension(); static ParkLoadResult CreateMissingObjects(const std::vector &missingObjects); static ParkLoadResult CreateUnknown(); + static ParkLoadResult CreateUnsupportedRCTCflag(uint8 classic_flag); private: ParkLoadResult(PARK_LOAD_ERROR error); ParkLoadResult(PARK_LOAD_ERROR error, const std::vector &missingObjects); + ParkLoadResult(PARK_LOAD_ERROR error, const uint8 flag); }; /** @@ -101,6 +105,7 @@ extern "C" PARK_LOAD_ERROR ParkLoadResult_GetError(const ParkLoadResult * t); size_t ParkLoadResult_GetMissingObjectsCount(const ParkLoadResult * t); const rct_object_entry * ParkLoadResult_GetMissingObjects(const ParkLoadResult * t); + uint8 ParkLoadResult_GetFlag(const ParkLoadResult * t); void ParkLoadResult_Delete(ParkLoadResult * t); ParkLoadResult * ParkLoadResult_CreateInvalidExtension(); #ifdef __cplusplus diff --git a/src/openrct2/game.c b/src/openrct2/game.c index 1617412e16..acd8d68f7b 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -1151,7 +1151,21 @@ void handle_park_load_failure_with_title_opt(const ParkLoadResult * result, cons window_object_load_error_open(strndup(path, strnlen(path, MAX_PATH)), ParkLoadResult_GetMissingObjectsCount(result), ParkLoadResult_GetMissingObjects(result)); - } else if (ParkLoadResult_GetError(result) != PARK_LOAD_ERROR_OK) { + } + else if (ParkLoadResult_GetError(result) == PARK_LOAD_ERROR_UNSUPPORTED_RCTC_FLAG) + { + // 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(); + } + + set_format_arg(0, uint16, ParkLoadResult_GetFlag(result)); + context_show_error(STR_FAILED_TO_LOAD_IMCOMPATIBLE_RCTC_FLAG, STR_NONE); + + } + else if (ParkLoadResult_GetError(result) != PARK_LOAD_ERROR_OK) { // 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(); diff --git a/src/openrct2/localisation/string_ids.h b/src/openrct2/localisation/string_ids.h index 62885b5877..c54af52565 100644 --- a/src/openrct2/localisation/string_ids.h +++ b/src/openrct2/localisation/string_ids.h @@ -3813,6 +3813,8 @@ enum { STR_CONSOLE = 6157, + STR_FAILED_TO_LOAD_IMCOMPATIBLE_RCTC_FLAG = 6158, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 }; diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index c370419e0b..56f1cf71cd 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -141,6 +141,11 @@ public: } } + if (_s6.header.classic_flag == 0xf) + { + return ParkLoadResult::CreateUnsupportedRCTCflag(_s6.header.classic_flag); + } + // Read packed objects // TODO try to contain this more and not store objects until later for (uint16 i = 0; i < _s6.header.num_packed_objects; i++)