Skip to content

Commit

Permalink
ugly fix for two empty snapshots being created on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Feb 10, 2017
1 parent 787939d commit 6040ccd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/gui/game/GameController.cpp
Expand Up @@ -144,6 +144,7 @@ GameController::GameController():

gameView->AttachController(this);
gameModel->AddObserver(gameView);
gameModel->SetAllowHistory();

gameView->SetDebugHUD(Client::Ref().GetPrefBool("Renderer.DebugMode", false));

Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/gui/game/GameModel.cpp
Expand Up @@ -28,6 +28,7 @@ GameModel::GameModel():
currentFile(NULL),
currentUser(0, ""),
toolStrength(1.0f),
allowHistory(false),
redoHistory(NULL),
historyPosition(0),
activeColourPreset(0),
Expand Down
3 changes: 3 additions & 0 deletions src/gui/game/GameModel.h
Expand Up @@ -64,6 +64,7 @@ class GameModel
Tool * regularToolset[4];
User currentUser;
float toolStrength;
bool allowHistory;
std::deque<Snapshot*> history;
Snapshot *redoHistory;
unsigned int historyPosition;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6040ccd

Please sign in to comment.