- 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));
|
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(mainMessageBoxState == ftpmsg_GetMap) {
|
else if(mainMessageBoxState == ftpmsg_GetMap ||
|
||||||
|
mainMessageBoxState == ftpmsg_ReplaceMap) {
|
||||||
|
bool getItemAfterRemoval = (mainMessageBoxState == ftpmsg_ReplaceMap);
|
||||||
mainMessageBoxState = ftpmsg_None;
|
mainMessageBoxState = ftpmsg_None;
|
||||||
|
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
@ -993,12 +995,26 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedMapName = "";
|
if(getItemAfterRemoval == false) {
|
||||||
|
selectedMapName = "";
|
||||||
|
}
|
||||||
refreshMaps();
|
refreshMaps();
|
||||||
Checksum::clearFileCache();
|
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;
|
mainMessageBoxState = ftpmsg_None;
|
||||||
|
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
@ -1033,9 +1049,22 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
clearFolderTreeContentsCheckSumList(paths, pathSearchString, filterFileExt);
|
clearFolderTreeContentsCheckSumList(paths, pathSearchString, filterFileExt);
|
||||||
safeMutexFTPProgress.ReleaseLock();
|
safeMutexFTPProgress.ReleaseLock();
|
||||||
|
|
||||||
selectedTilesetName = "";
|
if(getItemAfterRemoval == false) {
|
||||||
|
selectedTilesetName = "";
|
||||||
|
}
|
||||||
refreshTilesets();
|
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 ||
|
else if(mainMessageBoxState == ftpmsg_GetTechtree ||
|
||||||
mainMessageBoxState == ftpmsg_ReplaceTechtree) {
|
mainMessageBoxState == ftpmsg_ReplaceTechtree) {
|
||||||
|
@ -1093,7 +1122,9 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
buttonInstallTech.setEnabled(false);
|
buttonInstallTech.setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(mainMessageBoxState == ftpmsg_GetScenario) {
|
else if(mainMessageBoxState == ftpmsg_GetScenario ||
|
||||||
|
mainMessageBoxState == ftpmsg_ReplaceScenario) {
|
||||||
|
bool getItemAfterRemoval = (mainMessageBoxState == ftpmsg_ReplaceScenario);
|
||||||
mainMessageBoxState = ftpmsg_None;
|
mainMessageBoxState = ftpmsg_None;
|
||||||
|
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
@ -1128,9 +1159,21 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
clearFolderTreeContentsCheckSumList(paths, pathSearchString, filterFileExt);
|
clearFolderTreeContentsCheckSumList(paths, pathSearchString, filterFileExt);
|
||||||
safeMutexFTPProgress.ReleaseLock();
|
safeMutexFTPProgress.ReleaseLock();
|
||||||
|
|
||||||
selectedScenarioName = "";
|
if(getItemAfterRemoval == false) {
|
||||||
|
selectedScenarioName = "";
|
||||||
|
}
|
||||||
refreshScenarios();
|
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,11 +1280,30 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
if(selectedTilesetName != "") {
|
if(selectedTilesetName != "") {
|
||||||
bool alreadyHasTileset = (std::find(tilesetFiles.begin(),tilesetFiles.end(),selectedTilesetName) != tilesetFiles.end());
|
bool alreadyHasTileset = (std::find(tilesetFiles.begin(),tilesetFiles.end(),selectedTilesetName) != tilesetFiles.end());
|
||||||
if(alreadyHasTileset == true) {
|
if(alreadyHasTileset == true) {
|
||||||
mainMessageBoxState = ftpmsg_None;
|
ModInfo &modInfo = tilesetCacheList[selectedTilesetName];
|
||||||
mainMessageBox.init(lang.get("Ok"));
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d] remote CRC [%s]\n",__FILE__,__FUNCTION__,__LINE__,modInfo.crc.c_str());
|
||||||
char szBuf[1024]="";
|
|
||||||
sprintf(szBuf,lang.get("ModTilesetAlreadyInstalled").c_str(),selectedTilesetName.c_str());
|
Config &config = Config::getInstance();
|
||||||
showMessageBox(szBuf, lang.get("Notice"), true);
|
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 {
|
else {
|
||||||
string tilesetName = selectedTilesetName;
|
string tilesetName = selectedTilesetName;
|
||||||
|
@ -1291,11 +1353,31 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
if(selectedMapName != "") {
|
if(selectedMapName != "") {
|
||||||
bool alreadyHasMap = (std::find(mapFiles.begin(),mapFiles.end(),selectedMapName) != mapFiles.end());
|
bool alreadyHasMap = (std::find(mapFiles.begin(),mapFiles.end(),selectedMapName) != mapFiles.end());
|
||||||
if(alreadyHasMap == true) {
|
if(alreadyHasMap == true) {
|
||||||
mainMessageBoxState = ftpmsg_None;
|
ModInfo &modInfo = mapCacheList[selectedMapName];
|
||||||
mainMessageBox.init(lang.get("Ok"));
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d] remote CRC [%s]\n",__FILE__,__FUNCTION__,__LINE__,modInfo.crc.c_str());
|
||||||
char szBuf[1024]="";
|
|
||||||
sprintf(szBuf,lang.get("ModMapAlreadyInstalled").c_str(),selectedMapName.c_str());
|
Config &config = Config::getInstance();
|
||||||
showMessageBox(szBuf, lang.get("Notice"), true);
|
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 {
|
else {
|
||||||
string mapName = selectedMapName;
|
string mapName = selectedMapName;
|
||||||
|
@ -1345,11 +1427,30 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||||
if(selectedScenarioName != "") {
|
if(selectedScenarioName != "") {
|
||||||
bool alreadyHasScenario = (std::find(scenarioFiles.begin(),scenarioFiles.end(),selectedScenarioName) != scenarioFiles.end());
|
bool alreadyHasScenario = (std::find(scenarioFiles.begin(),scenarioFiles.end(),selectedScenarioName) != scenarioFiles.end());
|
||||||
if(alreadyHasScenario == true) {
|
if(alreadyHasScenario == true) {
|
||||||
mainMessageBoxState = ftpmsg_None;
|
ModInfo &modInfo = scenarioCacheList[selectedScenarioName];
|
||||||
mainMessageBox.init(lang.get("Ok"));
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d] remote CRC [%s]\n",__FILE__,__FUNCTION__,__LINE__,modInfo.crc.c_str());
|
||||||
char szBuf[1024]="";
|
|
||||||
sprintf(szBuf,lang.get("ModScenarioAlreadyInstalled").c_str(),selectedScenarioName.c_str());
|
Config &config = Config::getInstance();
|
||||||
showMessageBox(szBuf, lang.get("Notice"), true);
|
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 {
|
else {
|
||||||
string scenarioName = selectedScenarioName;
|
string scenarioName = selectedScenarioName;
|
||||||
|
|
Loading…
Reference in New Issue