- 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:
Mark Vejvoda 2011-03-19 12:04:18 +00:00
parent 83eaa67068
commit bca617cf18
13 changed files with 312 additions and 204 deletions

View File

@ -73,6 +73,7 @@ private:
int32 mapCRC;
int32 tilesetCRC;
int32 techCRC;
vector<pair<string,int32> > factionCRCList;
public:
@ -101,6 +102,7 @@ public:
mapCRC = 0;
tilesetCRC = 0;
techCRC = 0;
factionCRCList.clear();
}
// default copy constructor will do fine, and will maintain itself ;)
@ -161,6 +163,7 @@ public:
int32 getMapCRC() const { return mapCRC; }
int32 getTilesetCRC() const { return tilesetCRC; }
int32 getTechCRC() const { return techCRC; }
vector<pair<string,int32> > getFactionCRCList() const { return factionCRCList; }
//set
void setDescription(const string& description) {this->description= description;}
@ -200,6 +203,8 @@ public:
void setTilesetCRC(int32 value) { tilesetCRC = value; }
void setTechCRC(int32 value) { techCRC = value; }
void setFactionCRCList(vector<pair<string,int32> > value) { factionCRCList = value; }
string toString() const {
string result = "";
@ -239,6 +244,10 @@ public:
result += "tilesetCRC = " + intToStr(tilesetCRC) + "\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;
}
};

View File

@ -34,6 +34,8 @@
namespace Glest{ namespace Game{
static const string ITEM_MISSING = "***missing***";
using namespace Shared::Util;
struct FormatString {
@ -987,8 +989,9 @@ void MenuStateConnectedGame::update() {
MutexSafeWrapper safeMutexFTPProgress(ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL,string(__FILE__) + "_" + intToStr(__LINE__));
int32 tilesetCRC = lastCheckedCRCTilesetValue;
if(lastCheckedCRCTilesetName != gameSettings->getTileset()) {
console.addLine("Checking tileset CRC " + gameSettings->getTileset() + "]");
if(lastCheckedCRCTilesetName != gameSettings->getTileset() &&
gameSettings->getTileset() != "") {
console.addLine("Checking tileset CRC [" + gameSettings->getTileset() + "]");
tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL);
// Test data synch
//tilesetCRC++;
@ -997,20 +1000,31 @@ void MenuStateConnectedGame::update() {
}
int32 techCRC = lastCheckedCRCTechtreeValue;
if(lastCheckedCRCTechtreeName != gameSettings->getTech()) {
console.addLine("Checking techtree CRC " + gameSettings->getTech() + "]");
if(lastCheckedCRCTechtreeName != gameSettings->getTech() &&
gameSettings->getTech() != "") {
console.addLine("Checking techtree CRC [" + gameSettings->getTech() + "]");
techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), string("/") + gameSettings->getTech() + string("/*"), ".xml", NULL);
// Test data synch
//techCRC++;
lastCheckedCRCTechtreeValue = techCRC;
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;
if(lastCheckedCRCMapName != gameSettings->getMap()) {
if(lastCheckedCRCMapName != gameSettings->getMap() &&
gameSettings->getMap() != "") {
Checksum checksum;
string file = Map::getMapPath(gameSettings->getMap(),"",false);
console.addLine("Checking map CRC " + file + "]");
console.addLine("Checking map CRC [" + file + "]");
checksum.addFile(file);
mapCRC = checksum.getSum();
// Test data synch
@ -1030,7 +1044,7 @@ void MenuStateConnectedGame::update() {
if(dataSynchMismatch == true) {
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");
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");
if(updateDataSynchDetailText == true &&
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");
if(updateDataSynchDetailText == true &&
lastTechtreeDataSynchError != lang.get("DataNotSynchedTechtree") + " " + listBoxTechTree.getSelectedItem()) {
lastTechtreeDataSynchError = lang.get("DataNotSynchedTechtree") + " " + listBoxTechTree.getSelectedItem();
clientInterface->sendTextMessage(lastTechtreeDataSynchError,-1,true);
}
}
/*
if(clientInterface->getNetworkGameDataSynchCheckOkTech() == false) {
labelSynch = labelSynch + " techtree";
string mismatchedFactionText = "";
vector<pair<string,int32> > serverFactionCRCList = gameSettings->getFactionCRCList();
if(updateDataSynchDetailText == true) {
for(unsigned int factionIdx = 0; factionIdx < serverFactionCRCList.size(); ++factionIdx) {
pair<string,int32> &serverFaction = serverFactionCRCList[factionIdx];
string report = clientInterface->getNetworkGameDataSynchCheckTechMismatchReport();
if(lastTechtreeDataSynchError != "techtree CRC mismatch" + report) {
lastTechtreeDataSynchError = "techtree CRC mismatch" + report;
bool foundFaction = false;
for(unsigned int clientFactionIdx = 0; clientFactionIdx < factionCRCList.size(); ++clientFactionIdx) {
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);
vector<string> reportLineTokens;
Tokenize(report,reportLineTokens,"\n");
for(int reportLine = 0; reportLine < reportLineTokens.size(); ++reportLine) {
clientInterface->sendTextMessage(reportLineTokens[reportLine],-1,true);
if(foundFaction == false) {
if(mismatchedFactionText == "") {
mismatchedFactionText = "The following factions are mismatched: [" + intToStr(factionCRCList.size()) + "][" + intToStr(serverFactionCRCList.size()) + "] - ";
}
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) {
updateDataSynchDetailText = false;
@ -1241,11 +1287,12 @@ void MenuStateConnectedGame::update() {
throw runtime_error("gameSettings == NULL");
}
if(getMissingTilesetFromFTPServerInProgress == false) {
if(getMissingTilesetFromFTPServerInProgress == false &&
gameSettings->getTileset() != "") {
// tileset
if(std::find(tilesetFiles.begin(),tilesetFiles.end(),gameSettings->getTileset()) != tilesetFiles.end()) {
lastMissingTileSet = "";
getMissingTilesetFromFTPServer = "";
tilesets.push_back(formatString(gameSettings->getTileset()));
}
else {
@ -1263,7 +1310,7 @@ void MenuStateConnectedGame::update() {
}
}
tilesets.push_back("***missing***");
tilesets.push_back(ITEM_MISSING);
NetworkManager &networkManager= NetworkManager::getInstance();
ClientInterface* clientInterface= networkManager.getClientInterface();
@ -1287,11 +1334,12 @@ void MenuStateConnectedGame::update() {
listBoxTileset.setItems(tilesets);
}
if(getMissingTechtreeFromFTPServerInProgress == false) {
if(getMissingTechtreeFromFTPServerInProgress == false &&
gameSettings->getTech() != "") {
// techtree
if(std::find(techTreeFiles.begin(),techTreeFiles.end(),gameSettings->getTech()) != techTreeFiles.end()) {
lastMissingTechtree = "";
getMissingTechtreeFromFTPServer = "";
techtree.push_back(formatString(gameSettings->getTech()));
}
else {
@ -1309,7 +1357,7 @@ void MenuStateConnectedGame::update() {
}
}
techtree.push_back("***missing***");
techtree.push_back(ITEM_MISSING);
NetworkManager &networkManager= NetworkManager::getInstance();
ClientInterface* clientInterface= networkManager.getClientInterface();
@ -1339,20 +1387,21 @@ void MenuStateConnectedGame::update() {
// factions
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());
currentFactionName = gameSettings->getTech();
hasFactions = loadFactions(gameSettings,false);
}
else {
// do this to process special faction types liek observers
// do this to process special faction types like observers
loadFactions(gameSettings,false);
}
//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
if(currentMap != gameSettings->getMap()) {// load the setup again
currentMap = gameSettings->getMap();
@ -1376,7 +1425,7 @@ void MenuStateConnectedGame::update() {
showFTPMessageBox(szBuf, lang.get("Question"), false);
}
}
maps.push_back("***missing***");
maps.push_back(ITEM_MISSING);
}
listBoxMap.setItems(maps);
labelMapInfo.setText(mapInfo.desc);
@ -1442,11 +1491,7 @@ void MenuStateConnectedGame::update() {
labelPlayerStatus[i].setText("");
}
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
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){
int slot = gameSettings->getStartLocationIndex(i);
@ -1639,75 +1684,79 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
bool foundFactions = false;
vector<string> results;
Config &config = Config::getInstance();
Lang &lang= Lang::getInstance();
vector<string> techPaths = config.getPathListForType(ptTechs);
for(int idx = 0; idx < techPaths.size(); idx++) {
string &techPath = techPaths[idx];
endPathWithSlash(techPath);
findAll(techPath + gameSettings->getTech() + "/factions/*.", results, false, false);
if(results.size() > 0) {
break;
}
}
if(gameSettings->getTech() != "") {
Config &config = Config::getInstance();
Lang &lang= Lang::getInstance();
if(results.size() == 0) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
NetworkManager &networkManager= NetworkManager::getInstance();
ClientInterface* clientInterface= networkManager.getClientInterface();
if(clientInterface->getAllowGameDataSynchCheck() == false) {
if(errorOnNoFactions == true) {
throw runtime_error("(2)There are no factions for the tech tree [" + gameSettings->getTech() + "]");
vector<string> techPaths = config.getPathListForType(ptTechs);
for(int idx = 0; idx < techPaths.size(); idx++) {
string &techPath = techPaths[idx];
endPathWithSlash(techPath);
findAll(techPath + gameSettings->getTech() + "/factions/*.", results, false, false);
if(results.size() > 0) {
break;
}
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()) {
lastMissingTechtree = gameSettings->getTech();
if(results.size() == 0) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
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);
NetworkManager &networkManager= NetworkManager::getInstance();
ClientInterface* clientInterface= networkManager.getClientInterface();
if(clientInterface->getAllowGameDataSynchCheck() == false) {
if(errorOnNoFactions == true) {
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(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;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
else {
lastMissingTechtree = "";
// Add special Observer Faction
//Lang &lang= Lang::getInstance();
if(gameSettings->getAllowObservers() == true) {
results.push_back(formatString(GameConstants::OBSERVER_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);
}
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__);
return foundFactions;
}
@ -1936,7 +1985,7 @@ bool MenuStateConnectedGame::loadMapInfo(string file, MapInfo *mapInfo, bool loa
mapLoaded = true;
}
else {
mapInfo->desc = "***missing***";
mapInfo->desc = ITEM_MISSING;
NetworkManager &networkManager= NetworkManager::getInstance();
ClientInterface* clientInterface= networkManager.getClientInterface();

View File

@ -164,6 +164,7 @@ private:
int32 lastCheckedCRCTilesetValue;
int32 lastCheckedCRCTechtreeValue;
int32 lastCheckedCRCMapValue;
vector<pair<string,int32> > factionCRCList;
std::map<string,pair<int,string> > fileFTPProgressList;

View File

@ -881,9 +881,6 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
updateResourceMultiplier(i);
}
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
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] == formatString(GameConstants::OBSERVER_SLOTNAME) &&
(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))
{
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)) {
lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
}
@ -2230,7 +2226,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
if( 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);
lastCheckedCRCTilesetName = gameSettings->getTileset();
}
@ -2240,10 +2236,21 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
if(config.getBool("DisableServerLobbyTechtreeCRCCheck","false") == false) {
if(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);
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();
}
gameSettings->setFactionCRCList(factionCRCList);
gameSettings->setTechCRC(lastCheckedCRCTechtreeValue);
}
}
@ -2252,7 +2259,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
if(lastCheckedCRCMapName != gameSettings->getMap()) {
Checksum checksum;
string file = Map::getMapPath(gameSettings->getMap(),"",false);
console.addLine("Checking map CRC " + file + "]");
console.addLine("Checking map CRC [" + file + "]");
checksum.addFile(file);
lastCheckedCRCMapValue = checksum.getSum();
lastCheckedCRCMapName = gameSettings->getMap();

View File

@ -107,9 +107,6 @@ private:
bool needToBroadcastServerSettings;
std::map<string,string> publishToServerInfo;
SimpleTaskThread *publishToMasterserverThread;
//Mutex masterServerThreadAccessor;
//Mutex publishToMasterserverThreadPtrChangeAccessor;
//bool publishToMasterserverThreadInDeletion;
bool parentMenuIsMs;
int soundConnectionCount;
@ -154,6 +151,7 @@ private:
int32 lastCheckedCRCTilesetValue;
int32 lastCheckedCRCTechtreeValue;
int32 lastCheckedCRCMapValue;
vector<pair<string,int32> > factionCRCList;
public:
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,bool openNetworkSlots= false, bool parentMenuIsMasterserver=false, bool autostart=false);

View File

@ -202,6 +202,10 @@ void NetworkMessageReady::send(Socket* socket) const {
NetworkMessageLaunch::NetworkMessageLaunch() {
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) {
@ -211,6 +215,17 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
data.tilesetCRC = gameSettings->getTilesetCRC();
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.map= gameSettings->getMap();
data.tileset= gameSettings->getTileset();
@ -264,7 +279,15 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const {
gameSettings->setTilesetCRC(data.tilesetCRC);
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->setNetworkPlayerName(i,data.networkPlayerNames[i].getString());
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 result = NetworkMessage::receive(socket, &data, sizeof(data));
data.description.nullTerminate();
data.map.nullTerminate();
data.tileset.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.networkPlayerNames[i].nullTerminate();
}
for(unsigned int i = 0; i < maxFactionCRCCount; ++i) {
data.factionNameList[i].nullTerminate();
}
return result;
}

View File

@ -187,6 +187,7 @@ class NetworkMessageLaunch: public NetworkMessage {
private:
static const int maxStringSize= 256;
static const int maxSmallStringSize= 60;
static const int maxFactionCRCCount= 20;
private:
struct Data{
@ -201,6 +202,8 @@ private:
int32 mapCRC;
int32 tilesetCRC;
int32 techCRC;
NetworkString<maxSmallStringSize> factionNameList[maxFactionCRCCount];
int32 factionCRCList[maxFactionCRCCount];
int8 factionControls[GameConstants::maxPlayers];
int8 resourceMultiplierIndex[GameConstants::maxPlayers];
@ -235,6 +238,7 @@ public:
int getMapCRC() const { return data.mapCRC; }
int getTilesetCRC() const { return data.tilesetCRC; }
int getTechCRC() const { return data.techCRC; }
vector<pair<string,int32> > getFactionCRCList() const;
virtual bool receive(Socket* socket);
virtual void send(Socket* socket) const;

View File

@ -37,18 +37,18 @@ FactionThread::FactionThread(Faction *faction) : BaseThread() {
}
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);
if(value == true) {
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) {
//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);
@ -59,12 +59,12 @@ void FactionThread::signalPathfinder(int frameIndex) {
this->frameIndex.second = false;
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();
}
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);
@ -77,7 +77,7 @@ void FactionThread::setTaskCompleted(int frameIndex) {
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) {
@ -91,7 +91,7 @@ bool FactionThread::canShutdown(bool deleteSelfIfShutdownDelayed) {
}
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) {
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);
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;
}
@ -123,7 +123,7 @@ void FactionThread::execute() {
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
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) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -141,7 +141,6 @@ void FactionThread::execute() {
if(executeTask == true) {
ExecutingTaskSafeWrapper safeExecutingTaskMutex(this);
//this->slotInterface->slotUpdateTask(&eventCopy);
World *world = faction->getWorld();
int unitCount = faction->getUnitCount();
@ -160,13 +159,13 @@ void FactionThread::execute() {
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) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
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__);
@ -180,7 +179,7 @@ void FactionThread::execute() {
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);
}

View File

@ -1116,64 +1116,51 @@ const CommandType *Unit::computeCommandType(const Vec2i &pos, const Unit *target
bool Unit::needToUpdate() {
assert(progress <= 1.f);
if(currSkill == NULL) {
char szBuf[4096]="";
sprintf(szBuf,"In [%s::%s Line: %d] ERROR: currSkill == NULL, Unit = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->toString().c_str());
throw runtime_error(szBuf);
}
//speed
int speed = currSkill->getTotalSpeed(&totalUpgrade);
bool return_value = false;
if(currSkill->getClass() != scDie) {
//speed
int speed = currSkill->getTotalSpeed(&totalUpgrade);
//speed modifier
float diagonalFactor= 1.f;
float heightFactor= 1.f;
if(currSkill->getClass() == scMove) {
//if moving in diagonal move slower
Vec2i dest= pos-lastPos;
if(abs(dest.x) + abs(dest.y) == 2) {
diagonalFactor= 0.71f;
//speed modifier
float diagonalFactor= 1.f;
float heightFactor= 1.f;
if(currSkill->getClass() == scMove) {
//if moving in diagonal move slower
Vec2i dest= pos - lastPos;
if(abs(dest.x) + abs(dest.y) == 2) {
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
float heightDiff= map->getCell(pos)->getHeight() - map->getCell(targetPos)->getHeight();
heightFactor= clamp(1.f + heightDiff / 5.f, 0.2f, 5.f);
}
//update progresses
float newProgress = progress;
const Game *game = Renderer::getInstance().getGame();
newProgress += (speed * diagonalFactor * heightFactor) / (speedDivider * game->getWorld()->getUpdateFps(this->getFactionIndex()));
//update progresses
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;
if(newProgress >= 1.f) {
return_value = true;
}
else {
newProgress= 1.f;
int newDeadCount = deadCount;
newDeadCount++;
if(newDeadCount >= maxDeadCount) {
return_value = false;
}
}
}
return return_value;
}
bool Unit::update() {
assert(progress<=1.f);
assert(progress <= 1.f);
//highlight
if(highlight>0.f) {
if(highlight > 0.f) {
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) {
@ -1186,22 +1173,20 @@ bool Unit::update() {
int speed= currSkill->getTotalSpeed(&totalUpgrade);
//speed modifier
float diagonalFactor= 1.f;
float heightFactor= 1.f;
float diagonalFactor = 1.f;
float heightFactor = 1.f;
if(currSkill->getClass() == scMove) {
//if moving in diagonal move slower
Vec2i dest= pos-lastPos;
if(abs(dest.x)+abs(dest.y) == 2) {
diagonalFactor= 0.71f;
Vec2i dest = pos - lastPos;
if(abs(dest.x) + abs(dest.y) == 2) {
diagonalFactor = 0.71f;
}
//if movig 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 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);
}
//update progresses
lastAnimProgress= animProgress;
const Game *game = Renderer::getInstance().getGame();
@ -1214,13 +1199,13 @@ bool Unit::update() {
//rotation
if(currSkill->getClass() != scStop) {
const int rotFactor= 2;
if(progress<1.f/rotFactor){
if(progress < 1.f / rotFactor) {
if(type->getFirstStOfClass(scMove)){
if(abs((int)(lastRotation-targetRotation)) < 180)
rotation= lastRotation+(targetRotation-lastRotation)*progress*rotFactor;
else{
float rotationTerm= targetRotation>lastRotation? -360.f: +360.f;
rotation= lastRotation+(targetRotation-lastRotation+rotationTerm)*progress*rotFactor;
rotation= lastRotation + (targetRotation - lastRotation) * progress * rotFactor;
else {
float rotationTerm = targetRotation > lastRotation ? -360.f: +360.f;
rotation = lastRotation + (targetRotation - lastRotation + rotationTerm) * progress * rotFactor;
}
}
}
@ -1242,22 +1227,22 @@ bool Unit::update() {
(*it)->setRotation(getRotation());
}
//checks
if(animProgress>1.f) {
animProgress= currSkill->getClass()==scDie? 1.f: 0.f;
if(animProgress > 1.f) {
animProgress = currSkill->getClass() == scDie? 1.f: 0.f;
}
bool return_value = false;
//checks
if(progress>=1.f) {
if(progress >= 1.f) {
lastRotation= targetRotation;
if(currSkill->getClass() != scDie) {
progress= 0.f;
progress = 0.f;
return_value = true;
}
else {
progress= 1.f;
deadCount++;
if(deadCount>=maxDeadCount) {
if(deadCount >= maxDeadCount) {
toBeUndertaken= true;
return_value = false;
}

View File

@ -120,11 +120,11 @@ void setCRCCacheFilePath(string path);
std::pair<string,string> getFolderTreeContentsCheckSumCacheKey(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);
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);
void clearFolderTreeContentsCheckSumList(vector<string> paths, string pathSearchString, const string filterFileExt);

View File

@ -573,7 +573,7 @@ void clearFolderTreeContentsCheckSum(vector<string> paths, string pathSearchStri
}
//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__);
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);
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());
return crcTreeCache[cacheKey];
}
@ -590,7 +590,7 @@ int32 getFolderTreeContentsCheckSumRecursively(vector<string> paths, string path
string crcCacheFile = getFormattedCRCCacheFileName(cacheKeys);
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Looking for CRC Cache file [%s]\n",crcCacheFile.c_str());
int32 crcValue = 0;
if(hasCachedFileCRCValue(crcCacheFile, crcValue)) {
if(forceNoCache == false && hasCachedFileCRCValue(crcCacheFile, 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());
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());
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());
@ -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());
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] Final CRC file count: %d\n",__FILE__,__FUNCTION__,__LINE__,checksum.getFileCount());
crcTreeCache[cacheKey] = checksum.getFinalFileListSum();
writeCachedFileCRCValue(crcCacheFile, crcTreeCache[cacheKey]);
return crcTreeCache[cacheKey];
int32 result = checksum.getFinalFileListSum();
if(forceNoCache == false) {
crcTreeCache[cacheKey] = result;
writeCachedFileCRCValue(crcCacheFile, crcTreeCache[cacheKey]);
}
return result;
}
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
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());
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);
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());
return crcTreeCache[cacheKey];
}
@ -661,7 +662,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
string crcCacheFile = getFormattedCRCCacheFileName(cacheKeys);
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Looking for CRC Cache file [%s]\n",crcCacheFile.c_str());
int32 crcValue = 0;
if(hasCachedFileCRCValue(crcCacheFile, crcValue)) {
if(forceNoCache == false && hasCachedFileCRCValue(crcCacheFile, 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());
return crcTreeCache[cacheKey];
@ -747,7 +748,7 @@ int32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
string currentPath = p;
endPathWithSlash(currentPath);
getFolderTreeContentsCheckSumRecursively(currentPath + "*", filterFileExt, &checksum);
getFolderTreeContentsCheckSumRecursively(currentPath + "*", filterFileExt, &checksum, forceNoCache);
}
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());
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();
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);
int32 result = checksum.getFinalFileListSum();
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 crcTreeCache[cacheKey];
return result;
}
else {
return 0;

View File

@ -753,6 +753,11 @@ bool Socket::isSocketValid(const PLATFORM_SOCKET *validateSocket) {
Socket::Socket(PLATFORM_SOCKET sock) {
//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__));
this->inSocketDestructor = false;
safeMutexSocketDestructorFlag.ReleaseLock();
@ -837,6 +842,14 @@ Socket::~Socket()
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);
//delete pingThread;

View File

@ -94,6 +94,7 @@ Mutex::~Mutex() {
char szBuf[1024]="";
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);
//printf("%s\n",szBuf);
}
else if(refCount >= 1) {
char szBuf[1024]="";
@ -101,8 +102,10 @@ Mutex::~Mutex() {
throw runtime_error(szBuf);
}
SDL_DestroyMutex(mutex);
mutex=NULL;
if(mutex != NULL) {
SDL_DestroyMutex(mutex);
mutex=NULL;
}
}
void Mutex::p() {