mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 04:02:30 +01:00
- added other mod types for crc check of changed server data (server items require a proper value in the crc field)
This commit is contained in:
parent
42a6737960
commit
a06dcadd08
@ -966,7 +966,9 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||
return;
|
||||
}
|
||||
else if(mainMessageBoxState == ftpmsg_GetMap) {
|
||||
else if(mainMessageBoxState == ftpmsg_GetMap ||
|
||||
mainMessageBoxState == ftpmsg_ReplaceMap) {
|
||||
bool getItemAfterRemoval = (mainMessageBoxState == ftpmsg_ReplaceMap);
|
||||
mainMessageBoxState = ftpmsg_None;
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
@ -993,12 +995,26 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
}
|
||||
}
|
||||
|
||||
if(getItemAfterRemoval == false) {
|
||||
selectedMapName = "";
|
||||
}
|
||||
refreshMaps();
|
||||
Checksum::clearFileCache();
|
||||
|
||||
if(getItemAfterRemoval == true) {
|
||||
string mapName = selectedMapName;
|
||||
string mapURL = mapCacheList[mapName].url;
|
||||
ftpClientThread->addMapToRequests(mapName,mapURL);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
fileFTPProgressList[mapName] = pair<int,string>(0,"");
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
buttonInstallMap.setEnabled(false);
|
||||
}
|
||||
}
|
||||
else if(mainMessageBoxState == ftpmsg_GetTileset) {
|
||||
}
|
||||
else if(mainMessageBoxState == ftpmsg_GetTileset ||
|
||||
mainMessageBoxState == ftpmsg_ReplaceTileset) {
|
||||
bool getItemAfterRemoval = (mainMessageBoxState == ftpmsg_ReplaceTileset);
|
||||
mainMessageBoxState = ftpmsg_None;
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
@ -1033,9 +1049,22 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
clearFolderTreeContentsCheckSumList(paths, pathSearchString, filterFileExt);
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
|
||||
if(getItemAfterRemoval == false) {
|
||||
selectedTilesetName = "";
|
||||
}
|
||||
refreshTilesets();
|
||||
}
|
||||
|
||||
if(getItemAfterRemoval == true) {
|
||||
string tilesetName = selectedTilesetName;
|
||||
string tilesetURL = tilesetCacheList[tilesetName].url;
|
||||
ftpClientThread->addTilesetToRequests(tilesetName,tilesetURL);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
fileFTPProgressList[tilesetName] = pair<int,string>(0,"");
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
buttonInstallTileset.setEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
else if(mainMessageBoxState == ftpmsg_GetTechtree ||
|
||||
mainMessageBoxState == ftpmsg_ReplaceTechtree) {
|
||||
@ -1093,7 +1122,9 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
buttonInstallTech.setEnabled(false);
|
||||
}
|
||||
}
|
||||
else if(mainMessageBoxState == ftpmsg_GetScenario) {
|
||||
else if(mainMessageBoxState == ftpmsg_GetScenario ||
|
||||
mainMessageBoxState == ftpmsg_ReplaceScenario) {
|
||||
bool getItemAfterRemoval = (mainMessageBoxState == ftpmsg_ReplaceScenario);
|
||||
mainMessageBoxState = ftpmsg_None;
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
@ -1128,9 +1159,21 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
clearFolderTreeContentsCheckSumList(paths, pathSearchString, filterFileExt);
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
|
||||
if(getItemAfterRemoval == false) {
|
||||
selectedScenarioName = "";
|
||||
}
|
||||
refreshScenarios();
|
||||
}
|
||||
|
||||
if(getItemAfterRemoval == true) {
|
||||
string scenarioName = selectedScenarioName;
|
||||
string scenarioURL = scenarioCacheList[scenarioName].url;
|
||||
ftpClientThread->addScenarioToRequests(scenarioName,scenarioURL);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
fileFTPProgressList[scenarioName] = pair<int,string>(0,"");
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
buttonInstallScenario.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1237,12 +1280,31 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
if(selectedTilesetName != "") {
|
||||
bool alreadyHasTileset = (std::find(tilesetFiles.begin(),tilesetFiles.end(),selectedTilesetName) != tilesetFiles.end());
|
||||
if(alreadyHasTileset == true) {
|
||||
ModInfo &modInfo = tilesetCacheList[selectedTilesetName];
|
||||
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(ptTilesets,"")[1] + "/" + selectedTilesetName + string("/*");
|
||||
bool forceRefresh = (mapCRCUpdateList.find(itemPath) == mapCRCUpdateList.end());
|
||||
|
||||
if( strToInt(modInfo.crc) != 0 &&
|
||||
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_ReplaceTileset;
|
||||
mainMessageBox.init(lang.get("Yes"),lang.get("No"));
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,lang.get("ModLocalRemoteMismatch").c_str(),selectedTilesetName.c_str());
|
||||
showMessageBox(szBuf, lang.get("Notice"), true);
|
||||
}
|
||||
else {
|
||||
mainMessageBoxState = ftpmsg_None;
|
||||
mainMessageBox.init(lang.get("Ok"));
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,lang.get("ModTilesetAlreadyInstalled").c_str(),selectedTilesetName.c_str());
|
||||
showMessageBox(szBuf, lang.get("Notice"), true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
string tilesetName = selectedTilesetName;
|
||||
string tilesetURL = tilesetCacheList[tilesetName].url;
|
||||
@ -1291,12 +1353,32 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
if(selectedMapName != "") {
|
||||
bool alreadyHasMap = (std::find(mapFiles.begin(),mapFiles.end(),selectedMapName) != mapFiles.end());
|
||||
if(alreadyHasMap == true) {
|
||||
ModInfo &modInfo = mapCacheList[selectedMapName];
|
||||
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();
|
||||
Checksum checksum;
|
||||
string file = Map::getMapPath(selectedMapName,"",false);
|
||||
checksum.addFile(file);
|
||||
|
||||
if( strToInt(modInfo.crc) != 0 &&
|
||||
strToInt(modInfo.crc) != checksum.getSum()) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d] local CRC [%d]\n",__FILE__,__FUNCTION__,__LINE__,checksum.getSum());
|
||||
|
||||
mainMessageBoxState = ftpmsg_ReplaceMap;
|
||||
mainMessageBox.init(lang.get("Yes"),lang.get("No"));
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,lang.get("ModLocalRemoteMismatch").c_str(),selectedMapName.c_str());
|
||||
showMessageBox(szBuf, lang.get("Notice"), true);
|
||||
}
|
||||
else {
|
||||
mainMessageBoxState = ftpmsg_None;
|
||||
mainMessageBox.init(lang.get("Ok"));
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,lang.get("ModMapAlreadyInstalled").c_str(),selectedMapName.c_str());
|
||||
showMessageBox(szBuf, lang.get("Notice"), true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
string mapName = selectedMapName;
|
||||
string mapURL = mapCacheList[mapName].url;
|
||||
@ -1345,12 +1427,31 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
if(selectedScenarioName != "") {
|
||||
bool alreadyHasScenario = (std::find(scenarioFiles.begin(),scenarioFiles.end(),selectedScenarioName) != scenarioFiles.end());
|
||||
if(alreadyHasScenario == true) {
|
||||
ModInfo &modInfo = scenarioCacheList[selectedScenarioName];
|
||||
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(ptScenarios,"")[1] + "/" + selectedScenarioName + string("/*");
|
||||
bool forceRefresh = (mapCRCUpdateList.find(itemPath) == mapCRCUpdateList.end());
|
||||
|
||||
if( strToInt(modInfo.crc) != 0 &&
|
||||
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_ReplaceScenario;
|
||||
mainMessageBox.init(lang.get("Yes"),lang.get("No"));
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,lang.get("ModLocalRemoteMismatch").c_str(),selectedScenarioName.c_str());
|
||||
showMessageBox(szBuf, lang.get("Notice"), true);
|
||||
}
|
||||
else {
|
||||
mainMessageBoxState = ftpmsg_None;
|
||||
mainMessageBox.init(lang.get("Ok"));
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,lang.get("ModScenarioAlreadyInstalled").c_str(),selectedScenarioName.c_str());
|
||||
showMessageBox(szBuf, lang.get("Notice"), true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
string scenarioName = selectedScenarioName;
|
||||
string scenarioURL = scenarioCacheList[scenarioName].url;
|
||||
|
Loading…
x
Reference in New Issue
Block a user