From 970de758e4d48c2d0ec05fde02daf8427ffb8922 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Thu, 19 Sep 2013 01:35:08 +0000 Subject: [PATCH] - bugfix for network CRC comparison so we don't lose frames --- source/glest_game/game/game.cpp | 55 +++++++++++++++++---------------- source/glest_game/game/game.h | 1 + 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index e89f408a..af0e4f9a 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -1687,6 +1687,33 @@ void Game::setupPopupMenus(bool checkClientAdminOverrideOnly) { } } +void Game::processNetworkSynchChecksIfRequired() { + bool isNetworkGame = this->gameSettings.isNetworkGame(); + if (isNetworkGame + == true&& NetworkManager::getInstance().getGameNetworkInterface() != NULL) {GameSettings *settings = world.getGameSettingsPtr(); + if(settings != NULL && (settings->getFlagTypes1() & ft1_network_synch_checks) == ft1_network_synch_checks) { + NetworkManager &networkManager = NetworkManager::getInstance(); + NetworkRole role = networkManager.getNetworkRole(); + + NetworkInterface *netIntf = networkManager.getGameNetworkInterface(); + for(int index = 0; index < GameConstants::maxPlayers; ++index) { + if(index < world.getFactionCount()) { + Faction *faction = world.getFaction(index); + netIntf->setNetworkPlayerFactionCRC(index,faction->getCRC().getSum()); + faction->addCRC_DetailsForWorldFrame(world.getFrameCount(),role == nrServer); + } + else { + netIntf->setNetworkPlayerFactionCRC(index,0); + } + + //if(world.getFrameCount() % 40 == 0) { + // printf("Frame #: %d Faction: %d CRC: %u\n",world.getFrameCount(),index,netIntf->getNetworkPlayerFactionCRC(index)); + //} + } + } + } +} + //update void Game::update() { try { @@ -1705,31 +1732,6 @@ void Game::update() { perfList.push_back(perfBuf); } - bool isNetworkGame = this->gameSettings.isNetworkGame(); - if(isNetworkGame == true && NetworkManager::getInstance().getGameNetworkInterface() != NULL) { - GameSettings *settings = world.getGameSettingsPtr(); - if(settings != NULL && (settings->getFlagTypes1() & ft1_network_synch_checks) == ft1_network_synch_checks) { - NetworkManager &networkManager = NetworkManager::getInstance(); - NetworkRole role = networkManager.getNetworkRole(); - - NetworkInterface *netIntf = networkManager.getGameNetworkInterface(); - for(int index = 0; index < GameConstants::maxPlayers; ++index) { - if(index < world.getFactionCount()) { - Faction *faction = world.getFaction(index); - netIntf->setNetworkPlayerFactionCRC(index,faction->getCRC().getSum()); - faction->addCRC_DetailsForWorldFrame(world.getFrameCount(),role == nrServer); - } - else { - netIntf->setNetworkPlayerFactionCRC(index,0); - } - - //if(world.getFrameCount() % 40 == 0) { - // printf("Frame #: %d Faction: %d CRC: %u\n",world.getFrameCount(),index,netIntf->getNetworkPlayerFactionCRC(index)); - //} - } - } - } - Chrono chrono; if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start(); @@ -1940,6 +1942,7 @@ void Game::update() { // Check to see if we are playing a network game and if any players // have disconnected? + bool isNetworkGame = this->gameSettings.isNetworkGame(); ReplaceDisconnectedNetworkPlayersWithAI(isNetworkGame, role); setupPopupMenus(true); @@ -1975,7 +1978,7 @@ void Game::update() { //AiInterface if(commander.hasReplayCommandListForFrame() == false) { - + processNetworkSynchChecksIfRequired(); /* for(int j = 0; j < world.getFactionCount(); ++j) { diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index 8191d165..66d548e8 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -378,6 +378,7 @@ private: bool switchSetupForSlots(ServerInterface *& serverInterface, int startIndex, int endIndex, bool onlyNetworkUnassigned); + void processNetworkSynchChecksIfRequired(); }; }}//end namespace