Some bug fixes related to file transfer code and user folders
This commit is contained in:
parent
e56ce605db
commit
a0c0be4d65
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 + "]");
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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<string> 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<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(vector<string> paths, string pathSearchString, string filterFileExt, vector<std::pair<string,int32> > *recursiveMap) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *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<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(co
|
|||
|
||||
vector<std::pair<string,int32> > checksumFiles = (recursiveMap == NULL ? vector<std::pair<string,int32> >() : *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<std::pair<string,int32> > getFolderTreeContentsCheckSumListRecursively(co
|
|||
|
||||
globfree(&globbuf);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s]\n",__FILE__,__FUNCTION__,path.c_str());
|
||||
|
||||
return checksumFiles;
|
||||
}
|
||||
|
||||
|
|
|
@ -327,8 +327,13 @@ int32 getFolderTreeContentsCheckSumRecursively(vector<string> 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue