- implement ability to toggle off verbose and normal network crc mode via ini entries:

EnableNetworkGameSynchChecks
EnableNetworkGameSynchMonitor
This commit is contained in:
Mark Vejvoda 2013-09-24 19:35:35 +00:00
parent c9b3284aeb
commit 11471243ea
4 changed files with 63 additions and 31 deletions

View File

@ -1571,6 +1571,13 @@ void Game::init(bool initForPreviewOnly) {
printf("New game has started...\n"); printf("New game has started...\n");
} }
if(isFlagType1BitEnabled(gameSettings.getFlagTypes1(),ft1_network_synch_checks_verbose) == true) {
printf("*Note: Monitoring Network CRC VERBOSE synchronization...\n");
}
else if(isFlagType1BitEnabled(gameSettings.getFlagTypes1(),ft1_network_synch_checks) == true) {
printf("*Note: Monitoring Network CRC NORMAL synchronization...\n");
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== START GAME ==== getCurrentPixelByteCount() = %llu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(long long unsigned int)renderer.getCurrentPixelByteCount()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== START GAME ==== getCurrentPixelByteCount() = %llu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(long long unsigned int)renderer.getCurrentPixelByteCount());
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled) SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"=============================================\n"); if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled) SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"=============================================\n");
@ -1702,20 +1709,19 @@ void Game::processNetworkSynchChecksIfRequired() {
Faction *faction = world.getFaction(index); Faction *faction = world.getFaction(index);
netIntf->setNetworkPlayerFactionCRC(index,faction->getCRC().getSum()); netIntf->setNetworkPlayerFactionCRC(index,faction->getCRC().getSum());
if(settings != NULL && (settings->getFlagTypes1() & ft1_network_synch_checks) == ft1_network_synch_checks) { if(settings != NULL) {
faction->addCRC_DetailsForWorldFrame(world.getFrameCount(),role == nrServer); if(isFlagType1BitEnabled(settings->getFlagTypes1(),ft1_network_synch_checks_verbose) == true) {
} faction->addCRC_DetailsForWorldFrame(world.getFrameCount(),role == nrServer);
else if(world.getFrameCount() % 20 == 0) { }
faction->addCRC_DetailsForWorldFrame(world.getFrameCount(),role == nrServer); else if(isFlagType1BitEnabled(settings->getFlagTypes1(),ft1_network_synch_checks) == true &&
world.getFrameCount() % 20 == 0) {
faction->addCRC_DetailsForWorldFrame(world.getFrameCount(),role == nrServer);
}
} }
} }
else { else {
netIntf->setNetworkPlayerFactionCRC(index,0); netIntf->setNetworkPlayerFactionCRC(index,0);
} }
//if(world.getFrameCount() % 40 == 0) {
// printf("Frame #: %d Faction: %d CRC: %u\n",world.getFrameCount(),index,netIntf->getNetworkPlayerFactionCRC(index));
//}
} }
} }
} }
@ -2985,7 +2991,9 @@ void Game::ReplaceDisconnectedNetworkPlayersWithAI(bool isNetworkGame, NetworkRo
if(aiInterfaces[i] == NULL && if(aiInterfaces[i] == NULL &&
server->isClientConnected(faction->getStartLocationIndex()) == false) { server->isClientConnected(faction->getStartLocationIndex()) == false) {
DumpCRCWorldLogIfRequired("_faction_" + intToStr(i)); if(faction->getPersonalityType() != fpt_Observer) {
DumpCRCWorldLogIfRequired("_faction_" + intToStr(i));
}
faction->setFactionDisconnectHandled(true); faction->setFactionDisconnectHandled(true);
@ -4919,7 +4927,9 @@ void Game::DumpCRCWorldLogIfRequired(string fileSuffix) {
printf("Check save world CRC to log. isNetworkGame = %d fileSuffix = %s\n",isNetworkGame,fileSuffix.c_str()); printf("Check save world CRC to log. isNetworkGame = %d fileSuffix = %s\n",isNetworkGame,fileSuffix.c_str());
GameSettings *settings = world.getGameSettingsPtr(); GameSettings *settings = world.getGameSettingsPtr();
//if(settings != NULL && (settings->getFlagTypes1() & ft1_network_synch_checks) == ft1_network_synch_checks) { if(settings != NULL &&
(isFlagType1BitEnabled(settings->getFlagTypes1(),ft1_network_synch_checks_verbose) == true ||
isFlagType1BitEnabled(settings->getFlagTypes1(),ft1_network_synch_checks) == true)) {
string debugCRCWorldLogFile = Config::getInstance().getString("DebugCRCWorldLogFile","debugCRCWorld.log"); string debugCRCWorldLogFile = Config::getInstance().getString("DebugCRCWorldLogFile","debugCRCWorld.log");
debugCRCWorldLogFile += fileSuffix; debugCRCWorldLogFile += fileSuffix;
@ -4936,13 +4946,13 @@ void Game::DumpCRCWorldLogIfRequired(string fileSuffix) {
printf("Save to log debugCRCWorldLogFile = %s\n",debugCRCWorldLogFile.c_str()); printf("Save to log debugCRCWorldLogFile = %s\n",debugCRCWorldLogFile.c_str());
#if defined(WIN32) && !defined(__MINGW32__) #if defined(WIN32) && !defined(__MINGW32__)
FILE *fp = _wfopen(utf8_decode(debugCRCWorldLogFile).c_str(), L"w"); FILE *fp = _wfopen(utf8_decode(debugCRCWorldLogFile).c_str(), L"w");
std::ofstream logFile(fp); std::ofstream logFile(fp);
#else #else
std::ofstream logFile; std::ofstream logFile;
logFile.open(debugCRCWorldLogFile.c_str(), ios_base::out | ios_base::trunc); logFile.open(debugCRCWorldLogFile.c_str(), ios_base::out | ios_base::trunc);
#endif #endif
logFile << "World CRC debug information:" << std::endl; logFile << "World CRC debug information:" << std::endl;
logFile << "============================" << std::endl; logFile << "============================" << std::endl;
logFile << "Maximum framecount: " << world.getFaction(0)->getCRC_DetailsForWorldFrameCount() << std::endl; logFile << "Maximum framecount: " << world.getFaction(0)->getCRC_DetailsForWorldFrameCount() << std::endl;
@ -4961,13 +4971,13 @@ void Game::DumpCRCWorldLogIfRequired(string fileSuffix) {
} }
logFile.close(); logFile.close();
#if defined(WIN32) && !defined(__MINGW32__) #if defined(WIN32) && !defined(__MINGW32__)
if(fp) { if(fp) {
fclose(fp); fclose(fp);
} }
#endif #endif
//} }
} }
} }
@ -4979,14 +4989,6 @@ void Game::exitGameState(Program *program, Stats &endStats) {
//printf("game = %p\n",game); //printf("game = %p\n",game);
if(game) { if(game) {
// NetworkManager &networkManager= NetworkManager::getInstance();
// NetworkRole role = networkManager.getNetworkRole();
// string suffix = "_client";
// if(role == nrServer) {
// suffix = "_server";
// }
// game->DumpCRCWorldLogIfRequired(suffix);
game->setEndGameTeamWinnersAndLosers(); game->setEndGameTeamWinnersAndLosers();
game->endGame(); game->endGame();
} }

View File

@ -61,14 +61,20 @@ public:
// ===================================================== // =====================================================
enum FlagTypes1 { enum FlagTypes1 {
ft1_none = 0x00, ft1_none = 0x00,
ft1_show_map_resources = 0x01, ft1_show_map_resources = 0x01,
ft1_allow_team_switching = 0x02, ft1_allow_team_switching = 0x02,
ft1_allow_in_game_joining = 0x04, ft1_allow_in_game_joining = 0x04,
ft1_network_synch_checks = 0x08 ft1_network_synch_checks_verbose = 0x08,
//ft1_xx = 0x10, ft1_network_synch_checks = 0x10
//ft1_xx = 0x20,
//ft1_xx = 0x40,
}; };
static bool isFlagType1BitEnabled(uint32 flagValue,FlagTypes1 type) {
return ((flagValue & type) == type);
}
enum NetworkPlayerStatusType { enum NetworkPlayerStatusType {
npst_None = 0, npst_None = 0,
npst_PickSettings = 1, npst_PickSettings = 1,

View File

@ -1070,6 +1070,18 @@ bool CoreData::loadGameSettingsFromFile(std::string fileName, GameSettings *game
if(Config::getInstance().getBool("EnableNetworkGameSynchChecks","false") == true) { if(Config::getInstance().getBool("EnableNetworkGameSynchChecks","false") == true) {
//printf("*WARNING* - EnableNetworkGameSynchChecks is enabled\n"); //printf("*WARNING* - EnableNetworkGameSynchChecks is enabled\n");
valueFlags1 |= ft1_network_synch_checks_verbose;
gameSettings->setFlagTypes1(valueFlags1);
}
else {
valueFlags1 &= ~ft1_network_synch_checks_verbose;
gameSettings->setFlagTypes1(valueFlags1);
}
if(Config::getInstance().getBool("EnableNetworkGameSynchMonitor","true") == true) {
//printf("*WARNING* - EnableNetworkGameSynchChecks is enabled\n");
valueFlags1 |= ft1_network_synch_checks; valueFlags1 |= ft1_network_synch_checks;
gameSettings->setFlagTypes1(valueFlags1); gameSettings->setFlagTypes1(valueFlags1);

View File

@ -3185,6 +3185,18 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
if(Config::getInstance().getBool("EnableNetworkGameSynchChecks","false") == true) { if(Config::getInstance().getBool("EnableNetworkGameSynchChecks","false") == true) {
//printf("*WARNING* - EnableNetworkGameSynchChecks is enabled\n"); //printf("*WARNING* - EnableNetworkGameSynchChecks is enabled\n");
valueFlags1 |= ft1_network_synch_checks_verbose;
gameSettings->setFlagTypes1(valueFlags1);
}
else {
valueFlags1 &= ~ft1_network_synch_checks_verbose;
gameSettings->setFlagTypes1(valueFlags1);
}
if(Config::getInstance().getBool("EnableNetworkGameSynchMonitor","true") == true) {
//printf("*WARNING* - EnableNetworkGameSynchChecks is enabled\n");
valueFlags1 |= ft1_network_synch_checks; valueFlags1 |= ft1_network_synch_checks;
gameSettings->setFlagTypes1(valueFlags1); gameSettings->setFlagTypes1(valueFlags1);