diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index a9799d612..83f09b235 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -395,7 +395,7 @@ const CommandType *UnitType::getFirstCtOfClass(CommandClass commandClass) const{ const SkillType *UnitType::getFirstStOfClass(SkillClass skillClass) const{ if(firstSkillTypeOfClass[skillClass] == NULL) { - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] skillClass = %d\n",__FILE__,__FUNCTION__,__LINE__,skillClass); + //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] skillClass = %d\n",__FILE__,__FUNCTION__,__LINE__,skillClass); /* for(int j= 0; j paths, string path //finds all filenames like path and gets their checksum of all files combined int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s] filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str()); // !!! OLD local CACHE //static std::map crcTreeCache; @@ -337,6 +338,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] found CACHED checksum = %d for cacheKey [%s]\n",__FILE__,__FUNCTION__,path.c_str(),crcTreeCache[cacheKey],cacheKey.c_str()); return crcTreeCache[cacheKey]; } + bool topLevelCaller = (recursiveChecksum == NULL); Checksum checksum = (recursiveChecksum == NULL ? Checksum() : *recursiveChecksum); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] starting checksum = %d\n",__FILE__,__FUNCTION__,path.c_str(),checksum.getSum()); @@ -359,34 +361,29 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string throw runtime_error(msg.str()); } + int fileLoopCount = 0; + int fileMatchCount = 0; for(int i = 0; i < globbuf.gl_pathc; ++i) { const char* p = globbuf.gl_pathv[i]; - /* - const char* begin = p; - for( ; *p != 0; ++p) { - // strip the path component - if(*p == '/') - begin = p+1; - } - */ - //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] examining file [%s]\n",__FILE__,__FUNCTION__,p); - if(isdir(p) == false) - { + if(isdir(p) == false) { bool addFile = true; - if(filterFileExt != "") - { + if(EndsWith(p, ".") == true || EndsWith(p, "..") == true || EndsWith(p, ".svn") == true) { + addFile = false; + } + else if(filterFileExt != "") { addFile = EndsWith(p, filterFileExt); } - if(addFile) - { + if(addFile) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p); checksum.addFile(p); + fileMatchCount++; } } + fileLoopCount++; } globfree(&globbuf); @@ -401,15 +398,6 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string for(int i = 0; i < globbuf.gl_pathc; ++i) { const char* p = globbuf.gl_pathv[i]; - /* - const char* begin = p; - for( ; *p != 0; ++p) { - // strip the path component - if(*p == '/') - begin = p+1; - } - */ - getFolderTreeContentsCheckSumRecursively(string(p) + "/*", filterFileExt, &checksum); } @@ -421,11 +409,15 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string *recursiveChecksum = checksum; } - crcTreeCache[cacheKey] = checksum.getFinalFileListSum(); + if(topLevelCaller == true) { + crcTreeCache[cacheKey] = checksum.getFinalFileListSum(); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d for cacheKey [%s] fileMatchCount = %d, fileLoopCount = %d\n",__FILE__,__FUNCTION__,path.c_str(),crcTreeCache[cacheKey],cacheKey.c_str(),fileMatchCount,fileLoopCount); - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d for cacheKey [%s]\n",__FILE__,__FUNCTION__,path.c_str(),crcTreeCache[cacheKey],cacheKey.c_str()); - - return crcTreeCache[cacheKey]; + return crcTreeCache[cacheKey]; + } + else { + return 0; + } } vector > getFolderTreeContentsCheckSumListRecursively(vector paths, string pathSearchString, string filterFileExt, vector > *recursiveMap) { @@ -461,6 +453,7 @@ vector > getFolderTreeContentsCheckSumListRecursively(ve //finds all filenames like path and gets the checksum of each file vector > getFolderTreeContentsCheckSumListRecursively(const string &path, const string &filterFileExt, vector > *recursiveMap) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s] filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str()); //static std::map > > crcTreeCache; string cacheLookupId = string(__FILE__) + intToStr(__LINE__); @@ -496,25 +489,17 @@ vector > getFolderTreeContentsCheckSumListRecursively(co for(int i = 0; i < globbuf.gl_pathc; ++i) { const char* p = globbuf.gl_pathv[i]; - /* - const char* begin = p; - for( ; *p != 0; ++p) { - // strip the path component - if(*p == '/') - begin = p+1; - } - */ - if(isdir(p) == false) - { + if(isdir(p) == false) { bool addFile = true; - if(filterFileExt != "") - { + if(EndsWith(p, ".") == true || EndsWith(p, "..") == true || EndsWith(p, ".svn") == true) { + addFile = false; + } + else if(filterFileExt != "") { addFile = EndsWith(p, filterFileExt); } - if(addFile) - { + if(addFile) { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] adding file [%s]\n",__FILE__,__FUNCTION__,p); Checksum checksum; @@ -537,15 +522,6 @@ vector > getFolderTreeContentsCheckSumListRecursively(co for(int i = 0; i < globbuf.gl_pathc; ++i) { const char* p = globbuf.gl_pathv[i]; - /* - const char* begin = p; - for( ; *p != 0; ++p) { - // strip the path component - if(*p == '/') - begin = p+1; - } - */ - checksumFiles = getFolderTreeContentsCheckSumListRecursively(string(p) + "/*", filterFileExt, &checksumFiles); } @@ -558,12 +534,8 @@ vector > getFolderTreeContentsCheckSumListRecursively(co return crcTreeCache[cacheKey]; } -string extractFileFromDirectoryPath(string filename) -{ - size_t lastDirectory_Win = filename.find_last_of('\\'); - size_t lastDirectory_Lin = filename.find_last_of('/'); - size_t lastDirectory = (lastDirectory_Win lastPoint)) { return ""; diff --git a/source/shared_lib/sources/platform/common/simple_threads.cpp b/source/shared_lib/sources/platform/common/simple_threads.cpp index 896ecd276..adadd2c7a 100644 --- a/source/shared_lib/sources/platform/common/simple_threads.cpp +++ b/source/shared_lib/sources/platform/common/simple_threads.cpp @@ -36,9 +36,14 @@ void FileCRCPreCacheThread::execute() { for(unsigned int idx = 0; idx < techPaths.size(); idx++) { string techName = techPaths[idx]; + time_t elapsedTime = time(NULL); printf("In [%s::%s Line: %d] caching CRC value for Tech [%s] [%d of %d]\n",__FILE__,__FUNCTION__,__LINE__,techName.c_str(),idx+1,techPaths.size()); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] caching CRC value for Tech [%s] [%d of %d]\n",__FILE__,__FUNCTION__,__LINE__,techName.c_str(),idx+1,techPaths.size()); + int32 techCRC = getFolderTreeContentsCheckSumRecursively(techDataPaths, string("/") + techName + string("/*"), ".xml", NULL); - printf("In [%s::%s Line: %d] cached CRC value for Tech [%s] is [%d] [%d of %d]\n",__FILE__,__FUNCTION__,__LINE__,techName.c_str(),techCRC,idx+1,techPaths.size()); + + printf("In [%s::%s Line: %d] cached CRC value for Tech [%s] is [%d] [%d of %d] took %.3f seconds.\n",__FILE__,__FUNCTION__,__LINE__,techName.c_str(),techCRC,idx+1,techPaths.size(),difftime(time(NULL),elapsedTime)); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] cached CRC value for Tech [%s] is [%d] [%d of %d] took %.3f seconds.\n",__FILE__,__FUNCTION__,__LINE__,techName.c_str(),techCRC,idx+1,techPaths.size(),difftime(time(NULL),elapsedTime)); if(getQuitStatus() == true) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);