- 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)

This commit is contained in:
Mark Vejvoda 2011-04-09 21:46:13 +00:00
parent 64dbe0f887
commit 51ae014124
3 changed files with 19 additions and 2 deletions

View File

@ -2319,7 +2319,7 @@ int glestMain(int argc, char** argv) {
string paramValue = argv[foundParamIndIndex];
vector<string> 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);

View File

@ -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;

View File

@ -174,6 +174,7 @@ private:
void showDesription(const ModInfo *modInfo);
std::map<string,int32> mapCRCUpdateList;
public:
MenuStateMods(Program *program, MainMenu *mainMenu);