From 1086051e56ff03f3e83fd39b583e0c159f7d64d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Mon, 16 Apr 2012 20:30:35 +0200 Subject: [PATCH] Fixed loading of duplicate games --- game/player_move_cmd.cpp | 2 +- game/xml_reader.cpp | 12 +++++++----- game/xml_reader.h | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/game/player_move_cmd.cpp b/game/player_move_cmd.cpp index 5c831d5..a33fda2 100644 --- a/game/player_move_cmd.cpp +++ b/game/player_move_cmd.cpp @@ -30,7 +30,7 @@ INIT_LOGGER(game, PlayerMoveCmd); PlayerMoveCmd::PlayerMoveCmd(Player &ioPlayer, const Move &iMove, bool iAutoExec) : m_player(ioPlayer), m_move(iMove) { - setAutoExecutable(iAutoExec); + setAutoExecutable(iAutoExec || iMove.getType() == Move::NO_MOVE); } diff --git a/game/xml_reader.cpp b/game/xml_reader.cpp index 1390e38..4d610ff 100644 --- a/game/xml_reader.cpp +++ b/game/xml_reader.cpp @@ -205,6 +205,13 @@ void XmlReader::startElement(const string& namespaceURI, m_attributes[atts.getLocalName(i)] = atts.getValue(i); } } + else if (tag == "Turn") + { + if (m_firstTurn) + m_firstTurn = false; + else + m_game->accessNavigation().newTurn(); + } } @@ -318,11 +325,6 @@ void XmlReader::endElement(const string& namespaceURI, } } - else if (tag == "Turn") - { - m_game->accessNavigation().newTurn(); - } - else if (tag == "GameRack") { // Build a rack for the correct player diff --git a/game/xml_reader.h b/game/xml_reader.h index 7c02bd4..5b674f0 100644 --- a/game/xml_reader.h +++ b/game/xml_reader.h @@ -101,6 +101,7 @@ private: const Dictionary &m_dic; Game *m_game; string errorMessage; + bool m_firstTurn; string m_context; string m_data; @@ -111,7 +112,7 @@ private: // Private constructor, because we only want the read() method // to be called externally XmlReader(const Dictionary &iDic) : - m_dic(iDic), m_game(NULL), m_params(iDic) {} + m_dic(iDic), m_game(NULL), m_firstTurn(true), m_params(iDic) {} XmlReader(const XmlReader&); XmlReader& operator=(const XmlReader&);