diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 4db4afc9e..d0d3b6db7 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -51,6 +51,7 @@ public: { try { + cc->HistorySnapshot(); cc->gameModel->SetSave(cc->search->GetLoadedSave()); cc->search->ReleaseLoadedSave(); } @@ -73,6 +74,7 @@ public: { try { + cc->HistorySnapshot(); cc->LoadSave(cc->activePreview->GetSaveInfo()); } catch(GameModelException & ex) @@ -144,7 +146,6 @@ GameController::GameController(): gameView->AttachController(this); gameModel->AddObserver(gameView); - gameModel->SetAllowHistory(); gameView->SetDebugHUD(Client::Ref().GetPrefBool("Renderer.DebugMode", false)); @@ -253,11 +254,6 @@ void GameController::HistoryRestore() void GameController::HistorySnapshot() { - // callbacks during initialization create two empty snapshots on startup - // Prevent that from happening here - if (!gameModel->GetAllowHistory()) - return; - std::deque history = gameModel->GetHistory(); unsigned int historyPosition = gameModel->GetHistoryPosition(); Snapshot * newSnap = gameModel->GetSimulation()->CreateSnapshot(); @@ -288,6 +284,8 @@ void GameController::HistorySnapshot() void GameController::HistoryForward() { std::deque history = gameModel->GetHistory(); + if (!history.size()) + return; unsigned int historyPosition = gameModel->GetHistoryPosition(); unsigned int newHistoryPosition = std::min((size_t)historyPosition+1, history.size()); Snapshot *snap; @@ -1252,6 +1250,7 @@ void GameController::OpenLocalBrowse() virtual ~LocalSaveOpenCallback() {}; virtual void FileSelected(SaveFile* file) { + c->HistorySnapshot(); c->LoadSaveFile(file); delete file; } @@ -1488,6 +1487,7 @@ void GameController::ChangeBrush() void GameController::ClearSim() { + HistorySnapshot(); gameModel->SetSave(NULL); gameModel->ClearSimulation(); } @@ -1496,10 +1496,12 @@ void GameController::ReloadSim() { if(gameModel->GetSave() && gameModel->GetSave()->GetGameSave()) { + HistorySnapshot(); gameModel->SetSave(gameModel->GetSave()); } else if(gameModel->GetSaveFile() && gameModel->GetSaveFile()->GetGameSave()) { + HistorySnapshot(); gameModel->SetSaveFile(gameModel->GetSaveFile()); } } diff --git a/src/gui/game/GameModel.cpp b/src/gui/game/GameModel.cpp index 81afa971f..dc67f0b35 100644 --- a/src/gui/game/GameModel.cpp +++ b/src/gui/game/GameModel.cpp @@ -28,7 +28,6 @@ GameModel::GameModel(): currentFile(NULL), currentUser(0, ""), toolStrength(1.0f), - allowHistory(false), redoHistory(NULL), historyPosition(0), activeColourPreset(0), diff --git a/src/gui/game/GameModel.h b/src/gui/game/GameModel.h index cb1eca237..3727d8172 100644 --- a/src/gui/game/GameModel.h +++ b/src/gui/game/GameModel.h @@ -64,7 +64,6 @@ private: Tool * regularToolset[4]; User currentUser; float toolStrength; - bool allowHistory; std::deque history; Snapshot *redoHistory; unsigned int historyPosition; @@ -132,8 +131,6 @@ public: void BuildFavoritesMenu(); void BuildQuickOptionMenu(GameController * controller); - bool GetAllowHistory() { return allowHistory; } - void SetAllowHistory() { allowHistory = true; } std::deque GetHistory(); unsigned int GetHistoryPosition(); void SetHistory(std::deque newHistory); diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 9a1872130..c1a8eb6e1 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -1035,7 +1035,6 @@ void GameView::NotifySaveChanged(GameModel * sender) } saveSimulationButton->Enabled = (saveSimulationButtonEnabled || ctrlBehaviour); SetSaveButtonTooltips(); - c->HistorySnapshot(); } void GameView::NotifyBrushChanged(GameModel * sender)