From cd41aac1f7d02711639c5b840ae23680b2e5cd5f Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sun, 7 Aug 2016 15:31:28 -0400 Subject: [PATCH] allow snapshots to still publish saves, as long as they don't use new features --- src/Config.h | 5 +++++ src/client/Client.cpp | 7 +++++++ src/client/GameSave.cpp | 11 +++++++++++ src/simulation/elements/180.cpp | 2 +- src/simulation/elements/181.cpp | 2 +- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Config.h b/src/Config.h index 917f8afec..7b4d0da42 100644 --- a/src/Config.h +++ b/src/Config.h @@ -33,6 +33,11 @@ #ifndef MOD_ID #define MOD_ID 0 #endif + +#ifdef SNAPSHOT +#define FUTURE_SAVE_VERSION 92 +#define FUTURE_MINOR_VERSION 0 +#endif //VersionInfoEnd //#define IGNORE_UPDATES //uncomment this for mods, to not get any update notifications diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 68d0235f9..4ff983612 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -991,6 +991,13 @@ RequestStatus Client::UploadSave(SaveInfo & save) lastError = "Cannot upload game save"; return RequestFailure; } +#ifdef SNAPSHOT + else if (save.gameSave->fromNewerVersion && save.GetPublished()) + { + lastError = "Cannot publish save"; + return RequestFailure; + } +#endif char *saveName = new char[save.GetName().length() + 1]; std::strcpy (saveName, save.GetName().c_str()); diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index 05b019448..5175efe5b 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -740,7 +740,11 @@ void GameSave::readOPS(char * data, int dataLength) fprintf(stderr, "Wrong type for %s\n", bson_iterator_key(&iter)); } } +#ifdef SNAPSHOT + if (major > FUTURE_SAVE_VERSION || (major == FUTURE_SAVE_VERSION && minor > FUTURE_MINOR_VERSION)) +#else if (major > SAVE_VERSION || (major == SAVE_VERSION && minor > MINOR_VERSION)) +#endif { std::stringstream errorMessage; errorMessage << "Save from a newer version: Requires version " << major << "." << minor; @@ -2123,6 +2127,13 @@ char * GameSave::serialiseOPS(unsigned int & dataLength) { RESTRICTVERSION(91, 5); } +#ifdef SNAPSHOT + if (particles[i].type == PT_E180 || particles[i].type == PT_E181) + { + RESTRICTVERSION(92, 0); + fromNewerVersion = true; + } +#endif //Get the pmap entry for the next particle in the same position i = partsPosLink[i]; diff --git a/src/simulation/elements/180.cpp b/src/simulation/elements/180.cpp index 81a5f3cef..d9a3652a5 100644 --- a/src/simulation/elements/180.cpp +++ b/src/simulation/elements/180.cpp @@ -8,7 +8,7 @@ Element_E180::Element_E180() Colour = PIXPACK(0xCB6351); MenuVisible = 1; MenuSection = SC_SOLIDS; -#ifdef DEBUG +#if defined(DEBUG) || defined(SNAPSHOT) Enabled = 1; #else Enabled = 0; diff --git a/src/simulation/elements/181.cpp b/src/simulation/elements/181.cpp index a6e9532a6..f822031d0 100644 --- a/src/simulation/elements/181.cpp +++ b/src/simulation/elements/181.cpp @@ -7,7 +7,7 @@ Element_E181::Element_E181() Colour = PIXPACK(0xF0F0A0); MenuVisible = 1; MenuSection = SC_POWDERS; -#ifdef DEBUG +#if defined(DEBUG) || defined(SNAPSHOT) Enabled = 1; #else Enabled = 0;