From 51ae0141240cd04c737288fee520a683aac071e6 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 9 Apr 2011 21:46:13 +0000 Subject: [PATCH] - added feature to use mod CRC values if they are entered on the server, clients will fetch their own CRC value and if different allow users to replace current mod with server version, currently ONLY techtree is implemented for testing (munchy techtree is setup) --- source/glest_game/main/main.cpp | 2 +- source/glest_game/menu/menu_state_mods.cpp | 18 +++++++++++++++++- source/glest_game/menu/menu_state_mods.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 3d62ef433..95257e039 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -2319,7 +2319,7 @@ int glestMain(int argc, char** argv) { string paramValue = argv[foundParamIndIndex]; vector paramPartTokens; Tokenize(paramValue,paramPartTokens,"="); - if(paramPartTokens.size() >= 3 && paramPartTokens[1].length() > 0 && paramPartTokens[2].length() > 0) { + if(paramPartTokens.size() >= 3 && paramPartTokens[1].length() > 0) { string itemName = paramPartTokens[1]; string itemNameFilter = paramPartTokens[2]; int32 crcValue = getFolderTreeContentsCheckSumRecursively(itemName, itemNameFilter, NULL, true); diff --git a/source/glest_game/menu/menu_state_mods.cpp b/source/glest_game/menu/menu_state_mods.cpp index 959271a7d..7761fefc8 100644 --- a/source/glest_game/menu/menu_state_mods.cpp +++ b/source/glest_game/menu/menu_state_mods.cpp @@ -696,6 +696,14 @@ void MenuStateMods::getTechsLocalList() { string path = config.getPathListForType(ptTechs)[1]; endPathWithSlash(path); findDirs(path, techTreeFilesUserData, false, false); + + //for(unsigned int i = 0; i < techTreeFilesUserData.size(); ++i) { + //string itemPath = config.getPathListForType(ptTechs,"")[1] + "/" + techTreeFilesUserData[i] + string("/*"); + //bool forceRefresh = (mapCRCUpdateList.find(itemPath) == mapCRCUpdateList.end()); + //mapCRCUpdateList[itemPath] = getFolderTreeContentsCheckSumRecursively(itemPath, "", NULL,forceRefresh); + //mapCRCUpdateList[itemPath] = getFolderTreeContentsCheckSumRecursively(itemPath, "", NULL,false); + //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d] local CRC for techtree [%s] is [%d]\n",__FILE__,__FUNCTION__,__LINE__,itemPath.c_str(),mapCRCUpdateList[itemPath]); + //} } } @@ -1152,9 +1160,16 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) { if(alreadyHasTech == true) { ModInfo &modInfo = techCacheList[selectedTechName]; + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d] remote CRC [%s]\n",__FILE__,__FUNCTION__,__LINE__,modInfo.crc.c_str()); + Config &config = Config::getInstance(); + string itemPath = config.getPathListForType(ptTechs,"")[1] + "/" + selectedTechName + string("/*"); + bool forceRefresh = (mapCRCUpdateList.find(itemPath) == mapCRCUpdateList.end()); + if( strToInt(modInfo.crc) != 0 && - strToInt(modInfo.crc) != getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), string("/") + selectedTechName + string("/*"), ".xml", NULL)) { + strToInt(modInfo.crc) != getFolderTreeContentsCheckSumRecursively(itemPath, "", NULL,forceRefresh)) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d] local CRC [%d]\n",__FILE__,__FUNCTION__,__LINE__,getFolderTreeContentsCheckSumRecursively(itemPath, "", NULL)); + mainMessageBoxState = ftpmsg_ReplaceTechtree; mainMessageBox.init(lang.get("Yes"),lang.get("No")); char szBuf[1024]=""; @@ -1168,6 +1183,7 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) { sprintf(szBuf,lang.get("ModTechAlreadyInstalled").c_str(),selectedTechName.c_str()); showMessageBox(szBuf, lang.get("Notice"), true); } + mapCRCUpdateList[itemPath] = true; } else { string techName = selectedTechName; diff --git a/source/glest_game/menu/menu_state_mods.h b/source/glest_game/menu/menu_state_mods.h index 9d17e4b55..16fec11fd 100644 --- a/source/glest_game/menu/menu_state_mods.h +++ b/source/glest_game/menu/menu_state_mods.h @@ -174,6 +174,7 @@ private: void showDesription(const ModInfo *modInfo); + std::map mapCRCUpdateList; public: MenuStateMods(Program *program, MainMenu *mainMenu);