- bugfix for socket mutex locked when deleting socket
- added faction detail in lobby when CRC's do not match on techtree
This commit is contained in:
parent
83eaa67068
commit
bca617cf18
|
@ -73,6 +73,7 @@ private:
|
||||||
int32 mapCRC;
|
int32 mapCRC;
|
||||||
int32 tilesetCRC;
|
int32 tilesetCRC;
|
||||||
int32 techCRC;
|
int32 techCRC;
|
||||||
|
vector<pair<string,int32> > factionCRCList;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -101,6 +102,7 @@ public:
|
||||||
mapCRC = 0;
|
mapCRC = 0;
|
||||||
tilesetCRC = 0;
|
tilesetCRC = 0;
|
||||||
techCRC = 0;
|
techCRC = 0;
|
||||||
|
factionCRCList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// default copy constructor will do fine, and will maintain itself ;)
|
// default copy constructor will do fine, and will maintain itself ;)
|
||||||
|
@ -161,6 +163,7 @@ public:
|
||||||
int32 getMapCRC() const { return mapCRC; }
|
int32 getMapCRC() const { return mapCRC; }
|
||||||
int32 getTilesetCRC() const { return tilesetCRC; }
|
int32 getTilesetCRC() const { return tilesetCRC; }
|
||||||
int32 getTechCRC() const { return techCRC; }
|
int32 getTechCRC() const { return techCRC; }
|
||||||
|
vector<pair<string,int32> > getFactionCRCList() const { return factionCRCList; }
|
||||||
|
|
||||||
//set
|
//set
|
||||||
void setDescription(const string& description) {this->description= description;}
|
void setDescription(const string& description) {this->description= description;}
|
||||||
|
@ -200,6 +203,8 @@ public:
|
||||||
void setTilesetCRC(int32 value) { tilesetCRC = value; }
|
void setTilesetCRC(int32 value) { tilesetCRC = value; }
|
||||||
void setTechCRC(int32 value) { techCRC = value; }
|
void setTechCRC(int32 value) { techCRC = value; }
|
||||||
|
|
||||||
|
void setFactionCRCList(vector<pair<string,int32> > value) { factionCRCList = value; }
|
||||||
|
|
||||||
string toString() const {
|
string toString() const {
|
||||||
string result = "";
|
string result = "";
|
||||||
|
|
||||||
|
@ -239,6 +244,10 @@ public:
|
||||||
result += "tilesetCRC = " + intToStr(tilesetCRC) + "\n";
|
result += "tilesetCRC = " + intToStr(tilesetCRC) + "\n";
|
||||||
result += "techCRC = " + intToStr(techCRC) + "\n";
|
result += "techCRC = " + intToStr(techCRC) + "\n";
|
||||||
|
|
||||||
|
for(unsigned int i = 0; i < factionCRCList.size(); ++i) {
|
||||||
|
result += "factionCRCList name [" + factionCRCList[i].first + "] CRC = " + intToStr(factionCRCList[i].second) + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
|
static const string ITEM_MISSING = "***missing***";
|
||||||
|
|
||||||
using namespace Shared::Util;
|
using namespace Shared::Util;
|
||||||
|
|
||||||
struct FormatString {
|
struct FormatString {
|
||||||
|
@ -987,8 +989,9 @@ void MenuStateConnectedGame::update() {
|
||||||
MutexSafeWrapper safeMutexFTPProgress(ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
MutexSafeWrapper safeMutexFTPProgress(ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
int32 tilesetCRC = lastCheckedCRCTilesetValue;
|
int32 tilesetCRC = lastCheckedCRCTilesetValue;
|
||||||
if(lastCheckedCRCTilesetName != gameSettings->getTileset()) {
|
if(lastCheckedCRCTilesetName != gameSettings->getTileset() &&
|
||||||
console.addLine("Checking tileset CRC " + gameSettings->getTileset() + "]");
|
gameSettings->getTileset() != "") {
|
||||||
|
console.addLine("Checking tileset CRC [" + gameSettings->getTileset() + "]");
|
||||||
tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL);
|
tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL);
|
||||||
// Test data synch
|
// Test data synch
|
||||||
//tilesetCRC++;
|
//tilesetCRC++;
|
||||||
|
@ -997,20 +1000,31 @@ void MenuStateConnectedGame::update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 techCRC = lastCheckedCRCTechtreeValue;
|
int32 techCRC = lastCheckedCRCTechtreeValue;
|
||||||
if(lastCheckedCRCTechtreeName != gameSettings->getTech()) {
|
if(lastCheckedCRCTechtreeName != gameSettings->getTech() &&
|
||||||
console.addLine("Checking techtree CRC " + gameSettings->getTech() + "]");
|
gameSettings->getTech() != "") {
|
||||||
|
console.addLine("Checking techtree CRC [" + gameSettings->getTech() + "]");
|
||||||
techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), string("/") + gameSettings->getTech() + string("/*"), ".xml", NULL);
|
techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), string("/") + gameSettings->getTech() + string("/*"), ".xml", NULL);
|
||||||
// Test data synch
|
// Test data synch
|
||||||
//techCRC++;
|
//techCRC++;
|
||||||
lastCheckedCRCTechtreeValue = techCRC;
|
lastCheckedCRCTechtreeValue = techCRC;
|
||||||
lastCheckedCRCTechtreeName = gameSettings->getTech();
|
lastCheckedCRCTechtreeName = gameSettings->getTech();
|
||||||
|
|
||||||
|
loadFactions(gameSettings,false);
|
||||||
|
factionCRCList.clear();
|
||||||
|
for(unsigned int factionIdx = 0; factionIdx < factionFiles.size(); ++factionIdx) {
|
||||||
|
string factionName = factionFiles[factionIdx];
|
||||||
|
int32 factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
|
||||||
|
factionCRCList.push_back(make_pair(factionName,factionCRC));
|
||||||
|
}
|
||||||
|
console.addLine("Found factions: " + intToStr(factionCRCList.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 mapCRC = lastCheckedCRCMapValue;
|
int32 mapCRC = lastCheckedCRCMapValue;
|
||||||
if(lastCheckedCRCMapName != gameSettings->getMap()) {
|
if(lastCheckedCRCMapName != gameSettings->getMap() &&
|
||||||
|
gameSettings->getMap() != "") {
|
||||||
Checksum checksum;
|
Checksum checksum;
|
||||||
string file = Map::getMapPath(gameSettings->getMap(),"",false);
|
string file = Map::getMapPath(gameSettings->getMap(),"",false);
|
||||||
console.addLine("Checking map CRC " + file + "]");
|
console.addLine("Checking map CRC [" + file + "]");
|
||||||
checksum.addFile(file);
|
checksum.addFile(file);
|
||||||
mapCRC = checksum.getSum();
|
mapCRC = checksum.getSum();
|
||||||
// Test data synch
|
// Test data synch
|
||||||
|
@ -1030,7 +1044,7 @@ void MenuStateConnectedGame::update() {
|
||||||
if(dataSynchMismatch == true) {
|
if(dataSynchMismatch == true) {
|
||||||
string labelSynch = lang.get("DataNotSynchedTitle");
|
string labelSynch = lang.get("DataNotSynchedTitle");
|
||||||
|
|
||||||
if(mapCRC != 0 && mapCRC != gameSettings->getMapCRC()) {
|
if(mapCRC != 0 && mapCRC != gameSettings->getMapCRC() && listBoxMap.getSelectedItem() != ITEM_MISSING) {
|
||||||
labelSynch = labelSynch + " " + lang.get("Map");
|
labelSynch = labelSynch + " " + lang.get("Map");
|
||||||
|
|
||||||
if(updateDataSynchDetailText == true &&
|
if(updateDataSynchDetailText == true &&
|
||||||
|
@ -1040,7 +1054,7 @@ void MenuStateConnectedGame::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tilesetCRC != 0 && tilesetCRC != gameSettings->getTilesetCRC()) {
|
if(tilesetCRC != 0 && tilesetCRC != gameSettings->getTilesetCRC() && listBoxTileset.getSelectedItem() != ITEM_MISSING) {
|
||||||
labelSynch = labelSynch + " " + lang.get("Tileset");
|
labelSynch = labelSynch + " " + lang.get("Tileset");
|
||||||
if(updateDataSynchDetailText == true &&
|
if(updateDataSynchDetailText == true &&
|
||||||
lastTileDataSynchError != lang.get("DataNotSynchedTileset") + " " + listBoxTileset.getSelectedItem()) {
|
lastTileDataSynchError != lang.get("DataNotSynchedTileset") + " " + listBoxTileset.getSelectedItem()) {
|
||||||
|
@ -1049,37 +1063,69 @@ void MenuStateConnectedGame::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(techCRC != 0 && techCRC != gameSettings->getTechCRC()) {
|
if(techCRC != 0 && techCRC != gameSettings->getTechCRC() && listBoxTechTree.getSelectedItem() != ITEM_MISSING) {
|
||||||
labelSynch = labelSynch + " " + lang.get("TechTree");
|
labelSynch = labelSynch + " " + lang.get("TechTree");
|
||||||
if(updateDataSynchDetailText == true &&
|
if(updateDataSynchDetailText == true &&
|
||||||
lastTechtreeDataSynchError != lang.get("DataNotSynchedTechtree") + " " + listBoxTechTree.getSelectedItem()) {
|
lastTechtreeDataSynchError != lang.get("DataNotSynchedTechtree") + " " + listBoxTechTree.getSelectedItem()) {
|
||||||
lastTechtreeDataSynchError = lang.get("DataNotSynchedTechtree") + " " + listBoxTechTree.getSelectedItem();
|
lastTechtreeDataSynchError = lang.get("DataNotSynchedTechtree") + " " + listBoxTechTree.getSelectedItem();
|
||||||
clientInterface->sendTextMessage(lastTechtreeDataSynchError,-1,true);
|
clientInterface->sendTextMessage(lastTechtreeDataSynchError,-1,true);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
string mismatchedFactionText = "";
|
||||||
if(clientInterface->getNetworkGameDataSynchCheckOkTech() == false) {
|
vector<pair<string,int32> > serverFactionCRCList = gameSettings->getFactionCRCList();
|
||||||
labelSynch = labelSynch + " techtree";
|
|
||||||
|
|
||||||
if(updateDataSynchDetailText == true) {
|
for(unsigned int factionIdx = 0; factionIdx < serverFactionCRCList.size(); ++factionIdx) {
|
||||||
|
pair<string,int32> &serverFaction = serverFactionCRCList[factionIdx];
|
||||||
|
|
||||||
string report = clientInterface->getNetworkGameDataSynchCheckTechMismatchReport();
|
bool foundFaction = false;
|
||||||
if(lastTechtreeDataSynchError != "techtree CRC mismatch" + report) {
|
for(unsigned int clientFactionIdx = 0; clientFactionIdx < factionCRCList.size(); ++clientFactionIdx) {
|
||||||
lastTechtreeDataSynchError = "techtree CRC mismatch" + report;
|
pair<string,int32> &clientFaction = factionCRCList[clientFactionIdx];
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] report: %s\n",__FILE__,__FUNCTION__,__LINE__,report.c_str());
|
if(serverFaction.first == clientFaction.first) {
|
||||||
|
foundFaction = true;
|
||||||
|
if(serverFaction.second != clientFaction.second) {
|
||||||
|
if(mismatchedFactionText == "") {
|
||||||
|
mismatchedFactionText = "The following factions are mismatched: [" + intToStr(factionCRCList.size()) + "][" + intToStr(serverFactionCRCList.size()) + "] - ";
|
||||||
|
}
|
||||||
|
mismatchedFactionText += serverFaction.first + ", ";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clientInterface->sendTextMessage("techtree CRC mismatch",-1,true);
|
if(foundFaction == false) {
|
||||||
vector<string> reportLineTokens;
|
if(mismatchedFactionText == "") {
|
||||||
Tokenize(report,reportLineTokens,"\n");
|
mismatchedFactionText = "The following factions are mismatched: [" + intToStr(factionCRCList.size()) + "][" + intToStr(serverFactionCRCList.size()) + "] - ";
|
||||||
for(int reportLine = 0; reportLine < reportLineTokens.size(); ++reportLine) {
|
}
|
||||||
clientInterface->sendTextMessage(reportLineTokens[reportLine],-1,true);
|
mismatchedFactionText += serverFaction.first + " (missing), ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(unsigned int clientFactionIdx = 0; clientFactionIdx < factionCRCList.size(); ++clientFactionIdx) {
|
||||||
|
pair<string,int32> &clientFaction = factionCRCList[clientFactionIdx];
|
||||||
|
|
||||||
|
bool foundFaction = false;
|
||||||
|
for(unsigned int factionIdx = 0; factionIdx < serverFactionCRCList.size(); ++factionIdx) {
|
||||||
|
pair<string,int32> &serverFaction = serverFactionCRCList[factionIdx];
|
||||||
|
|
||||||
|
if(serverFaction.first == clientFaction.first) {
|
||||||
|
foundFaction = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(foundFaction == false) {
|
||||||
|
if(mismatchedFactionText == "") {
|
||||||
|
mismatchedFactionText = "The following factions are mismatched: [" + intToStr(factionCRCList.size()) + "][" + intToStr(serverFactionCRCList.size()) + "] - ";
|
||||||
|
}
|
||||||
|
mismatchedFactionText += clientFaction.first + " (extra), ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mismatchedFactionText != "") {
|
||||||
|
clientInterface->sendTextMessage(mismatchedFactionText,-1,true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
//if(clientInterface->getReceivedDataSynchCheck() == true) {
|
//if(clientInterface->getReceivedDataSynchCheck() == true) {
|
||||||
updateDataSynchDetailText = false;
|
updateDataSynchDetailText = false;
|
||||||
|
@ -1241,11 +1287,12 @@ void MenuStateConnectedGame::update() {
|
||||||
throw runtime_error("gameSettings == NULL");
|
throw runtime_error("gameSettings == NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getMissingTilesetFromFTPServerInProgress == false) {
|
if(getMissingTilesetFromFTPServerInProgress == false &&
|
||||||
|
gameSettings->getTileset() != "") {
|
||||||
// tileset
|
// tileset
|
||||||
if(std::find(tilesetFiles.begin(),tilesetFiles.end(),gameSettings->getTileset()) != tilesetFiles.end()) {
|
if(std::find(tilesetFiles.begin(),tilesetFiles.end(),gameSettings->getTileset()) != tilesetFiles.end()) {
|
||||||
lastMissingTileSet = "";
|
lastMissingTileSet = "";
|
||||||
|
getMissingTilesetFromFTPServer = "";
|
||||||
tilesets.push_back(formatString(gameSettings->getTileset()));
|
tilesets.push_back(formatString(gameSettings->getTileset()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1263,7 +1310,7 @@ void MenuStateConnectedGame::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tilesets.push_back("***missing***");
|
tilesets.push_back(ITEM_MISSING);
|
||||||
|
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
ClientInterface* clientInterface= networkManager.getClientInterface();
|
||||||
|
@ -1287,11 +1334,12 @@ void MenuStateConnectedGame::update() {
|
||||||
listBoxTileset.setItems(tilesets);
|
listBoxTileset.setItems(tilesets);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getMissingTechtreeFromFTPServerInProgress == false) {
|
if(getMissingTechtreeFromFTPServerInProgress == false &&
|
||||||
|
gameSettings->getTech() != "") {
|
||||||
// techtree
|
// techtree
|
||||||
if(std::find(techTreeFiles.begin(),techTreeFiles.end(),gameSettings->getTech()) != techTreeFiles.end()) {
|
if(std::find(techTreeFiles.begin(),techTreeFiles.end(),gameSettings->getTech()) != techTreeFiles.end()) {
|
||||||
lastMissingTechtree = "";
|
lastMissingTechtree = "";
|
||||||
|
getMissingTechtreeFromFTPServer = "";
|
||||||
techtree.push_back(formatString(gameSettings->getTech()));
|
techtree.push_back(formatString(gameSettings->getTech()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1309,7 +1357,7 @@ void MenuStateConnectedGame::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
techtree.push_back("***missing***");
|
techtree.push_back(ITEM_MISSING);
|
||||||
|
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
ClientInterface* clientInterface= networkManager.getClientInterface();
|
||||||
|
@ -1339,20 +1387,21 @@ void MenuStateConnectedGame::update() {
|
||||||
|
|
||||||
// factions
|
// factions
|
||||||
bool hasFactions = true;
|
bool hasFactions = true;
|
||||||
if(currentFactionName != gameSettings->getTech())
|
if(currentFactionName != gameSettings->getTech()
|
||||||
{
|
&& gameSettings->getTech() != "") {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] hasFactions = %d, currentFactionName [%s]\n",__FILE__,__FUNCTION__,__LINE__,hasFactions,currentFactionName.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] hasFactions = %d, currentFactionName [%s]\n",__FILE__,__FUNCTION__,__LINE__,hasFactions,currentFactionName.c_str());
|
||||||
currentFactionName = gameSettings->getTech();
|
currentFactionName = gameSettings->getTech();
|
||||||
hasFactions = loadFactions(gameSettings,false);
|
hasFactions = loadFactions(gameSettings,false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// do this to process special faction types liek observers
|
// do this to process special faction types like observers
|
||||||
loadFactions(gameSettings,false);
|
loadFactions(gameSettings,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] hasFactions = %d, currentFactionName [%s]\n",__FILE__,__FUNCTION__,__LINE__,hasFactions,currentFactionName.c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] hasFactions = %d, currentFactionName [%s]\n",__FILE__,__FUNCTION__,__LINE__,hasFactions,currentFactionName.c_str());
|
||||||
|
|
||||||
if(getMissingMapFromFTPServerInProgress == false) {
|
if(getMissingMapFromFTPServerInProgress == false &&
|
||||||
|
gameSettings->getMap() != "") {
|
||||||
// map
|
// map
|
||||||
if(currentMap != gameSettings->getMap()) {// load the setup again
|
if(currentMap != gameSettings->getMap()) {// load the setup again
|
||||||
currentMap = gameSettings->getMap();
|
currentMap = gameSettings->getMap();
|
||||||
|
@ -1376,7 +1425,7 @@ void MenuStateConnectedGame::update() {
|
||||||
showFTPMessageBox(szBuf, lang.get("Question"), false);
|
showFTPMessageBox(szBuf, lang.get("Question"), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maps.push_back("***missing***");
|
maps.push_back(ITEM_MISSING);
|
||||||
}
|
}
|
||||||
listBoxMap.setItems(maps);
|
listBoxMap.setItems(maps);
|
||||||
labelMapInfo.setText(mapInfo.desc);
|
labelMapInfo.setText(mapInfo.desc);
|
||||||
|
@ -1442,11 +1491,7 @@ void MenuStateConnectedGame::update() {
|
||||||
labelPlayerStatus[i].setText("");
|
labelPlayerStatus[i].setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
if(hasFactions == true) {
|
if(hasFactions == true) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] errorOnMissingData = %d\n",__FILE__,__FUNCTION__,__LINE__,errorOnMissingData);
|
|
||||||
|
|
||||||
for(int i=0; i<gameSettings->getFactionCount(); ++i){
|
for(int i=0; i<gameSettings->getFactionCount(); ++i){
|
||||||
int slot = gameSettings->getStartLocationIndex(i);
|
int slot = gameSettings->getStartLocationIndex(i);
|
||||||
|
|
||||||
|
@ -1639,75 +1684,79 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
|
||||||
|
|
||||||
bool foundFactions = false;
|
bool foundFactions = false;
|
||||||
vector<string> results;
|
vector<string> results;
|
||||||
Config &config = Config::getInstance();
|
|
||||||
Lang &lang= Lang::getInstance();
|
|
||||||
|
|
||||||
vector<string> techPaths = config.getPathListForType(ptTechs);
|
if(gameSettings->getTech() != "") {
|
||||||
for(int idx = 0; idx < techPaths.size(); idx++) {
|
Config &config = Config::getInstance();
|
||||||
string &techPath = techPaths[idx];
|
Lang &lang= Lang::getInstance();
|
||||||
endPathWithSlash(techPath);
|
|
||||||
findAll(techPath + gameSettings->getTech() + "/factions/*.", results, false, false);
|
|
||||||
if(results.size() > 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(results.size() == 0) {
|
vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
for(int idx = 0; idx < techPaths.size(); idx++) {
|
||||||
|
string &techPath = techPaths[idx];
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
endPathWithSlash(techPath);
|
||||||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
findAll(techPath + gameSettings->getTech() + "/factions/*.", results, false, false);
|
||||||
if(clientInterface->getAllowGameDataSynchCheck() == false) {
|
if(results.size() > 0) {
|
||||||
if(errorOnNoFactions == true) {
|
break;
|
||||||
throw runtime_error("(2)There are no factions for the tech tree [" + gameSettings->getTech() + "]");
|
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (2)There are no factions for the tech tree [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameSettings->getTech().c_str());
|
|
||||||
}
|
|
||||||
results.push_back("***missing***");
|
|
||||||
factionFiles = results;
|
|
||||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
|
||||||
listBoxFactions[i].setItems(results);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lastMissingTechtree != gameSettings->getTech()) {
|
if(results.size() == 0) {
|
||||||
lastMissingTechtree = gameSettings->getTech();
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
char szMsg[1024]="";
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
if(lang.hasString("DataMissingTechtree") == true) {
|
ClientInterface* clientInterface= networkManager.getClientInterface();
|
||||||
sprintf(szMsg,lang.get("DataMissingTechtree").c_str(),getHumanPlayerName().c_str(),gameSettings->getTech().c_str());
|
if(clientInterface->getAllowGameDataSynchCheck() == false) {
|
||||||
}
|
if(errorOnNoFactions == true) {
|
||||||
else {
|
throw runtime_error("(2)There are no factions for the tech tree [" + gameSettings->getTech() + "]");
|
||||||
sprintf(szMsg,"Player: %s is missing the techtree: %s",getHumanPlayerName().c_str(),gameSettings->getTech().c_str());
|
}
|
||||||
}
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (2)There are no factions for the tech tree [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameSettings->getTech().c_str());
|
||||||
clientInterface->sendTextMessage(szMsg,-1, true);
|
}
|
||||||
|
results.push_back(ITEM_MISSING);
|
||||||
|
factionFiles = results;
|
||||||
|
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||||
|
listBoxFactions[i].setItems(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lastMissingTechtree != gameSettings->getTech() &&
|
||||||
|
gameSettings->getTech() != "") {
|
||||||
|
lastMissingTechtree = gameSettings->getTech();
|
||||||
|
|
||||||
|
char szMsg[1024]="";
|
||||||
|
if(lang.hasString("DataMissingTechtree") == true) {
|
||||||
|
sprintf(szMsg,lang.get("DataMissingTechtree").c_str(),getHumanPlayerName().c_str(),gameSettings->getTech().c_str());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sprintf(szMsg,"Player: %s is missing the techtree: %s",getHumanPlayerName().c_str(),gameSettings->getTech().c_str());
|
||||||
|
}
|
||||||
|
clientInterface->sendTextMessage(szMsg,-1, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
foundFactions = false;
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
lastMissingTechtree = "";
|
||||||
|
getMissingTechtreeFromFTPServer = "";
|
||||||
|
// Add special Observer Faction
|
||||||
|
//Lang &lang= Lang::getInstance();
|
||||||
|
if(gameSettings->getAllowObservers() == true) {
|
||||||
|
results.push_back(formatString(GameConstants::OBSERVER_SLOTNAME));
|
||||||
|
}
|
||||||
|
results.push_back(formatString(GameConstants::RANDOMFACTION_SLOTNAME));
|
||||||
|
|
||||||
foundFactions = false;
|
factionFiles= results;
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
for(int i= 0; i<results.size(); ++i){
|
||||||
}
|
results[i]= formatString(results[i]);
|
||||||
else {
|
|
||||||
lastMissingTechtree = "";
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"Tech [%s] has faction [%s]\n",gameSettings->getTech().c_str(),results[i].c_str());
|
||||||
// Add special Observer Faction
|
}
|
||||||
//Lang &lang= Lang::getInstance();
|
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||||
if(gameSettings->getAllowObservers() == true) {
|
listBoxFactions[i].setItems(results);
|
||||||
results.push_back(formatString(GameConstants::OBSERVER_SLOTNAME));
|
}
|
||||||
|
|
||||||
|
foundFactions = (results.size() > 0);
|
||||||
}
|
}
|
||||||
results.push_back(formatString(GameConstants::RANDOMFACTION_SLOTNAME));
|
|
||||||
|
|
||||||
factionFiles= results;
|
|
||||||
for(int i= 0; i<results.size(); ++i){
|
|
||||||
results[i]= formatString(results[i]);
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"Tech [%s] has faction [%s]\n",gameSettings->getTech().c_str(),results[i].c_str());
|
|
||||||
}
|
|
||||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
|
||||||
listBoxFactions[i].setItems(results);
|
|
||||||
}
|
|
||||||
|
|
||||||
foundFactions = (results.size() > 0);
|
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
return foundFactions;
|
return foundFactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1936,7 +1985,7 @@ bool MenuStateConnectedGame::loadMapInfo(string file, MapInfo *mapInfo, bool loa
|
||||||
mapLoaded = true;
|
mapLoaded = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mapInfo->desc = "***missing***";
|
mapInfo->desc = ITEM_MISSING;
|
||||||
|
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
ClientInterface* clientInterface= networkManager.getClientInterface();
|
||||||
|
|
|
@ -164,6 +164,7 @@ private:
|
||||||
int32 lastCheckedCRCTilesetValue;
|
int32 lastCheckedCRCTilesetValue;
|
||||||
int32 lastCheckedCRCTechtreeValue;
|
int32 lastCheckedCRCTechtreeValue;
|
||||||
int32 lastCheckedCRCMapValue;
|
int32 lastCheckedCRCMapValue;
|
||||||
|
vector<pair<string,int32> > factionCRCList;
|
||||||
|
|
||||||
std::map<string,pair<int,string> > fileFTPProgressList;
|
std::map<string,pair<int,string> > fileFTPProgressList;
|
||||||
|
|
||||||
|
|
|
@ -881,9 +881,6 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
updateResourceMultiplier(i);
|
updateResourceMultiplier(i);
|
||||||
}
|
}
|
||||||
else if(listBoxFactions[i].mouseClick(x, y)) {
|
else if(listBoxFactions[i].mouseClick(x, y)) {
|
||||||
|
|
||||||
//printf("factionFiles[listBoxFactions[i].getSelectedItemIndex()] [%s] i = %d selIndex = %d\n",factionFiles[listBoxFactions[i].getSelectedItemIndex()].c_str(),i,listBoxFactions[i].getSelectedItemIndex());
|
|
||||||
|
|
||||||
// Disallow CPU players to be observers
|
// Disallow CPU players to be observers
|
||||||
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] == formatString(GameConstants::OBSERVER_SLOTNAME) &&
|
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] == formatString(GameConstants::OBSERVER_SLOTNAME) &&
|
||||||
(listBoxControls[i].getSelectedItemIndex() == ctCpuEasy || listBoxControls[i].getSelectedItemIndex() == ctCpu ||
|
(listBoxControls[i].getSelectedItemIndex() == ctCpuEasy || listBoxControls[i].getSelectedItemIndex() == ctCpu ||
|
||||||
|
@ -905,7 +902,6 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
else if(listBoxTeams[i].mouseClick(x, y))
|
else if(listBoxTeams[i].mouseClick(x, y))
|
||||||
{
|
{
|
||||||
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] != formatString(GameConstants::OBSERVER_SLOTNAME)) {
|
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] != formatString(GameConstants::OBSERVER_SLOTNAME)) {
|
||||||
//printf("i = %d factionFiles[listBoxFactions[i].getSelectedItemIndex()] [%s] listBoxTeams[i].getSelectedItemIndex() = %d, lastSelectedTeamIndex[i] = %d\n",i,factionFiles[listBoxFactions[i].getSelectedItemIndex()].c_str(),listBoxTeams[i].getSelectedItemIndex(),lastSelectedTeamIndex[i]);
|
|
||||||
if(listBoxTeams[i].getSelectedItemIndex() + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
if(listBoxTeams[i].getSelectedItemIndex() + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
||||||
lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
||||||
}
|
}
|
||||||
|
@ -2230,7 +2226,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
||||||
|
|
||||||
if( gameSettings->getTileset() != "") {
|
if( gameSettings->getTileset() != "") {
|
||||||
if(lastCheckedCRCTilesetName != gameSettings->getTileset()) {
|
if(lastCheckedCRCTilesetName != gameSettings->getTileset()) {
|
||||||
console.addLine("Checking tileset CRC " + gameSettings->getTileset() + "]");
|
console.addLine("Checking tileset CRC [" + gameSettings->getTileset() + "]");
|
||||||
lastCheckedCRCTilesetValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL);
|
lastCheckedCRCTilesetValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL);
|
||||||
lastCheckedCRCTilesetName = gameSettings->getTileset();
|
lastCheckedCRCTilesetName = gameSettings->getTileset();
|
||||||
}
|
}
|
||||||
|
@ -2240,10 +2236,21 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
||||||
if(config.getBool("DisableServerLobbyTechtreeCRCCheck","false") == false) {
|
if(config.getBool("DisableServerLobbyTechtreeCRCCheck","false") == false) {
|
||||||
if(gameSettings->getTech() != "") {
|
if(gameSettings->getTech() != "") {
|
||||||
if(lastCheckedCRCTechtreeName != gameSettings->getTech()) {
|
if(lastCheckedCRCTechtreeName != gameSettings->getTech()) {
|
||||||
console.addLine("Checking techtree CRC " + gameSettings->getTech() + "]");
|
console.addLine("Checking techtree CRC [" + gameSettings->getTech() + "]");
|
||||||
lastCheckedCRCTechtreeValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/*", ".xml", NULL);
|
lastCheckedCRCTechtreeValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/*", ".xml", NULL);
|
||||||
|
|
||||||
|
reloadFactions(true);
|
||||||
|
factionCRCList.clear();
|
||||||
|
for(unsigned int factionIdx = 0; factionIdx < factionFiles.size(); ++factionIdx) {
|
||||||
|
string factionName = factionFiles[factionIdx];
|
||||||
|
int32 factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
|
||||||
|
factionCRCList.push_back(make_pair(factionName,factionCRC));
|
||||||
|
}
|
||||||
|
console.addLine("Found factions: " + intToStr(factionCRCList.size()));
|
||||||
lastCheckedCRCTechtreeName = gameSettings->getTech();
|
lastCheckedCRCTechtreeName = gameSettings->getTech();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gameSettings->setFactionCRCList(factionCRCList);
|
||||||
gameSettings->setTechCRC(lastCheckedCRCTechtreeValue);
|
gameSettings->setTechCRC(lastCheckedCRCTechtreeValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2252,7 +2259,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
||||||
if(lastCheckedCRCMapName != gameSettings->getMap()) {
|
if(lastCheckedCRCMapName != gameSettings->getMap()) {
|
||||||
Checksum checksum;
|
Checksum checksum;
|
||||||
string file = Map::getMapPath(gameSettings->getMap(),"",false);
|
string file = Map::getMapPath(gameSettings->getMap(),"",false);
|
||||||
console.addLine("Checking map CRC " + file + "]");
|
console.addLine("Checking map CRC [" + file + "]");
|
||||||
checksum.addFile(file);
|
checksum.addFile(file);
|
||||||
lastCheckedCRCMapValue = checksum.getSum();
|
lastCheckedCRCMapValue = checksum.getSum();
|
||||||
lastCheckedCRCMapName = gameSettings->getMap();
|
lastCheckedCRCMapName = gameSettings->getMap();
|
||||||
|
|
|
@ -107,9 +107,6 @@ private:
|
||||||
bool needToBroadcastServerSettings;
|
bool needToBroadcastServerSettings;
|
||||||
std::map<string,string> publishToServerInfo;
|
std::map<string,string> publishToServerInfo;
|
||||||
SimpleTaskThread *publishToMasterserverThread;
|
SimpleTaskThread *publishToMasterserverThread;
|
||||||
//Mutex masterServerThreadAccessor;
|
|
||||||
//Mutex publishToMasterserverThreadPtrChangeAccessor;
|
|
||||||
//bool publishToMasterserverThreadInDeletion;
|
|
||||||
|
|
||||||
bool parentMenuIsMs;
|
bool parentMenuIsMs;
|
||||||
int soundConnectionCount;
|
int soundConnectionCount;
|
||||||
|
@ -154,6 +151,7 @@ private:
|
||||||
int32 lastCheckedCRCTilesetValue;
|
int32 lastCheckedCRCTilesetValue;
|
||||||
int32 lastCheckedCRCTechtreeValue;
|
int32 lastCheckedCRCTechtreeValue;
|
||||||
int32 lastCheckedCRCMapValue;
|
int32 lastCheckedCRCMapValue;
|
||||||
|
vector<pair<string,int32> > factionCRCList;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,bool openNetworkSlots= false, bool parentMenuIsMasterserver=false, bool autostart=false);
|
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,bool openNetworkSlots= false, bool parentMenuIsMasterserver=false, bool autostart=false);
|
||||||
|
|
|
@ -202,6 +202,10 @@ void NetworkMessageReady::send(Socket* socket) const {
|
||||||
|
|
||||||
NetworkMessageLaunch::NetworkMessageLaunch() {
|
NetworkMessageLaunch::NetworkMessageLaunch() {
|
||||||
data.messageType=-1;
|
data.messageType=-1;
|
||||||
|
for(unsigned int i = 0; i < maxFactionCRCCount; ++i) {
|
||||||
|
data.factionNameList[i] = "";
|
||||||
|
data.factionCRCList[i] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8 messageType) {
|
NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8 messageType) {
|
||||||
|
@ -211,6 +215,17 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
|
||||||
data.tilesetCRC = gameSettings->getTilesetCRC();
|
data.tilesetCRC = gameSettings->getTilesetCRC();
|
||||||
data.techCRC = gameSettings->getTechCRC();
|
data.techCRC = gameSettings->getTechCRC();
|
||||||
|
|
||||||
|
for(unsigned int i = 0; i < maxFactionCRCCount; ++i) {
|
||||||
|
data.factionNameList[i] = "";
|
||||||
|
data.factionCRCList[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<pair<string,int32> > factionCRCList = gameSettings->getFactionCRCList();
|
||||||
|
for(unsigned int i = 0; i < factionCRCList.size() && i < maxFactionCRCCount; ++i) {
|
||||||
|
data.factionNameList[i] = factionCRCList[i].first;
|
||||||
|
data.factionCRCList[i] = factionCRCList[i].second;
|
||||||
|
}
|
||||||
|
|
||||||
data.description= gameSettings->getDescription();
|
data.description= gameSettings->getDescription();
|
||||||
data.map= gameSettings->getMap();
|
data.map= gameSettings->getMap();
|
||||||
data.tileset= gameSettings->getTileset();
|
data.tileset= gameSettings->getTileset();
|
||||||
|
@ -264,7 +279,15 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const {
|
||||||
gameSettings->setTilesetCRC(data.tilesetCRC);
|
gameSettings->setTilesetCRC(data.tilesetCRC);
|
||||||
gameSettings->setTechCRC(data.techCRC);
|
gameSettings->setTechCRC(data.techCRC);
|
||||||
|
|
||||||
for(int i= 0; i<data.factionCount; ++i) {
|
vector<pair<string,int32> > factionCRCList;
|
||||||
|
for(unsigned int i = 0; i < maxFactionCRCCount; ++i) {
|
||||||
|
if(data.factionNameList[i].getString() != "") {
|
||||||
|
factionCRCList.push_back(make_pair(data.factionNameList[i].getString(),data.factionCRCList[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gameSettings->setFactionCRCList(factionCRCList);
|
||||||
|
|
||||||
|
for(int i= 0; i < data.factionCount; ++i) {
|
||||||
gameSettings->setFactionTypeName(i, data.factionTypeNames[i].getString());
|
gameSettings->setFactionTypeName(i, data.factionTypeNames[i].getString());
|
||||||
gameSettings->setNetworkPlayerName(i,data.networkPlayerNames[i].getString());
|
gameSettings->setNetworkPlayerName(i,data.networkPlayerNames[i].getString());
|
||||||
gameSettings->setNetworkPlayerStatuses(i, data.networkPlayerStatuses[i]);
|
gameSettings->setNetworkPlayerStatuses(i, data.networkPlayerStatuses[i]);
|
||||||
|
@ -275,16 +298,30 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<pair<string,int32> > NetworkMessageLaunch::getFactionCRCList() const {
|
||||||
|
|
||||||
|
vector<pair<string,int32> > factionCRCList;
|
||||||
|
for(unsigned int i = 0; i < maxFactionCRCCount; ++i) {
|
||||||
|
if(data.factionNameList[i].getString() != "") {
|
||||||
|
factionCRCList.push_back(make_pair(data.factionNameList[i].getString(),data.factionCRCList[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return factionCRCList;
|
||||||
|
}
|
||||||
|
|
||||||
bool NetworkMessageLaunch::receive(Socket* socket) {
|
bool NetworkMessageLaunch::receive(Socket* socket) {
|
||||||
bool result = NetworkMessage::receive(socket, &data, sizeof(data));
|
bool result = NetworkMessage::receive(socket, &data, sizeof(data));
|
||||||
data.description.nullTerminate();
|
data.description.nullTerminate();
|
||||||
data.map.nullTerminate();
|
data.map.nullTerminate();
|
||||||
data.tileset.nullTerminate();
|
data.tileset.nullTerminate();
|
||||||
data.tech.nullTerminate();
|
data.tech.nullTerminate();
|
||||||
for(int i= 0; i<GameConstants::maxPlayers; ++i){
|
for(int i= 0; i < GameConstants::maxPlayers; ++i){
|
||||||
data.factionTypeNames[i].nullTerminate();
|
data.factionTypeNames[i].nullTerminate();
|
||||||
data.networkPlayerNames[i].nullTerminate();
|
data.networkPlayerNames[i].nullTerminate();
|
||||||
}
|
}
|
||||||
|
for(unsigned int i = 0; i < maxFactionCRCCount; ++i) {
|
||||||
|
data.factionNameList[i].nullTerminate();
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,6 +187,7 @@ class NetworkMessageLaunch: public NetworkMessage {
|
||||||
private:
|
private:
|
||||||
static const int maxStringSize= 256;
|
static const int maxStringSize= 256;
|
||||||
static const int maxSmallStringSize= 60;
|
static const int maxSmallStringSize= 60;
|
||||||
|
static const int maxFactionCRCCount= 20;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Data{
|
struct Data{
|
||||||
|
@ -201,6 +202,8 @@ private:
|
||||||
int32 mapCRC;
|
int32 mapCRC;
|
||||||
int32 tilesetCRC;
|
int32 tilesetCRC;
|
||||||
int32 techCRC;
|
int32 techCRC;
|
||||||
|
NetworkString<maxSmallStringSize> factionNameList[maxFactionCRCCount];
|
||||||
|
int32 factionCRCList[maxFactionCRCCount];
|
||||||
|
|
||||||
int8 factionControls[GameConstants::maxPlayers];
|
int8 factionControls[GameConstants::maxPlayers];
|
||||||
int8 resourceMultiplierIndex[GameConstants::maxPlayers];
|
int8 resourceMultiplierIndex[GameConstants::maxPlayers];
|
||||||
|
@ -235,6 +238,7 @@ public:
|
||||||
int getMapCRC() const { return data.mapCRC; }
|
int getMapCRC() const { return data.mapCRC; }
|
||||||
int getTilesetCRC() const { return data.tilesetCRC; }
|
int getTilesetCRC() const { return data.tilesetCRC; }
|
||||||
int getTechCRC() const { return data.techCRC; }
|
int getTechCRC() const { return data.techCRC; }
|
||||||
|
vector<pair<string,int32> > getFactionCRCList() const;
|
||||||
|
|
||||||
virtual bool receive(Socket* socket);
|
virtual bool receive(Socket* socket);
|
||||||
virtual void send(Socket* socket) const;
|
virtual void send(Socket* socket) const;
|
||||||
|
|
|
@ -37,18 +37,18 @@ FactionThread::FactionThread(Faction *faction) : BaseThread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FactionThread::setQuitStatus(bool value) {
|
void FactionThread::setQuitStatus(bool value) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d value = %d\n",__FILE__,__FUNCTION__,__LINE__,value);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d value = %d\n",__FILE__,__FUNCTION__,__LINE__,value);
|
||||||
|
|
||||||
BaseThread::setQuitStatus(value);
|
BaseThread::setQuitStatus(value);
|
||||||
if(value == true) {
|
if(value == true) {
|
||||||
signalPathfinder(-1);
|
signalPathfinder(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FactionThread::signalPathfinder(int frameIndex) {
|
void FactionThread::signalPathfinder(int frameIndex) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] event = %p\n",__FILE__,__FUNCTION__,__LINE__,event);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] event = %p\n",__FILE__,__FUNCTION__,__LINE__,event);
|
||||||
|
|
||||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] frameIndex = %d this = %p\n",__FILE__,__FUNCTION__,__LINE__,frameIndex, this);
|
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] frameIndex = %d this = %p\n",__FILE__,__FUNCTION__,__LINE__,frameIndex, this);
|
||||||
|
|
||||||
|
@ -59,12 +59,12 @@ void FactionThread::signalPathfinder(int frameIndex) {
|
||||||
this->frameIndex.second = false;
|
this->frameIndex.second = false;
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
}
|
}
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
semTaskSignalled.signal();
|
semTaskSignalled.signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FactionThread::setTaskCompleted(int frameIndex) {
|
void FactionThread::setTaskCompleted(int frameIndex) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] frameIndex = %d this = %p\n",__FILE__,__FUNCTION__,__LINE__,frameIndex, this);
|
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] frameIndex = %d this = %p\n",__FILE__,__FUNCTION__,__LINE__,frameIndex, this);
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ void FactionThread::setTaskCompleted(int frameIndex) {
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FactionThread::canShutdown(bool deleteSelfIfShutdownDelayed) {
|
bool FactionThread::canShutdown(bool deleteSelfIfShutdownDelayed) {
|
||||||
|
@ -91,7 +91,7 @@ bool FactionThread::canShutdown(bool deleteSelfIfShutdownDelayed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FactionThread::isSignalPathfinderCompleted(int frameIndex) {
|
bool FactionThread::isSignalPathfinderCompleted(int frameIndex) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] slotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,slotIndex);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] slotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,slotIndex);
|
||||||
if(getRunningStatus() == false) {
|
if(getRunningStatus() == false) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ bool FactionThread::isSignalPathfinderCompleted(int frameIndex) {
|
||||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] worker thread this = %p, this->frameIndex.first = %d, this->frameIndex.second = %d\n",__FILE__,__FUNCTION__,__LINE__,this,this->frameIndex.first,this->frameIndex.second);
|
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] worker thread this = %p, this->frameIndex.first = %d, this->frameIndex.second = %d\n",__FILE__,__FUNCTION__,__LINE__,this,this->frameIndex.first,this->frameIndex.second);
|
||||||
|
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
//if(result == false) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] slotIndex = %d, result = %d\n",__FILE__,__FUNCTION__,__LINE__,slotIndex,result);
|
//if(result == false) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] slotIndex = %d, result = %d\n",__FILE__,__FUNCTION__,__LINE__,slotIndex,result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ void FactionThread::execute() {
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
semTaskSignalled.waitTillSignalled();
|
semTaskSignalled.waitTillSignalled();
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(getQuitStatus() == true) {
|
if(getQuitStatus() == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -141,7 +141,6 @@ void FactionThread::execute() {
|
||||||
|
|
||||||
if(executeTask == true) {
|
if(executeTask == true) {
|
||||||
ExecutingTaskSafeWrapper safeExecutingTaskMutex(this);
|
ExecutingTaskSafeWrapper safeExecutingTaskMutex(this);
|
||||||
//this->slotInterface->slotUpdateTask(&eventCopy);
|
|
||||||
|
|
||||||
World *world = faction->getWorld();
|
World *world = faction->getWorld();
|
||||||
int unitCount = faction->getUnitCount();
|
int unitCount = faction->getUnitCount();
|
||||||
|
@ -160,13 +159,13 @@ void FactionThread::execute() {
|
||||||
setTaskCompleted(frameIndex.first);
|
setTaskCompleted(frameIndex.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(getQuitStatus() == true) {
|
if(getQuitStatus() == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -180,7 +179,7 @@ void FactionThread::execute() {
|
||||||
|
|
||||||
throw runtime_error(ex.what());
|
throw runtime_error(ex.what());
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//setRunningStatus(false);
|
//setRunningStatus(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1116,64 +1116,51 @@ const CommandType *Unit::computeCommandType(const Vec2i &pos, const Unit *target
|
||||||
|
|
||||||
bool Unit::needToUpdate() {
|
bool Unit::needToUpdate() {
|
||||||
assert(progress <= 1.f);
|
assert(progress <= 1.f);
|
||||||
|
|
||||||
if(currSkill == NULL) {
|
if(currSkill == NULL) {
|
||||||
char szBuf[4096]="";
|
char szBuf[4096]="";
|
||||||
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
|
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
|
||||||
throw runtime_error(szBuf);
|
throw runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//speed
|
bool return_value = false;
|
||||||
int speed = currSkill->getTotalSpeed(&totalUpgrade);
|
if(currSkill->getClass() != scDie) {
|
||||||
|
//speed
|
||||||
|
int speed = currSkill->getTotalSpeed(&totalUpgrade);
|
||||||
|
|
||||||
//speed modifier
|
//speed modifier
|
||||||
float diagonalFactor= 1.f;
|
float diagonalFactor= 1.f;
|
||||||
float heightFactor= 1.f;
|
float heightFactor= 1.f;
|
||||||
if(currSkill->getClass() == scMove) {
|
if(currSkill->getClass() == scMove) {
|
||||||
//if moving in diagonal move slower
|
//if moving in diagonal move slower
|
||||||
Vec2i dest= pos-lastPos;
|
Vec2i dest= pos - lastPos;
|
||||||
if(abs(dest.x) + abs(dest.y) == 2) {
|
if(abs(dest.x) + abs(dest.y) == 2) {
|
||||||
diagonalFactor= 0.71f;
|
diagonalFactor = 0.71f;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if moving to an higher cell move slower else move faster
|
||||||
|
float heightDiff= map->getCell(pos)->getHeight() - map->getCell(targetPos)->getHeight();
|
||||||
|
heightFactor= clamp(1.f + heightDiff / 5.f, 0.2f, 5.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if movig to an higher cell move slower else move faster
|
//update progresses
|
||||||
float heightDiff= map->getCell(pos)->getHeight() - map->getCell(targetPos)->getHeight();
|
float newProgress = progress;
|
||||||
heightFactor= clamp(1.f + heightDiff / 5.f, 0.2f, 5.f);
|
const Game *game = Renderer::getInstance().getGame();
|
||||||
}
|
newProgress += (speed * diagonalFactor * heightFactor) / (speedDivider * game->getWorld()->getUpdateFps(this->getFactionIndex()));
|
||||||
|
|
||||||
//update progresses
|
if(newProgress >= 1.f) {
|
||||||
float newProgress = progress;
|
|
||||||
const Game *game = Renderer::getInstance().getGame();
|
|
||||||
newProgress += (speed * diagonalFactor * heightFactor) / (speedDivider * game->getWorld()->getUpdateFps(this->getFactionIndex()));
|
|
||||||
|
|
||||||
//checks
|
|
||||||
bool return_value = false;
|
|
||||||
//checks
|
|
||||||
if(newProgress >= 1.f) {
|
|
||||||
if(currSkill->getClass() != scDie) {
|
|
||||||
newProgress= 0.f;
|
|
||||||
return_value = true;
|
return_value = true;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
newProgress= 1.f;
|
|
||||||
int newDeadCount = deadCount;
|
|
||||||
newDeadCount++;
|
|
||||||
if(newDeadCount >= maxDeadCount) {
|
|
||||||
return_value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Unit::update() {
|
bool Unit::update() {
|
||||||
assert(progress<=1.f);
|
assert(progress <= 1.f);
|
||||||
|
|
||||||
//highlight
|
//highlight
|
||||||
if(highlight>0.f) {
|
if(highlight > 0.f) {
|
||||||
const Game *game = Renderer::getInstance().getGame();
|
const Game *game = Renderer::getInstance().getGame();
|
||||||
highlight-= 1.f / (highlightTime * game->getWorld()->getUpdateFps(this->getFactionIndex()));
|
highlight -= 1.f / (highlightTime * game->getWorld()->getUpdateFps(this->getFactionIndex()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currSkill == NULL) {
|
if(currSkill == NULL) {
|
||||||
|
@ -1186,22 +1173,20 @@ bool Unit::update() {
|
||||||
int speed= currSkill->getTotalSpeed(&totalUpgrade);
|
int speed= currSkill->getTotalSpeed(&totalUpgrade);
|
||||||
|
|
||||||
//speed modifier
|
//speed modifier
|
||||||
float diagonalFactor= 1.f;
|
float diagonalFactor = 1.f;
|
||||||
float heightFactor= 1.f;
|
float heightFactor = 1.f;
|
||||||
if(currSkill->getClass() == scMove) {
|
if(currSkill->getClass() == scMove) {
|
||||||
|
|
||||||
//if moving in diagonal move slower
|
//if moving in diagonal move slower
|
||||||
Vec2i dest= pos-lastPos;
|
Vec2i dest = pos - lastPos;
|
||||||
if(abs(dest.x)+abs(dest.y) == 2) {
|
if(abs(dest.x) + abs(dest.y) == 2) {
|
||||||
diagonalFactor= 0.71f;
|
diagonalFactor = 0.71f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if movig to an higher cell move slower else move faster
|
//if moving to an higher cell move slower else move faster
|
||||||
float heightDiff= map->getCell(pos)->getHeight() - map->getCell(targetPos)->getHeight();
|
float heightDiff = map->getCell(pos)->getHeight() - map->getCell(targetPos)->getHeight();
|
||||||
heightFactor= clamp(1.f+heightDiff/5.f, 0.2f, 5.f);
|
heightFactor = clamp(1.f + heightDiff / 5.f, 0.2f, 5.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//update progresses
|
//update progresses
|
||||||
lastAnimProgress= animProgress;
|
lastAnimProgress= animProgress;
|
||||||
const Game *game = Renderer::getInstance().getGame();
|
const Game *game = Renderer::getInstance().getGame();
|
||||||
|
@ -1214,13 +1199,13 @@ bool Unit::update() {
|
||||||
//rotation
|
//rotation
|
||||||
if(currSkill->getClass() != scStop) {
|
if(currSkill->getClass() != scStop) {
|
||||||
const int rotFactor= 2;
|
const int rotFactor= 2;
|
||||||
if(progress<1.f/rotFactor){
|
if(progress < 1.f / rotFactor) {
|
||||||
if(type->getFirstStOfClass(scMove)){
|
if(type->getFirstStOfClass(scMove)){
|
||||||
if(abs((int)(lastRotation-targetRotation)) < 180)
|
if(abs((int)(lastRotation-targetRotation)) < 180)
|
||||||
rotation= lastRotation+(targetRotation-lastRotation)*progress*rotFactor;
|
rotation= lastRotation + (targetRotation - lastRotation) * progress * rotFactor;
|
||||||
else{
|
else {
|
||||||
float rotationTerm= targetRotation>lastRotation? -360.f: +360.f;
|
float rotationTerm = targetRotation > lastRotation ? -360.f: +360.f;
|
||||||
rotation= lastRotation+(targetRotation-lastRotation+rotationTerm)*progress*rotFactor;
|
rotation = lastRotation + (targetRotation - lastRotation + rotationTerm) * progress * rotFactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1242,22 +1227,22 @@ bool Unit::update() {
|
||||||
(*it)->setRotation(getRotation());
|
(*it)->setRotation(getRotation());
|
||||||
}
|
}
|
||||||
//checks
|
//checks
|
||||||
if(animProgress>1.f) {
|
if(animProgress > 1.f) {
|
||||||
animProgress= currSkill->getClass()==scDie? 1.f: 0.f;
|
animProgress = currSkill->getClass() == scDie? 1.f: 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool return_value = false;
|
bool return_value = false;
|
||||||
//checks
|
//checks
|
||||||
if(progress>=1.f) {
|
if(progress >= 1.f) {
|
||||||
lastRotation= targetRotation;
|
lastRotation= targetRotation;
|
||||||
if(currSkill->getClass() != scDie) {
|
if(currSkill->getClass() != scDie) {
|
||||||
progress= 0.f;
|
progress = 0.f;
|
||||||
return_value = true;
|
return_value = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
progress= 1.f;
|
progress= 1.f;
|
||||||
deadCount++;
|
deadCount++;
|
||||||
if(deadCount>=maxDeadCount) {
|
if(deadCount >= maxDeadCount) {
|
||||||
toBeUndertaken= true;
|
toBeUndertaken= true;
|
||||||
return_value = false;
|
return_value = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,11 +120,11 @@ void setCRCCacheFilePath(string path);
|
||||||
|
|
||||||
std::pair<string,string> getFolderTreeContentsCheckSumCacheKey(vector<string> paths, string pathSearchString, const string filterFileExt);
|
std::pair<string,string> getFolderTreeContentsCheckSumCacheKey(vector<string> paths, string pathSearchString, const string filterFileExt);
|
||||||
void clearFolderTreeContentsCheckSum(vector<string> paths, string pathSearchString, const string filterFileExt);
|
void clearFolderTreeContentsCheckSum(vector<string> paths, string pathSearchString, const string filterFileExt);
|
||||||
int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string pathSearchString, const string filterFileExt, Checksum *recursiveChecksum);
|
int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string pathSearchString, const string filterFileExt, Checksum *recursiveChecksum,bool forceNoCache=false);
|
||||||
|
|
||||||
std::pair<string,string> getFolderTreeContentsCheckSumCacheKey(const string &path, const string filterFileExt);
|
std::pair<string,string> getFolderTreeContentsCheckSumCacheKey(const string &path, const string filterFileExt);
|
||||||
void clearFolderTreeContentsCheckSum(const string &path, const string filterFileExt);
|
void clearFolderTreeContentsCheckSum(const string &path, const string filterFileExt);
|
||||||
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum);
|
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum,bool forceNoCache=false);
|
||||||
|
|
||||||
std::pair<string,string> getFolderTreeContentsCheckSumListCacheKey(vector<string> paths, string pathSearchString, const string filterFileExt);
|
std::pair<string,string> getFolderTreeContentsCheckSumListCacheKey(vector<string> paths, string pathSearchString, const string filterFileExt);
|
||||||
void clearFolderTreeContentsCheckSumList(vector<string> paths, string pathSearchString, const string filterFileExt);
|
void clearFolderTreeContentsCheckSumList(vector<string> paths, string pathSearchString, const string filterFileExt);
|
||||||
|
|
|
@ -573,7 +573,7 @@ void clearFolderTreeContentsCheckSum(vector<string> paths, string pathSearchStri
|
||||||
}
|
}
|
||||||
|
|
||||||
//finds all filenames like path and gets their checksum of all files combined
|
//finds all filenames like path and gets their checksum of all files combined
|
||||||
int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string pathSearchString, const string filterFileExt, Checksum *recursiveChecksum) {
|
int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string pathSearchString, const string filterFileExt, Checksum *recursiveChecksum, bool forceNoCache) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n-------------- In [%s::%s Line: %d] Calculating CRC for [%s] -----------\n",__FILE__,__FUNCTION__,__LINE__,pathSearchString.c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n-------------- In [%s::%s Line: %d] Calculating CRC for [%s] -----------\n",__FILE__,__FUNCTION__,__LINE__,pathSearchString.c_str());
|
||||||
|
|
||||||
|
@ -582,7 +582,7 @@ int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string path
|
||||||
std::map<string,int32> &crcTreeCache = CacheManager::getCachedItem< std::map<string,int32> >(cacheLookupId);
|
std::map<string,int32> &crcTreeCache = CacheManager::getCachedItem< std::map<string,int32> >(cacheLookupId);
|
||||||
|
|
||||||
string cacheKey = cacheKeys.second;
|
string cacheKey = cacheKeys.second;
|
||||||
if(crcTreeCache.find(cacheKey) != crcTreeCache.end()) {
|
if(forceNoCache == false && crcTreeCache.find(cacheKey) != crcTreeCache.end()) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning folders found CACHED checksum = %d for cacheKey [%s]\n",__FILE__,__FUNCTION__,crcTreeCache[cacheKey],cacheKey.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning folders found CACHED checksum = %d for cacheKey [%s]\n",__FILE__,__FUNCTION__,crcTreeCache[cacheKey],cacheKey.c_str());
|
||||||
return crcTreeCache[cacheKey];
|
return crcTreeCache[cacheKey];
|
||||||
}
|
}
|
||||||
|
@ -590,7 +590,7 @@ int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string path
|
||||||
string crcCacheFile = getFormattedCRCCacheFileName(cacheKeys);
|
string crcCacheFile = getFormattedCRCCacheFileName(cacheKeys);
|
||||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Looking for CRC Cache file [%s]\n",crcCacheFile.c_str());
|
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Looking for CRC Cache file [%s]\n",crcCacheFile.c_str());
|
||||||
int32 crcValue = 0;
|
int32 crcValue = 0;
|
||||||
if(hasCachedFileCRCValue(crcCacheFile, crcValue)) {
|
if(forceNoCache == false && hasCachedFileCRCValue(crcCacheFile, crcValue)) {
|
||||||
crcTreeCache[cacheKey] = crcValue;
|
crcTreeCache[cacheKey] = crcValue;
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning folders found CACHED FILE checksum = %d for cacheKey [%s]\n",__FILE__,__FUNCTION__,crcTreeCache[cacheKey],cacheKey.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning folders found CACHED FILE checksum = %d for cacheKey [%s]\n",__FILE__,__FUNCTION__,crcTreeCache[cacheKey],cacheKey.c_str());
|
||||||
return crcTreeCache[cacheKey];
|
return crcTreeCache[cacheKey];
|
||||||
|
@ -602,7 +602,7 @@ int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string path
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s], filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s], filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str());
|
||||||
|
|
||||||
getFolderTreeContentsCheckSumRecursively(path, filterFileExt, &checksum);
|
getFolderTreeContentsCheckSumRecursively(path, filterFileExt, &checksum, forceNoCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning: %d\n",__FILE__,__FUNCTION__,__LINE__,checksum.getSum());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning: %d\n",__FILE__,__FUNCTION__,__LINE__,checksum.getSum());
|
||||||
|
@ -614,11 +614,12 @@ int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string path
|
||||||
//printf("In [%s::%s Line: %d] Final CRC file count: %d\n",__FILE__,__FUNCTION__,__LINE__,checksum.getFileCount());
|
//printf("In [%s::%s Line: %d] Final CRC file count: %d\n",__FILE__,__FUNCTION__,__LINE__,checksum.getFileCount());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] Final CRC file count: %d\n",__FILE__,__FUNCTION__,__LINE__,checksum.getFileCount());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] Final CRC file count: %d\n",__FILE__,__FUNCTION__,__LINE__,checksum.getFileCount());
|
||||||
|
|
||||||
crcTreeCache[cacheKey] = checksum.getFinalFileListSum();
|
int32 result = checksum.getFinalFileListSum();
|
||||||
|
if(forceNoCache == false) {
|
||||||
writeCachedFileCRCValue(crcCacheFile, crcTreeCache[cacheKey]);
|
crcTreeCache[cacheKey] = result;
|
||||||
|
writeCachedFileCRCValue(crcCacheFile, crcTreeCache[cacheKey]);
|
||||||
return crcTreeCache[cacheKey];
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<string,string> getFolderTreeContentsCheckSumCacheKey(const string &path, const string filterFileExt) {
|
std::pair<string,string> getFolderTreeContentsCheckSumCacheKey(const string &path, const string filterFileExt) {
|
||||||
|
@ -645,7 +646,7 @@ void clearFolderTreeContentsCheckSum(const string &path, const string filterFile
|
||||||
}
|
}
|
||||||
|
|
||||||
//finds all filenames like path and gets their checksum of all files combined
|
//finds all filenames like path and gets their checksum of all files combined
|
||||||
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum) {
|
int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string &filterFileExt, Checksum *recursiveChecksum, bool forceNoCache) {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s] filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str());
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s] filterFileExt = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),filterFileExt.c_str());
|
||||||
std::pair<string,string> cacheKeys = getFolderTreeContentsCheckSumCacheKey(path, filterFileExt);
|
std::pair<string,string> cacheKeys = getFolderTreeContentsCheckSumCacheKey(path, filterFileExt);
|
||||||
|
|
||||||
|
@ -653,7 +654,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
|
||||||
std::map<string,int32> &crcTreeCache = CacheManager::getCachedItem< std::map<string,int32> >(cacheLookupId);
|
std::map<string,int32> &crcTreeCache = CacheManager::getCachedItem< std::map<string,int32> >(cacheLookupId);
|
||||||
|
|
||||||
string cacheKey = cacheKeys.second;
|
string cacheKey = cacheKeys.second;
|
||||||
if(crcTreeCache.find(cacheKey) != crcTreeCache.end()) {
|
if(forceNoCache == false && crcTreeCache.find(cacheKey) != crcTreeCache.end()) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] found CACHED checksum = %d for cacheKey [%s]\n",__FILE__,__FUNCTION__,path.c_str(),crcTreeCache[cacheKey],cacheKey.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] found CACHED checksum = %d for cacheKey [%s]\n",__FILE__,__FUNCTION__,path.c_str(),crcTreeCache[cacheKey],cacheKey.c_str());
|
||||||
return crcTreeCache[cacheKey];
|
return crcTreeCache[cacheKey];
|
||||||
}
|
}
|
||||||
|
@ -661,7 +662,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
|
||||||
string crcCacheFile = getFormattedCRCCacheFileName(cacheKeys);
|
string crcCacheFile = getFormattedCRCCacheFileName(cacheKeys);
|
||||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Looking for CRC Cache file [%s]\n",crcCacheFile.c_str());
|
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Looking for CRC Cache file [%s]\n",crcCacheFile.c_str());
|
||||||
int32 crcValue = 0;
|
int32 crcValue = 0;
|
||||||
if(hasCachedFileCRCValue(crcCacheFile, crcValue)) {
|
if(forceNoCache == false && hasCachedFileCRCValue(crcCacheFile, crcValue)) {
|
||||||
crcTreeCache[cacheKey] = crcValue;
|
crcTreeCache[cacheKey] = crcValue;
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning folders found CACHED FILE checksum = %d for cacheKey [%s]\n",__FILE__,__FUNCTION__,crcTreeCache[cacheKey],cacheKey.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning folders found CACHED FILE checksum = %d for cacheKey [%s]\n",__FILE__,__FUNCTION__,crcTreeCache[cacheKey],cacheKey.c_str());
|
||||||
return crcTreeCache[cacheKey];
|
return crcTreeCache[cacheKey];
|
||||||
|
@ -747,7 +748,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
|
||||||
string currentPath = p;
|
string currentPath = p;
|
||||||
endPathWithSlash(currentPath);
|
endPathWithSlash(currentPath);
|
||||||
|
|
||||||
getFolderTreeContentsCheckSumRecursively(currentPath + "*", filterFileExt, &checksum);
|
getFolderTreeContentsCheckSumRecursively(currentPath + "*", filterFileExt, &checksum, forceNoCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
globfree(&globbuf);
|
globfree(&globbuf);
|
||||||
|
@ -762,12 +763,14 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
|
||||||
//printf("In [%s::%s Line: %d] Final CRC file count for [%s]: %d\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),checksum.getFileCount());
|
//printf("In [%s::%s Line: %d] Final CRC file count for [%s]: %d\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),checksum.getFileCount());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] Final CRC file count for [%s]: %d\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),checksum.getFileCount());
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] Final CRC file count for [%s]: %d\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),checksum.getFileCount());
|
||||||
|
|
||||||
crcTreeCache[cacheKey] = checksum.getFinalFileListSum();
|
int32 result = checksum.getFinalFileListSum();
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d for cacheKey [%s] fileMatchCount = %d, fileLoopCount = %d\n",__FILE__,__FUNCTION__,path.c_str(),crcTreeCache[cacheKey],cacheKey.c_str(),fileMatchCount,fileLoopCount);
|
if(forceNoCache == false) {
|
||||||
|
crcTreeCache[cacheKey] = result;
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] scanning [%s] ending checksum = %d for cacheKey [%s] fileMatchCount = %d, fileLoopCount = %d\n",__FILE__,__FUNCTION__,path.c_str(),crcTreeCache[cacheKey],cacheKey.c_str(),fileMatchCount,fileLoopCount);
|
||||||
|
writeCachedFileCRCValue(crcCacheFile, crcTreeCache[cacheKey]);
|
||||||
|
}
|
||||||
|
|
||||||
writeCachedFileCRCValue(crcCacheFile, crcTreeCache[cacheKey]);
|
return result;
|
||||||
|
|
||||||
return crcTreeCache[cacheKey];
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -753,6 +753,11 @@ bool Socket::isSocketValid(const PLATFORM_SOCKET *validateSocket) {
|
||||||
|
|
||||||
Socket::Socket(PLATFORM_SOCKET sock) {
|
Socket::Socket(PLATFORM_SOCKET sock) {
|
||||||
//this->pingThread = NULL;
|
//this->pingThread = NULL;
|
||||||
|
pingThreadAccessor.setOwnerId(string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
dataSynchAccessorRead.setOwnerId(string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
dataSynchAccessorWrite.setOwnerId(string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
inSocketDestructorSynchAccessor.setOwnerId(string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
MutexSafeWrapper safeMutexSocketDestructorFlag(&inSocketDestructorSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
MutexSafeWrapper safeMutexSocketDestructorFlag(&inSocketDestructorSynchAccessor,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
this->inSocketDestructor = false;
|
this->inSocketDestructor = false;
|
||||||
safeMutexSocketDestructorFlag.ReleaseLock();
|
safeMutexSocketDestructorFlag.ReleaseLock();
|
||||||
|
@ -837,6 +842,14 @@ Socket::~Socket()
|
||||||
|
|
||||||
disconnectSocket();
|
disconnectSocket();
|
||||||
|
|
||||||
|
// Allow other callers with a lock on the mutexes to let them go
|
||||||
|
for(time_t elapsed = time(NULL);
|
||||||
|
(dataSynchAccessorRead.getRefCount() > 0 ||
|
||||||
|
dataSynchAccessorWrite.getRefCount() > 0) &&
|
||||||
|
difftime(time(NULL),elapsed) <= 5;) {
|
||||||
|
sleep(0);
|
||||||
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END closing socket = %d...\n",__FILE__,__FUNCTION__,sock);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END closing socket = %d...\n",__FILE__,__FUNCTION__,sock);
|
||||||
|
|
||||||
//delete pingThread;
|
//delete pingThread;
|
||||||
|
|
|
@ -94,6 +94,7 @@ Mutex::~Mutex() {
|
||||||
char szBuf[1024]="";
|
char szBuf[1024]="";
|
||||||
snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str());
|
snprintf(szBuf,1023,"In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s]",__FILE__,__FUNCTION__,__LINE__,refCount,ownerId.c_str());
|
||||||
throw runtime_error(szBuf);
|
throw runtime_error(szBuf);
|
||||||
|
//printf("%s\n",szBuf);
|
||||||
}
|
}
|
||||||
else if(refCount >= 1) {
|
else if(refCount >= 1) {
|
||||||
char szBuf[1024]="";
|
char szBuf[1024]="";
|
||||||
|
@ -101,8 +102,10 @@ Mutex::~Mutex() {
|
||||||
throw runtime_error(szBuf);
|
throw runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DestroyMutex(mutex);
|
if(mutex != NULL) {
|
||||||
mutex=NULL;
|
SDL_DestroyMutex(mutex);
|
||||||
|
mutex=NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mutex::p() {
|
void Mutex::p() {
|
||||||
|
|
Loading…
Reference in New Issue