From a3c2a0d677c9fd595272a4cdba45af80aad35349 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 30 Nov 2020 13:45:06 -0500 Subject: [PATCH] Changes to "fromNewerVersion" code Standardizes the code to run on all mods and betas, not just snapshots and debug builds Ensures mods and betas can load their own saves Blocks publishing saves from all non-release versions if they use features not present in the previous release (currently only GoL elements) --- src/Config.h | 2 +- src/client/Client.cpp | 6 +++--- src/client/GameSave.cpp | 10 ++++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Config.h b/src/Config.h index 3f199a836..08dc241bd 100644 --- a/src/Config.h +++ b/src/Config.h @@ -34,7 +34,7 @@ #define MOD_ID 0 #endif -#if defined(SNAPSHOT) || defined(DEBUG) +#if defined(SNAPSHOT) || defined(BETA) || defined(DEBUG) || MOD_ID > 0 #define FUTURE_SAVE_VERSION 96 #define FUTURE_MINOR_VERSION 0 #endif diff --git a/src/client/Client.cpp b/src/client/Client.cpp index d0a806108..d546d7586 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -975,10 +975,10 @@ RequestStatus Client::UploadSave(SaveInfo & save) lastError = "Cannot serialize game save"; return RequestFailure; } -#if defined(SNAPSHOT) || defined(BETA) || defined(DEBUG) - else if (save.gameSave->fromNewerVersion) +#if defined(SNAPSHOT) || defined(BETA) || defined(DEBUG) || MOD_ID > 0 + else if (save.gameSave->fromNewerVersion && save.GetPublished()) { - lastError = "Cannot upload save, incompatible with latest release version"; + lastError = "Cannot publish save, incompatible with latest release version."; return RequestFailure; } #endif diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index c6a0ca1f6..46fce50e0 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -819,7 +819,7 @@ void GameSave::readOPS(char * data, int dataLength) minor = bson_iterator_int(&subiter); } } -#if defined(SNAPSHOT) || defined(DEBUG) +#if defined(SNAPSHOT) || defined(BETA) || defined(DEBUG) || MOD_ID > 0 if (major > FUTURE_SAVE_VERSION || (major == FUTURE_SAVE_VERSION && minor > FUTURE_MINOR_VERSION)) #else if (major > SAVE_VERSION || (major == SAVE_VERSION && minor > MINOR_VERSION)) @@ -828,7 +828,7 @@ void GameSave::readOPS(char * data, int dataLength) String errorMessage = String::Build("Save from a newer version: Requires version ", major, ".", minor); throw ParseException(ParseException::WrongVersion, errorMessage); } -#if defined(SNAPSHOT) || defined(DEBUG) +#if defined(SNAPSHOT) || defined(BETA) || defined(DEBUG) || MOD_ID > 0 else if (major > SAVE_VERSION || (major == SAVE_VERSION && minor > MINOR_VERSION)) fakeNewerVersion = true; #endif @@ -2498,6 +2498,12 @@ char * GameSave::serialiseOPS(unsigned int & dataLength) } } +#if defined(SNAPSHOT) || defined(BETA) || defined(DEBUG) || MOD_ID > 0 + // Mark save as incompatible with latest release + if (minimumMajorVersion > SAVE_VERSION || (minimumMajorVersion == SAVE_VERSION && minimumMinorVersion > MINOR_VERSION)) + fromNewerVersion = true; +#endif + bson b; b.data = NULL; auto bson_deleter = [](bson * b) { bson_destroy(b); };