Permalink
Browse files

ugly fix for two empty snapshots being created on startup

  • Loading branch information...
jacob1 committed Feb 10, 2017
1 parent 787939d commit 6040ccd27e1f4af568c2ab335be8b240d48e3761
Showing with 10 additions and 0 deletions.
  1. +6 −0 src/gui/game/GameController.cpp
  2. +1 −0 src/gui/game/GameModel.cpp
  3. +3 −0 src/gui/game/GameModel.h
@@ -144,6 +144,7 @@ GameController::GameController():
gameView->AttachController(this);
gameModel->AddObserver(gameView);
gameModel->SetAllowHistory();
gameView->SetDebugHUD(Client::Ref().GetPrefBool("Renderer.DebugMode", false));
@@ -250,6 +251,11 @@ 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<Snapshot*> history = gameModel->GetHistory();
unsigned int historyPosition = gameModel->GetHistoryPosition();
Snapshot * newSnap = gameModel->GetSimulation()->CreateSnapshot();
@@ -28,6 +28,7 @@ GameModel::GameModel():
currentFile(NULL),
currentUser(0, ""),
toolStrength(1.0f),
allowHistory(false),
redoHistory(NULL),
historyPosition(0),
activeColourPreset(0),
@@ -64,6 +64,7 @@ class GameModel
Tool * regularToolset[4];
User currentUser;
float toolStrength;
bool allowHistory;
std::deque<Snapshot*> history;
Snapshot *redoHistory;
unsigned int historyPosition;
@@ -131,6 +132,8 @@ class GameModel
void BuildFavoritesMenu();
void BuildQuickOptionMenu(GameController * controller);
bool GetAllowHistory() { return allowHistory; }
void SetAllowHistory() { allowHistory = true; }
std::deque<Snapshot*> GetHistory();
unsigned int GetHistoryPosition();
void SetHistory(std::deque<Snapshot*> newHistory);

0 comments on commit 6040ccd

Please sign in to comment.