Skip to content

Commit

Permalink
allow snapshots to still publish saves, as long as they don't use new…
Browse files Browse the repository at this point in the history
… features
  • Loading branch information
jacob1 committed Aug 7, 2016
1 parent b8e2113 commit cd41aac
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Config.h
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/client/Client.cpp
Expand Up @@ -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());
Expand Down
11 changes: 11 additions & 0 deletions src/client/GameSave.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/180.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/181.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit cd41aac

Please sign in to comment.