Fixed map CRCs

This commit is contained in:
mathusummut
2019-03-06 00:36:33 +01:00
parent 8ce2993e5d
commit a11327f2ef
6 changed files with 47 additions and 57 deletions

View File

@@ -61,9 +61,9 @@ namespace Game {
description; description;
string string
count; // used for faction count for example count; // used for faction count for example
string uint32
crc; crc;
string uint32
localCRC; localCRC;
ModType ModType
type; type;

View File

@@ -1096,7 +1096,7 @@ namespace Game {
Config & config = Config::getInstance(); Config & config = Config::getInstance();
ModInfo modinfo; ModInfo modinfo;
modinfo.name = tilesetInfoList[0]; modinfo.name = tilesetInfoList[0];
modinfo.crc = tilesetInfoList[1]; modinfo.crc = strToUInt(tilesetInfoList[1]);
modinfo.description = tilesetInfoList[2]; modinfo.description = tilesetInfoList[2];
modinfo.url = tilesetInfoList[3]; modinfo.url = tilesetInfoList[3];
modinfo.imageUrl = tilesetInfoList[4]; modinfo.imageUrl = tilesetInfoList[4];
@@ -1128,12 +1128,12 @@ namespace Game {
NULL, forceRefresh); NULL, forceRefresh);
} }
} }
modinfo.localCRC = uIntToStr(crc); modinfo.localCRC = crc;
//printf("itemPath='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc); //printf("itemPath='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc);
//printf("#1 refreshTilesetModInfo name [%s] modInfo.crc [%s] modInfo.localCRC [%s]\n",modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str()); //printf("#1 refreshTilesetModInfo name [%s] modInfo.crc [%s] modInfo.localCRC [%s]\n",modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str());
} else { } else {
modinfo.localCRC = ""; modinfo.localCRC = 0;
//printf("#2 refreshTilesetModInfo name [%s] modInfo.crc [%s] modInfo.localCRC [%s]\n",modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str()); //printf("#2 refreshTilesetModInfo name [%s] modInfo.crc [%s] modInfo.localCRC [%s]\n",modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str());
} }
@@ -1152,7 +1152,7 @@ namespace Game {
ModInfo modinfo; ModInfo modinfo;
modinfo.name = techInfoList[0]; modinfo.name = techInfoList[0];
modinfo.count = techInfoList[1]; modinfo.count = techInfoList[1];
modinfo.crc = techInfoList[2]; modinfo.crc = strToUInt(techInfoList[2]);
modinfo.description = techInfoList[3]; modinfo.description = techInfoList[3];
modinfo.url = techInfoList[4]; modinfo.url = techInfoList[4];
modinfo.imageUrl = techInfoList[5]; modinfo.imageUrl = techInfoList[5];
@@ -1184,10 +1184,10 @@ namespace Game {
NULL, forceRefresh); NULL, forceRefresh);
} }
} }
modinfo.localCRC = uIntToStr(crc); modinfo.localCRC = crc;
//printf("itemPath='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc); //printf("itemPath='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc);
} else { } else {
modinfo.localCRC = ""; modinfo.localCRC = 0;
} }
techCacheList[modinfo.name] = modinfo; techCacheList[modinfo.name] = modinfo;
return modinfo.name; return modinfo.name;
@@ -1195,31 +1195,29 @@ namespace Game {
return ""; return "";
} }
string MenuStateConnectedGame::getMapCRC(string mapName) { uint32 MenuStateConnectedGame::getMapCRC(string mapName) {
Config & config = Config::getInstance(); Config & config = Config::getInstance();
vector < string > mappaths = config.getPathListForType(ptMaps, ""); vector < string > mappaths = config.getPathListForType(ptMaps, "");
string result = ""; uint32 result;
if (mappaths.empty() == false) { if (mappaths.empty() == false) {
Checksum checksum; Checksum checksum;
string itemPath = mappaths[1] + "/" + mapName; string itemPath = mappaths[1] + "/" + mapName;
if (fileExists(itemPath)) { if (fileExists(itemPath)) {
checksum.addFile(itemPath); checksum.addFile(itemPath);
uint32 crc = checksum.getSum(); result = checksum.getSum();
result = uIntToStr(crc);
//printf("itemPath='%s' modinfo.name='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc); //printf("itemPath='%s' modinfo.name='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc);
} else { } else {
itemPath = mappaths[0] + "/" + mapName; itemPath = mappaths[0] + "/" + mapName;
if (fileExists(itemPath)) { if (fileExists(itemPath)) {
checksum.addFile(itemPath); checksum.addFile(itemPath);
uint32 crc = checksum.getSum(); result = checksum.getSum();
result = uIntToStr(crc);
//printf("itemPath='%s' modinfo.name='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc); //printf("itemPath='%s' modinfo.name='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc);
} else { } else {
result = ""; result = 0;
} }
} }
} else { } else {
result = ""; result = 0;
} }
return result; return result;
} }
@@ -1232,7 +1230,7 @@ namespace Game {
ModInfo modinfo; ModInfo modinfo;
modinfo.name = mapInfoList[0]; modinfo.name = mapInfoList[0];
modinfo.count = mapInfoList[1]; modinfo.count = mapInfoList[1];
modinfo.crc = mapInfoList[2]; modinfo.crc = strToUInt(mapInfoList[2]);
modinfo.description = mapInfoList[3]; modinfo.description = mapInfoList[3];
modinfo.url = mapInfoList[4]; modinfo.url = mapInfoList[4];
modinfo.imageUrl = mapInfoList[5]; modinfo.imageUrl = mapInfoList[5];

View File

@@ -339,7 +339,7 @@ namespace Game {
string refreshTilesetModInfo(string tilesetInfo); string refreshTilesetModInfo(string tilesetInfo);
string refreshTechModInfo(string techInfo); string refreshTechModInfo(string techInfo);
string refreshMapModInfo(string mapInfo); string refreshMapModInfo(string mapInfo);
string getMapCRC(string mapName); uint32 getMapCRC(string mapName);
void disconnectFromServer(); void disconnectFromServer();
}; };

View File

@@ -56,7 +56,7 @@ namespace Game {
imageUrl = ""; imageUrl = "";
description = ""; description = "";
count = ""; count = "";
crc = ""; crc = 0;
type = mt_None; type = mt_None;
} }
@@ -1127,7 +1127,7 @@ namespace Game {
ModInfo modinfo; ModInfo modinfo;
modinfo.name = techInfoList[0]; modinfo.name = techInfoList[0];
modinfo.count = techInfoList[1]; modinfo.count = techInfoList[1];
modinfo.crc = techInfoList[2]; modinfo.crc = strToUInt(techInfoList[2]);
modinfo.description = techInfoList[3]; modinfo.description = techInfoList[3];
modinfo.url = techInfoList[4]; modinfo.url = techInfoList[4];
modinfo.imageUrl = techInfoList[5]; modinfo.imageUrl = techInfoList[5];
@@ -1156,10 +1156,10 @@ namespace Game {
NULL, forceRefresh); NULL, forceRefresh);
} }
} }
modinfo.localCRC = uIntToStr(crc); modinfo.localCRC = crc;
//printf("itemPath='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc); //printf("itemPath='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc);
} else { } else {
modinfo.localCRC = ""; modinfo.localCRC = 0;
} }
techCacheList[modinfo.name] = modinfo; techCacheList[modinfo.name] = modinfo;
return modinfo.name; return modinfo.name;
@@ -1195,7 +1195,7 @@ namespace Game {
Config & config = Config::getInstance(); Config & config = Config::getInstance();
ModInfo modinfo; ModInfo modinfo;
modinfo.name = tilesetInfoList[0]; modinfo.name = tilesetInfoList[0];
modinfo.crc = tilesetInfoList[1]; modinfo.crc = strToUInt(tilesetInfoList[1]);
modinfo.description = tilesetInfoList[2]; modinfo.description = tilesetInfoList[2];
modinfo.url = tilesetInfoList[3]; modinfo.url = tilesetInfoList[3];
modinfo.imageUrl = tilesetInfoList[4]; modinfo.imageUrl = tilesetInfoList[4];
@@ -1224,12 +1224,12 @@ namespace Game {
NULL, forceRefresh); NULL, forceRefresh);
} }
} }
modinfo.localCRC = uIntToStr(crc); modinfo.localCRC = crc;
//printf("itemPath='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc); //printf("itemPath='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc);
//printf("#1 refreshTilesetModInfo name [%s] modInfo.crc [%s] modInfo.localCRC [%s]\n",modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str()); //printf("#1 refreshTilesetModInfo name [%s] modInfo.crc [%s] modInfo.localCRC [%s]\n",modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str());
} else { } else {
modinfo.localCRC = ""; modinfo.localCRC = 0;
//printf("#2 refreshTilesetModInfo name [%s] modInfo.crc [%s] modInfo.localCRC [%s]\n",modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str()); //printf("#2 refreshTilesetModInfo name [%s] modInfo.crc [%s] modInfo.localCRC [%s]\n",modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str());
} }
@@ -1248,9 +1248,7 @@ namespace Game {
} }
void MenuStateMods::getMapsLocalList() { void MenuStateMods::getMapsLocalList() {
/* Config &config = Config::getInstance();
/*
Config &config = Config::getInstance();
vector<string> results; vector<string> results;
set<string> allMaps; set<string> allMaps;
findAll(config.getPathListForType(ptMaps), "*.gbm", results, false, false); findAll(config.getPathListForType(ptMaps), "*.gbm", results, false, false);
@@ -1312,7 +1310,7 @@ namespace Game {
ModInfo modinfo; ModInfo modinfo;
modinfo.name = mapInfoList[0]; modinfo.name = mapInfoList[0];
modinfo.count = mapInfoList[1]; modinfo.count = mapInfoList[1];
modinfo.crc = mapInfoList[2]; modinfo.crc = strToUInt(mapInfoList[2]);
modinfo.description = mapInfoList[3]; modinfo.description = mapInfoList[3];
modinfo.url = mapInfoList[4]; modinfo.url = mapInfoList[4];
modinfo.imageUrl = mapInfoList[5]; modinfo.imageUrl = mapInfoList[5];
@@ -1324,31 +1322,29 @@ namespace Game {
return ""; return "";
} }
string MenuStateMods::getMapCRC(string mapName) { uint32 MenuStateMods::getMapCRC(string mapName) {
Config & config = Config::getInstance(); Config & config = Config::getInstance();
vector < string > mappaths = config.getPathListForType(ptMaps, ""); vector < string > mappaths = config.getPathListForType(ptMaps, "");
string result = ""; uint32 result;
if (mappaths.empty() == false) { if (mappaths.empty() == false) {
Checksum checksum; Checksum checksum;
string itemPath = mappaths[1] + "/" + mapName; string itemPath = mappaths[1] + "/" + mapName;
if (fileExists(itemPath)) { if (fileExists(itemPath)) {
checksum.addFile(itemPath); checksum.addFile(itemPath);
uint32 crc = checksum.getSum(); result = checksum.getSum();
result = uIntToStr(crc);
//printf("itemPath='%s' modinfo.name='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc); //printf("itemPath='%s' modinfo.name='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc);
} else { } else {
itemPath = mappaths[0] + "/" + mapName; itemPath = mappaths[0] + "/" + mapName;
if (fileExists(itemPath)) { if (fileExists(itemPath)) {
checksum.addFile(itemPath); checksum.addFile(itemPath);
uint32 crc = checksum.getSum(); result = checksum.getSum();
result = uIntToStr(crc);
//printf("itemPath='%s' modinfo.name='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc); //printf("itemPath='%s' modinfo.name='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.name.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc);
} else { } else {
result = ""; result = 0;
} }
} }
} else { } else {
result = ""; result = 0;
} }
return result; return result;
} }
@@ -1381,7 +1377,7 @@ namespace Game {
Config & config = Config::getInstance(); Config & config = Config::getInstance();
ModInfo modinfo; ModInfo modinfo;
modinfo.name = scenarioInfoList[0]; modinfo.name = scenarioInfoList[0];
modinfo.crc = scenarioInfoList[1]; modinfo.crc = strToUInt(scenarioInfoList[1]);
modinfo.description = scenarioInfoList[2]; modinfo.description = scenarioInfoList[2];
modinfo.url = scenarioInfoList[3]; modinfo.url = scenarioInfoList[3];
modinfo.imageUrl = scenarioInfoList[4]; modinfo.imageUrl = scenarioInfoList[4];
@@ -1410,10 +1406,10 @@ namespace Game {
NULL, forceRefresh); NULL, forceRefresh);
} }
} }
modinfo.localCRC = uIntToStr(crc); modinfo.localCRC = crc;
//printf(" itemPath='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc); //printf(" itemPath='%s' remote crc:'%s' local crc:'%s' crc='%d' \n",itemPath.c_str(),modinfo.crc.c_str(),modinfo.localCRC.c_str(),crc);
} else { } else {
modinfo.localCRC = ""; modinfo.localCRC = 0;
} }
scenarioCacheList[modinfo.name] = modinfo; scenarioCacheList[modinfo.name] = modinfo;
return modinfo.name; return modinfo.name;
@@ -1999,8 +1995,8 @@ namespace Game {
ModInfo & modInfo = techCacheList[selectedTechName]; ModInfo & modInfo = techCacheList[selectedTechName];
if (SystemFlags::VERBOSE_MODE_ENABLED) if (SystemFlags::VERBOSE_MODE_ENABLED)
printf("In [%s::%s Line %d] remote CRC [%s]\n", __FILE__, printf("In [%s::%s Line %d] remote CRC [%u]\n", __FILE__,
__FUNCTION__, __LINE__, modInfo.crc.c_str()); __FUNCTION__, __LINE__, modInfo.crc);
Config & config = Config::getInstance(); Config & config = Config::getInstance();
string itemPath = string itemPath =
@@ -2009,11 +2005,9 @@ namespace Game {
string("/*"); string("/*");
bool forceRefresh = bool forceRefresh =
(mapCRCUpdateList.find(itemPath) == mapCRCUpdateList.end()); (mapCRCUpdateList.find(itemPath) == mapCRCUpdateList.end());
if (strToUInt(modInfo.crc) != 0 if (modInfo.crc != 0 && modInfo.crc !=
&& strToUInt(modInfo.crc) !=
getFolderTreeContentsCheckSumRecursively(itemPath, ".xml", getFolderTreeContentsCheckSumRecursively(itemPath, ".xml",
NULL, NULL, forceRefresh)) {
forceRefresh)) {
if (SystemFlags::VERBOSE_MODE_ENABLED) if (SystemFlags::VERBOSE_MODE_ENABLED)
printf("In [%s::%s Line %d] local CRC [%u]\n", __FILE__, printf("In [%s::%s Line %d] local CRC [%u]\n", __FILE__,
__FUNCTION__, __LINE__, __FUNCTION__, __LINE__,
@@ -2116,8 +2110,8 @@ namespace Game {
if (remoteHasTileset) { if (remoteHasTileset) {
ModInfo & modInfo = tilesetCacheList[selectedTilesetName]; ModInfo & modInfo = tilesetCacheList[selectedTilesetName];
if (SystemFlags::VERBOSE_MODE_ENABLED) if (SystemFlags::VERBOSE_MODE_ENABLED)
printf("In [%s::%s Line %d] remote CRC [%s]\n", __FILE__, printf("In [%s::%s Line %d] remote CRC [%u]\n", __FILE__,
__FUNCTION__, __LINE__, modInfo.crc.c_str()); __FUNCTION__, __LINE__, modInfo.crc);
Config & config = Config::getInstance(); Config & config = Config::getInstance();
string itemPath = string itemPath =
@@ -2127,8 +2121,7 @@ namespace Game {
bool forceRefresh = bool forceRefresh =
(mapCRCUpdateList.find(itemPath) == mapCRCUpdateList.end()); (mapCRCUpdateList.find(itemPath) == mapCRCUpdateList.end());
if (strToUInt(modInfo.crc) != 0 && if (modInfo.crc != 0 && modInfo.crc !=
strToUInt(modInfo.crc) !=
getFolderTreeContentsCheckSumRecursively(itemPath, ".xml", getFolderTreeContentsCheckSumRecursively(itemPath, ".xml",
NULL, NULL,
forceRefresh)) { forceRefresh)) {
@@ -2325,8 +2318,8 @@ namespace Game {
if (remoteHasScenario) { if (remoteHasScenario) {
ModInfo & modInfo = scenarioCacheList[selectedScenarioName]; ModInfo & modInfo = scenarioCacheList[selectedScenarioName];
if (SystemFlags::VERBOSE_MODE_ENABLED) if (SystemFlags::VERBOSE_MODE_ENABLED)
printf("In [%s::%s Line %d] remote CRC [%s]\n", __FILE__, printf("In [%s::%s Line %d] remote CRC [%u]\n", __FILE__,
__FUNCTION__, __LINE__, modInfo.crc.c_str()); __FUNCTION__, __LINE__, modInfo.crc);
Config & config = Config::getInstance(); Config & config = Config::getInstance();
string itemPath = string itemPath =
@@ -2336,8 +2329,7 @@ namespace Game {
bool forceRefresh = bool forceRefresh =
(mapCRCUpdateList.find(itemPath) == mapCRCUpdateList.end()); (mapCRCUpdateList.find(itemPath) == mapCRCUpdateList.end());
if (strToUInt(modInfo.crc) != 0 && if (modInfo.crc != 0 && modInfo.crc !=
strToUInt(modInfo.crc) !=
getFolderTreeContentsCheckSumRecursively(itemPath, "", getFolderTreeContentsCheckSumRecursively(itemPath, "",
NULL, NULL,
forceRefresh)) { forceRefresh)) {
@@ -2446,7 +2438,7 @@ namespace Game {
(mapCacheList.find(mapName) != mapCacheList.end()); (mapCacheList.find(mapName) != mapCacheList.end());
if (remoteHasMap) { if (remoteHasMap) {
showRemoteDesription(&mapCacheList[selectedMapName]); showRemoteDesription(&mapCacheList[selectedMapName]);
if (mapCacheList[selectedMapName].localCRC != "") { if (mapCacheList[selectedMapName].localCRC != 0) {
loadMapPreview(mapName); loadMapPreview(mapName);
} }
} else { } else {

View File

@@ -180,7 +180,7 @@ namespace Game {
void getMapsLocalList(); void getMapsLocalList();
string refreshMapModInfo(string mapInfo); string refreshMapModInfo(string mapInfo);
void refreshMaps(); void refreshMaps();
string getMapCRC(string mapName); uint32 getMapCRC(string mapName);
void getScenariosLocalList(); void getScenariosLocalList();
string refreshScenarioModInfo(string scenarioInfo); string refreshScenarioModInfo(string scenarioInfo);

View File

@@ -2,4 +2,4 @@
#define G3D_VIEWER_VERSION "1.0" #define G3D_VIEWER_VERSION "1.0"
#define MAP_EDITOR_VERSION "1.0" #define MAP_EDITOR_VERSION "1.0"
//Month then Day //Month then Day
#define GAME_BUILD_DATE "0219" #define GAME_BUILD_DATE "0306"