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)
This commit is contained in:
jacob1 2020-11-30 13:45:06 -05:00
parent a631ef78e9
commit a3c2a0d677
3 changed files with 12 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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); };