From 111523f60b0dc65185fcd1762f9cd03eea15d119 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 28 Sep 2013 06:40:26 +0000 Subject: [PATCH] - corrected game shutdown to do quit logic only once --- source/glest_game/game/game.cpp | 29 +++++++++++++++++++---------- source/glest_game/game/game.h | 3 +++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index f2ae12d9..86467c14 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -164,6 +164,7 @@ Game::Game() : ProgramState(NULL) { lastworldFrameCountForReplay = -1; lastNetworkPlayerConnectionCheck = time(NULL); inJoinGameLoading = false; + quitGameCalled = false; for( int i=0;imasterserverMode == true) { + endStats.setIsMasterserverMode(true); + } + return endStats; +} + Stats Game::quitGame() { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(quitGameCalled == true) { + Stats endStats = getEndGameStats(); + return endStats; + } + quitGameCalled = true; + NetworkManager &networkManager= NetworkManager::getInstance(); NetworkRole role = networkManager.getNetworkRole(); string suffix = "_client"; @@ -4891,16 +4909,7 @@ Stats Game::quitGame() { this->saveGame(GameConstants::saveGameFileAutoTestDefault); } - //Stats stats = *(world.getStats()); - Stats endStats; - - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - endStats = *(world.getStats()); - //NetworkManager &networkManager= NetworkManager::getInstance(); - if(this->masterserverMode == true) { - endStats.setIsMasterserverMode(true); - } + Stats endStats = getEndGameStats(); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index 66d548e8..2f7109cb 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -207,6 +207,8 @@ private: bool inJoinGameLoading; bool initialResumeSpeedLoops; + bool quitGameCalled; + public: Game(); Game(Program *program, const GameSettings *gameSettings, bool masterserverMode); @@ -379,6 +381,7 @@ private: bool switchSetupForSlots(ServerInterface *& serverInterface, int startIndex, int endIndex, bool onlyNetworkUnassigned); void processNetworkSynchChecksIfRequired(); + Stats getEndGameStats(); }; }}//end namespace