From cd4c7ae085f9bc5689ff834e9487673e43b660b0 Mon Sep 17 00:00:00 2001 From: Xawotihs Date: Thu, 13 Oct 2011 20:58:32 +0000 Subject: [PATCH] Fixed a crash on undo on windows, and another one when you tried it before any action was done. Undo is still present in the menu even if there is nothing to undo. --- projects/mtg/src/GameObserver.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 93eb59d12..f041eab9f 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -1288,7 +1288,7 @@ bool GameObserver::load(const string& ss, bool undo) } else { - if(!players[0]) + if(players.size() == 0 || !players[0]) players.push_back(new HumanPlayer(this, deckFile, deckFileSmall)); players[0]->parseLine(s); } @@ -1300,7 +1300,7 @@ bool GameObserver::load(const string& ss, bool undo) } else { - if(!players[1]) { + if(players.size() == 1 || !players[1]) { AIPlayerFactory playerCreator; players.push_back(playerCreator.createAIPlayer(this, MTGCollection(), players[0])); } @@ -1345,7 +1345,7 @@ bool GameObserver::processActions(bool undo) float counter = 0.0f; // To handle undo, we'll remove the last P1 action and all P2 actions after. - if(undo) { + if(undo && copyList.size()) { while(copyList.back().find("p2") != string::npos) copyList.pop_back(); copyList.pop_back();