diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 8a60bdb4..0017413d 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -480,7 +480,7 @@ void MenuStateCustomGame::update() } // Send the game settings to each client if we have at least one networked client - if( serverInterface->getAllowDownloadDataSynch() == true && + if( serverInterface->getAllowGameDataSynchCheck() == true && haveAtLeastOneNetworkClientConnected == true && needToSetChangedGameSettings == true && difftime(time(NULL),lastSetChangedGameSettings) >= 2) diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index 4c4dfa2c..de61924b 100755 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -180,9 +180,21 @@ void ClientInterface::updateLobby() { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got NetworkMessageSynchNetworkGameData\n",__FILE__,__FUNCTION__); + Config &config = Config::getInstance(); + string scenarioDir = ""; + if(gameSettings.getScenarioDir() != "") { + scenarioDir = gameSettings.getScenarioDir(); + if(EndsWith(scenarioDir, ".xml") == true) { + scenarioDir = scenarioDir.erase(scenarioDir.size() - 4, 4); + scenarioDir = scenarioDir.erase(scenarioDir.size() - gameSettings.getScenario().size(), gameSettings.getScenario().size() + 1); + } + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameSettings.getScenarioDir() = [%s] gameSettings.getScenario() = [%s] scenarioDir = [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameSettings.getScenarioDir().c_str(),gameSettings.getScenario().c_str(),scenarioDir.c_str()); + } + // check the checksum's - int32 tilesetCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_tilesets) + "/" + - networkMessageSynchNetworkGameData.getTileset() + "/*", ".xml", NULL); + //int32 tilesetCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_tilesets) + "/" + networkMessageSynchNetworkGameData.getTileset() + "/*", ".xml", NULL); + int32 tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,scenarioDir), string("/") + networkMessageSynchNetworkGameData.getTileset() + string("/*"), ".xml", NULL); this->setNetworkGameDataSynchCheckOkTile((tilesetCRC == networkMessageSynchNetworkGameData.getTilesetCRC())); if(this->getNetworkGameDataSynchCheckOkTile() == false) @@ -193,8 +205,8 @@ void ClientInterface::updateLobby() //tech, load before map because of resources - int32 techCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_techs) + "/" + - networkMessageSynchNetworkGameData.getTech() + "/*", ".xml", NULL); + //int32 techCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_techs) + "/" + networkMessageSynchNetworkGameData.getTech() + "/*", ".xml", NULL); + int32 techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,scenarioDir), string("/") + networkMessageSynchNetworkGameData.getTech() + string("/*"), ".xml", NULL); this->setNetworkGameDataSynchCheckOkTech((techCRC == networkMessageSynchNetworkGameData.getTechCRC())); @@ -206,7 +218,7 @@ void ClientInterface::updateLobby() //map Checksum checksum; - string file = Map::getMapPath(networkMessageSynchNetworkGameData.getMap()); + string file = Map::getMapPath(networkMessageSynchNetworkGameData.getMap(),scenarioDir); checksum.addFile(file); int32 mapCRC = checksum.getSum(); //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] file = [%s] checksum = %d\n",__FILE__,__FUNCTION__,file.c_str(),mapCRC); diff --git a/source/glest_game/network/network_message.cpp b/source/glest_game/network/network_message.cpp index 8c0953ca..5e2e6a62 100644 --- a/source/glest_game/network/network_message.cpp +++ b/source/glest_game/network/network_message.cpp @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Martiņo Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -334,15 +334,29 @@ NetworkMessageSynchNetworkGameData::NetworkMessageSynchNetworkGameData(const Gam data.tileset = gameSettings->getTileset(); data.tech = gameSettings->getTech(); + Config &config = Config::getInstance(); + string scenarioDir = ""; + if(gameSettings->getScenarioDir() != "") { + scenarioDir = gameSettings->getScenarioDir(); + if(EndsWith(scenarioDir, ".xml") == true) { + scenarioDir = scenarioDir.erase(scenarioDir.size() - 4, 4); + scenarioDir = scenarioDir.erase(scenarioDir.size() - gameSettings->getScenario().size(), gameSettings->getScenario().size() + 1); + } + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameSettings.getScenarioDir() = [%s] gameSettings.getScenario() = [%s] scenarioDir = [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameSettings->getScenarioDir().c_str(),gameSettings->getScenario().c_str(),scenarioDir.c_str()); + } + //Checksum checksum; - data.tilesetCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_tilesets) + "/" + gameSettings->getTileset() + "/*", "xml", NULL); + //data.tilesetCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_tilesets) + "/" + gameSettings->getTileset() + "/*", "xml", NULL); + data.tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,scenarioDir), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL); //tech, load before map because of resources - data.techCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_techs) + "/" + gameSettings->getTech() + "/*", "xml", NULL); + //data.techCRC = getFolderTreeContentsCheckSumRecursively(string(GameConstants::folder_path_techs) + "/" + gameSettings->getTech() + "/*", "xml", NULL); + data.techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,scenarioDir), string("/") + gameSettings->getTech() + string("/*"), ".xml", NULL); //map Checksum checksum; - string file = Map::getMapPath(gameSettings->getMap()); + string file = Map::getMapPath(gameSettings->getMap(),scenarioDir); checksum.addFile(file); data.mapCRC = checksum.getSum(); //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] file = [%s] checksum = %d\n",__FILE__,__FUNCTION__,file.c_str(),data.mapCRC); diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index f7a8c20e..9f866b96 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -2,7 +2,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Martiņo Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -635,7 +635,7 @@ string Map::getMapPath(const string &mapName, string scenarioDir) { } } - throw runtime_error("Map " + mapName + " not found."); + throw runtime_error("Map [" + mapName + "] not found, scenarioDir [" + scenarioDir + "]"); } // ===================================================== diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index ca3d9563..f9788bac 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -1190,7 +1190,7 @@ void BroadCastSocketThread::execute() { for( pn = 1; ; pn++ ) { if(difftime(time(NULL),elapsed) >= 1) { - time_t elapsed = time(NULL); + elapsed = time(NULL); // Broadcast the packet to the subnet if( sendto( bcfd, buff, sizeof(buff) + 1, 0 , (struct sockaddr *)&bcaddr, sizeof(struct sockaddr_in) ) != sizeof(buff) + 1 ) { diff --git a/source/shared_lib/sources/platform/sdl/platform_util.cpp b/source/shared_lib/sources/platform/sdl/platform_util.cpp index cf174920..55d11c3a 100644 --- a/source/shared_lib/sources/platform/sdl/platform_util.cpp +++ b/source/shared_lib/sources/platform/sdl/platform_util.cpp @@ -269,12 +269,25 @@ bool EndsWith(const string &str, const string& key) //finds all filenames like path and gets their checksum of all files combined int32 getFolderTreeContentsCheckSumRecursively(vector paths, string pathSearchString, const string filterFileExt, Checksum *recursiveChecksum) { + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum); int count = paths.size(); for(int idx = 0; idx < count; ++idx) { string path = paths[idx] + pathSearchString; - getFolderTreeContentsCheckSumRecursively(path, filterFileExt, recursiveChecksum); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s], filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str()); + + getFolderTreeContentsCheckSumRecursively(path, filterFileExt, &checksum); } + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning: %d\n",__FILE__,__FUNCTION__,__LINE__,checksum.getSum()); + + if(recursiveChecksum != NULL) { + *recursiveChecksum = checksum; + } + return checksum.getSum(); } @@ -283,7 +296,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum); - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] starting checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum()); std::string mypath = path; /** Stupid win32 is searching for all files without extension when *. is @@ -314,6 +327,8 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string } */ + //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] examining file [%s]\n",__FILE__,__FUNCTION__,p); + if(isdir(p) == false) { bool addFile = true; @@ -324,7 +339,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string if(addFile) { - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p); checksum.addFile(p); } @@ -357,16 +372,27 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string globfree(&globbuf); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum()); + + if(recursiveChecksum != NULL) { + *recursiveChecksum = checksum; + } + return checksum.getSum(); } vector > getFolderTreeContentsCheckSumListRecursively(vector paths, string pathSearchString, string filterFileExt, vector > *recursiveMap) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + vector > checksumFiles = (recursiveMap == NULL ? vector >() : *recursiveMap); int count = paths.size(); for(int idx = 0; idx < count; ++idx) { string path = paths[idx] + pathSearchString; getFolderTreeContentsCheckSumListRecursively(path, filterFileExt, &checksumFiles); } + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + return checksumFiles; } @@ -375,7 +401,7 @@ vector > getFolderTreeContentsCheckSumListRecursively(co vector > checksumFiles = (recursiveMap == NULL ? vector >() : *recursiveMap); - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str()); std::string mypath = path; /** Stupid win32 is searching for all files without extension when *. is @@ -452,6 +478,8 @@ vector > getFolderTreeContentsCheckSumListRecursively(co globfree(&globbuf); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str()); + return checksumFiles; } diff --git a/source/shared_lib/sources/platform/win32/platform_util.cpp b/source/shared_lib/sources/platform/win32/platform_util.cpp index f40b06ae..5bc4e483 100644 --- a/source/shared_lib/sources/platform/win32/platform_util.cpp +++ b/source/shared_lib/sources/platform/win32/platform_util.cpp @@ -327,8 +327,13 @@ int32 getFolderTreeContentsCheckSumRecursively(vector paths, string path int count = paths.size(); for(int idx = 0; idx < count; ++idx) { string path = paths[idx] + pathSearchString; - getFolderTreeContentsCheckSumRecursively(path, filterFileExt, recursiveChecksum); - } + getFolderTreeContentsCheckSumRecursively(path, filterFileExt, &checksum); + } + + if(recursiveChecksum != NULL) { + *recursiveChecksum = checksum; + } + return checksum.getSum(); } @@ -410,6 +415,11 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string globfree(&globbuf); */ + + if(recursiveChecksum != NULL) { + *recursiveChecksum = checksum; + } + return checksum.getSum(); } diff --git a/source/shared_lib/sources/platform/win32/socket.cpp b/source/shared_lib/sources/platform/win32/socket.cpp index ba7b010a..c940b275 100644 --- a/source/shared_lib/sources/platform/win32/socket.cpp +++ b/source/shared_lib/sources/platform/win32/socket.cpp @@ -1282,7 +1282,7 @@ void BroadCastSocketThread::execute() { for( pn = 1; ; pn++ ) { if(difftime(time(NULL),elapsed) >= 1) { - time_t elapsed = time(NULL); + elapsed = time(NULL); // Broadcast the packet to the subnet if( sendto( bcfd, buff, sizeof(buff) + 1, 0 , (struct sockaddr *)&bcaddr, sizeof(struct sockaddr_in) ) != sizeof(buff) + 1 ) {