"Save from a newer version" is now just a warning (OPS format never changes)
Also, actual save errors now prevent you from clicking "Open" (which allowed you to vote and do other stuff even though the save was never loaded)
This commit is contained in:
parent
9c44fc641c
commit
b184c78cff
@ -51,6 +51,7 @@ originalData(save.originalData)
|
|||||||
blockHeight = save.blockHeight;
|
blockHeight = save.blockHeight;
|
||||||
}
|
}
|
||||||
particlesCount = save.particlesCount;
|
particlesCount = save.particlesCount;
|
||||||
|
fromNewerVersion = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameSave::GameSave(int width, int height)
|
GameSave::GameSave(int width, int height)
|
||||||
@ -63,6 +64,7 @@ GameSave::GameSave(int width, int height)
|
|||||||
fanVelYPtr = NULL;
|
fanVelYPtr = NULL;
|
||||||
particles = NULL;
|
particles = NULL;
|
||||||
|
|
||||||
|
fromNewerVersion = false;
|
||||||
hasOriginalData = false;
|
hasOriginalData = false;
|
||||||
expanded = true;
|
expanded = true;
|
||||||
setSize(width, height);
|
setSize(width, height);
|
||||||
@ -81,6 +83,7 @@ GameSave::GameSave(std::vector<char> data)
|
|||||||
fanVelYPtr = NULL;
|
fanVelYPtr = NULL;
|
||||||
particles = NULL;
|
particles = NULL;
|
||||||
|
|
||||||
|
fromNewerVersion = false;
|
||||||
expanded = false;
|
expanded = false;
|
||||||
hasOriginalData = true;
|
hasOriginalData = true;
|
||||||
originalData = data;
|
originalData = data;
|
||||||
@ -113,6 +116,7 @@ GameSave::GameSave(std::vector<unsigned char> data)
|
|||||||
fanVelYPtr = NULL;
|
fanVelYPtr = NULL;
|
||||||
particles = NULL;
|
particles = NULL;
|
||||||
|
|
||||||
|
fromNewerVersion = false;
|
||||||
expanded = false;
|
expanded = false;
|
||||||
hasOriginalData = true;
|
hasOriginalData = true;
|
||||||
originalData = std::vector<char>(data.begin(), data.end());
|
originalData = std::vector<char>(data.begin(), data.end());
|
||||||
@ -145,6 +149,7 @@ GameSave::GameSave(char * data, int dataSize)
|
|||||||
fanVelYPtr = NULL;
|
fanVelYPtr = NULL;
|
||||||
particles = NULL;
|
particles = NULL;
|
||||||
|
|
||||||
|
fromNewerVersion = false;
|
||||||
expanded = false;
|
expanded = false;
|
||||||
hasOriginalData = true;
|
hasOriginalData = true;
|
||||||
originalData = std::vector<char>(data, data+dataSize);
|
originalData = std::vector<char>(data, data+dataSize);
|
||||||
@ -246,6 +251,8 @@ void GameSave::read(char * data, int dataSize)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cout << "Reading OPS..." << std::endl;
|
std::cout << "Reading OPS..." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
if (data[3] != '1')
|
||||||
|
throw ParseException(ParseException::WrongVersion, "Save format from newer version");
|
||||||
readOPS(data, dataSize);
|
readOPS(data, dataSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -457,7 +464,8 @@ void GameSave::readOPS(char * data, int dataLength)
|
|||||||
|
|
||||||
//From newer version
|
//From newer version
|
||||||
if (savedVersion > SAVE_VERSION)
|
if (savedVersion > SAVE_VERSION)
|
||||||
throw ParseException(ParseException::WrongVersion, "Save from newer version");
|
fromNewerVersion = true;
|
||||||
|
//throw ParseException(ParseException::WrongVersion, "Save from newer version");
|
||||||
|
|
||||||
//Incompatible cell size
|
//Incompatible cell size
|
||||||
if (inputData[5] > CELL)
|
if (inputData[5] > CELL)
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
{
|
{
|
||||||
return message.c_str();
|
return message.c_str();
|
||||||
}
|
}
|
||||||
~ParseException() throw() {};
|
~ParseException() throw() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameSave
|
class GameSave
|
||||||
@ -29,6 +29,7 @@ class GameSave
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
int blockWidth, blockHeight;
|
int blockWidth, blockHeight;
|
||||||
|
bool fromNewerVersion;
|
||||||
|
|
||||||
//Simulation data
|
//Simulation data
|
||||||
//int ** particleMap;
|
//int ** particleMap;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
PreviewModel::PreviewModel():
|
PreviewModel::PreviewModel():
|
||||||
doOpen(false),
|
doOpen(false),
|
||||||
|
canOpen(true),
|
||||||
save(NULL),
|
save(NULL),
|
||||||
saveData(NULL),
|
saveData(NULL),
|
||||||
saveComments(NULL),
|
saveComments(NULL),
|
||||||
@ -92,6 +93,11 @@ bool PreviewModel::GetDoOpen()
|
|||||||
return doOpen;
|
return doOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PreviewModel::GetCanOpen()
|
||||||
|
{
|
||||||
|
return canOpen;
|
||||||
|
}
|
||||||
|
|
||||||
SaveInfo * PreviewModel::GetSave()
|
SaveInfo * PreviewModel::GetSave()
|
||||||
{
|
{
|
||||||
return save;
|
return save;
|
||||||
@ -169,11 +175,15 @@ void PreviewModel::OnResponseReady(void * object, int identifier)
|
|||||||
commentsTotal = save->Comments;
|
commentsTotal = save->Comments;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
save->SetGameSave(new GameSave(*saveData));
|
GameSave *gameSave = new GameSave(*saveData);
|
||||||
|
if (gameSave->fromNewerVersion)
|
||||||
|
new ErrorMessage("This save is from a newer version", "Please update TPT in game or at http://powdertoy.co.uk");
|
||||||
|
save->SetGameSave(gameSave);
|
||||||
}
|
}
|
||||||
catch(ParseException &e)
|
catch(ParseException &e)
|
||||||
{
|
{
|
||||||
new ErrorMessage("Error", e.what());
|
new ErrorMessage("Error", e.what());
|
||||||
|
canOpen = false;
|
||||||
}
|
}
|
||||||
notifySaveChanged();
|
notifySaveChanged();
|
||||||
notifyCommentsPageChanged();
|
notifyCommentsPageChanged();
|
||||||
|
@ -16,6 +16,7 @@ using namespace std;
|
|||||||
class PreviewView;
|
class PreviewView;
|
||||||
class PreviewModel: RequestListener {
|
class PreviewModel: RequestListener {
|
||||||
bool doOpen;
|
bool doOpen;
|
||||||
|
bool canOpen;
|
||||||
vector<PreviewView*> observers;
|
vector<PreviewView*> observers;
|
||||||
SaveInfo * save;
|
SaveInfo * save;
|
||||||
std::vector<unsigned char> * saveData;
|
std::vector<unsigned char> * saveData;
|
||||||
@ -52,6 +53,7 @@ public:
|
|||||||
void UpdateSave(int saveID, int saveDate);
|
void UpdateSave(int saveID, int saveDate);
|
||||||
void SetFavourite(bool favourite);
|
void SetFavourite(bool favourite);
|
||||||
bool GetDoOpen();
|
bool GetDoOpen();
|
||||||
|
bool GetCanOpen();
|
||||||
void SetDoOpen(bool doOpen);
|
void SetDoOpen(bool doOpen);
|
||||||
void Update();
|
void Update();
|
||||||
virtual void OnResponseReady(void * object, int identifier);
|
virtual void OnResponseReady(void * object, int identifier);
|
||||||
|
@ -465,6 +465,8 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
|
|||||||
savePreview->Height *= scaleFactor;
|
savePreview->Height *= scaleFactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (!sender->GetCanOpen())
|
||||||
|
openButton->Enabled = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -474,6 +476,8 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
|
|||||||
authorDateLabel->SetText("");
|
authorDateLabel->SetText("");
|
||||||
saveDescriptionLabel->SetText("");
|
saveDescriptionLabel->SetText("");
|
||||||
favButton->Enabled = false;
|
favButton->Enabled = false;
|
||||||
|
if (!sender->GetCanOpen())
|
||||||
|
openButton->Enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user