Fix stamp and save assignment

This commit is contained in:
Simon Robertshaw 2012-06-18 18:06:40 +01:00
parent 8c608ee8b9
commit f6403958de

View File

@ -280,11 +280,14 @@ SaveInfo * GameModel::GetSave()
void GameModel::SetSave(SaveInfo * newSave) void GameModel::SetSave(SaveInfo * newSave)
{ {
if(currentSave != newSave) if(currentSave != newSave)
delete currentSave; {
if(newSave == NULL) if(currentSave)
currentSave = NULL; delete currentSave;
else if(currentSave != newSave) if(newSave == NULL)
currentSave = new SaveInfo(*newSave); currentSave = NULL;
else
currentSave = new SaveInfo(*newSave);
}
if(currentSave && currentSave->GetGameSave()) if(currentSave && currentSave->GetGameSave())
{ {
@ -453,12 +456,15 @@ void GameModel::ClearSimulation()
void GameModel::SetStamp(GameSave * save) void GameModel::SetStamp(GameSave * save)
{ {
if(stamp) if(stamp != save)
delete stamp; {
if(save) if(stamp)
stamp = new GameSave(*save); delete stamp;
else if(save)
stamp = NULL; stamp = new GameSave(*save);
else
stamp = NULL;
}
} }
void GameModel::SetPlaceSave(GameSave * save) void GameModel::SetPlaceSave(GameSave * save)