bugfix to force server to refresh CRC if client has different CRC
This commit is contained in:
parent
d46479df95
commit
c88c631010
|
@ -98,6 +98,11 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
||||||
lastCheckedCRCTilesetName = "";
|
lastCheckedCRCTilesetName = "";
|
||||||
lastCheckedCRCTechtreeName = "";
|
lastCheckedCRCTechtreeName = "";
|
||||||
lastCheckedCRCMapName = "";
|
lastCheckedCRCMapName = "";
|
||||||
|
|
||||||
|
last_Forced_CheckedCRCTilesetName = "";
|
||||||
|
last_Forced_CheckedCRCTechtreeName = "";
|
||||||
|
last_Forced_CheckedCRCMapName = "";
|
||||||
|
|
||||||
lastCheckedCRCTilesetValue = -1;
|
lastCheckedCRCTilesetValue = -1;
|
||||||
lastCheckedCRCTechtreeValue = -1;
|
lastCheckedCRCTechtreeValue = -1;
|
||||||
lastCheckedCRCMapValue = -1;
|
lastCheckedCRCMapValue = -1;
|
||||||
|
@ -1492,6 +1497,40 @@ void MenuStateCustomGame::RestoreLastGameSettings() {
|
||||||
loadGameSettings(SAVED_GAME_FILENAME);
|
loadGameSettings(SAVED_GAME_FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MenuStateCustomGame::checkNetworkPlayerDataSynch(bool checkMapCRC,
|
||||||
|
bool checkTileSetCRC, bool checkTechTreeCRC) {
|
||||||
|
ServerInterface* serverInterface = NetworkManager::getInstance().getServerInterface();
|
||||||
|
|
||||||
|
bool dataSynchCheckOk = true;
|
||||||
|
for(int i= 0; i < mapInfo.players; ++i) {
|
||||||
|
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork) {
|
||||||
|
ConnectionSlot *slot = serverInterface->getSlot(i);
|
||||||
|
if( slot != NULL && slot->isConnected() &&
|
||||||
|
(slot->getAllowDownloadDataSynch() == true ||
|
||||||
|
slot->getAllowGameDataSynchCheck() == true)) {
|
||||||
|
|
||||||
|
if(checkMapCRC == true &&
|
||||||
|
slot->getNetworkGameDataSynchCheckOkMap() == false) {
|
||||||
|
dataSynchCheckOk = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(checkTileSetCRC == true &&
|
||||||
|
slot->getNetworkGameDataSynchCheckOkTile() == false) {
|
||||||
|
dataSynchCheckOk = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(checkTechTreeCRC == true &&
|
||||||
|
slot->getNetworkGameDataSynchCheckOkTech() == false) {
|
||||||
|
dataSynchCheckOk = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataSynchCheckOk;
|
||||||
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::PlayNow(bool saveGame) {
|
void MenuStateCustomGame::PlayNow(bool saveGame) {
|
||||||
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
if(saveGame == true) {
|
if(saveGame == true) {
|
||||||
|
@ -1575,22 +1614,7 @@ void MenuStateCustomGame::PlayNow(bool saveGame) {
|
||||||
// Send the game settings to each client if we have at least one networked client
|
// Send the game settings to each client if we have at least one networked client
|
||||||
safeMutex.Lock();
|
safeMutex.Lock();
|
||||||
|
|
||||||
bool dataSynchCheckOk = true;
|
bool dataSynchCheckOk = checkNetworkPlayerDataSynch(true, true, true);
|
||||||
for(int i= 0; i < mapInfo.players; ++i) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
if( serverInterface->getSlot(i) != NULL && serverInterface->getSlot(i)->isConnected() &&
|
|
||||||
(serverInterface->getSlot(i)->getAllowDownloadDataSynch() == true || serverInterface->getSlot(i)->getAllowGameDataSynchCheck() == true) &&
|
|
||||||
serverInterface->getSlot(i)->getNetworkGameDataSynchCheckOk() == false) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
dataSynchCheckOk = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure we have no dangling network players
|
// Ensure we have no dangling network players
|
||||||
for(int i= 0; i < GameConstants::maxPlayers; ++i) {
|
for(int i= 0; i < GameConstants::maxPlayers; ++i) {
|
||||||
|
@ -3314,66 +3338,82 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
||||||
gameSettings->setNetworkFramePeriod(config.getInt("NetworkSendFrameCount","20"));
|
gameSettings->setNetworkFramePeriod(config.getInt("NetworkSendFrameCount","20"));
|
||||||
gameSettings->setNetworkPauseGameForLaggedClients(((checkBoxNetworkPauseGameForLaggedClients.getValue() == true)));
|
gameSettings->setNetworkPauseGameForLaggedClients(((checkBoxNetworkPauseGameForLaggedClients.getValue() == true)));
|
||||||
|
|
||||||
//if(hasNetworkGameSettings() == true) {
|
if( gameSettings->getTileset() != "") {
|
||||||
{
|
// Check if client has different data, if so force a CRC refresh
|
||||||
if( gameSettings->getTileset() != "") {
|
if(checkNetworkPlayerDataSynch(false,true, false) == false &&
|
||||||
if(lastCheckedCRCTilesetName != gameSettings->getTileset()) {
|
last_Forced_CheckedCRCTilesetName != gameSettings->getTileset()) {
|
||||||
//console.addLine("Checking tileset CRC [" + gameSettings->getTileset() + "]");
|
lastCheckedCRCTilesetName = "";
|
||||||
lastCheckedCRCTilesetValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL);
|
last_Forced_CheckedCRCTilesetName = gameSettings->getTileset();
|
||||||
if(lastCheckedCRCTilesetValue == 0) {
|
|
||||||
lastCheckedCRCTilesetValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL, true);
|
|
||||||
}
|
|
||||||
lastCheckedCRCTilesetName = gameSettings->getTileset();
|
|
||||||
}
|
|
||||||
gameSettings->setTilesetCRC(lastCheckedCRCTilesetValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config.getBool("DisableServerLobbyTechtreeCRCCheck","false") == false) {
|
if(lastCheckedCRCTilesetName != gameSettings->getTileset()) {
|
||||||
if(gameSettings->getTech() != "") {
|
//console.addLine("Checking tileset CRC [" + gameSettings->getTileset() + "]");
|
||||||
if(lastCheckedCRCTechtreeName != gameSettings->getTech()) {
|
lastCheckedCRCTilesetValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL);
|
||||||
//console.addLine("Checking techtree CRC [" + gameSettings->getTech() + "]");
|
if(lastCheckedCRCTilesetValue == 0) {
|
||||||
lastCheckedCRCTechtreeValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/*", ".xml", NULL);
|
lastCheckedCRCTilesetValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL, true);
|
||||||
if(lastCheckedCRCTechtreeValue == 0) {
|
}
|
||||||
lastCheckedCRCTechtreeValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/*", ".xml", NULL, true);
|
lastCheckedCRCTilesetName = gameSettings->getTileset();
|
||||||
}
|
}
|
||||||
|
gameSettings->setTilesetCRC(lastCheckedCRCTilesetValue);
|
||||||
|
}
|
||||||
|
|
||||||
reloadFactions(true,(checkBoxScenario.getValue() == true ? scenarioFiles[listBoxScenario.getSelectedItemIndex()] : ""));
|
if(config.getBool("DisableServerLobbyTechtreeCRCCheck","false") == false) {
|
||||||
factionCRCList.clear();
|
if(gameSettings->getTech() != "") {
|
||||||
for(unsigned int factionIdx = 0; factionIdx < factionFiles.size(); ++factionIdx) {
|
// Check if client has different data, if so force a CRC refresh
|
||||||
string factionName = factionFiles[factionIdx];
|
if(checkNetworkPlayerDataSynch(false,false,true) == false &&
|
||||||
if(factionName != GameConstants::RANDOMFACTION_SLOTNAME &&
|
last_Forced_CheckedCRCTechtreeName != gameSettings->getTech()) {
|
||||||
factionName != GameConstants::OBSERVER_SLOTNAME) {
|
lastCheckedCRCTechtreeName = "";
|
||||||
//factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
|
last_Forced_CheckedCRCTechtreeName = gameSettings->getTech();
|
||||||
uint32 factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL);
|
}
|
||||||
if(factionCRC == 0) {
|
|
||||||
factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
|
if(lastCheckedCRCTechtreeName != gameSettings->getTech()) {
|
||||||
}
|
//console.addLine("Checking techtree CRC [" + gameSettings->getTech() + "]");
|
||||||
factionCRCList.push_back(make_pair(factionName,factionCRC));
|
lastCheckedCRCTechtreeValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/*", ".xml", NULL);
|
||||||
|
if(lastCheckedCRCTechtreeValue == 0) {
|
||||||
|
lastCheckedCRCTechtreeValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/*", ".xml", NULL, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadFactions(true,(checkBoxScenario.getValue() == true ? scenarioFiles[listBoxScenario.getSelectedItemIndex()] : ""));
|
||||||
|
factionCRCList.clear();
|
||||||
|
for(unsigned int factionIdx = 0; factionIdx < factionFiles.size(); ++factionIdx) {
|
||||||
|
string factionName = factionFiles[factionIdx];
|
||||||
|
if(factionName != GameConstants::RANDOMFACTION_SLOTNAME &&
|
||||||
|
factionName != GameConstants::OBSERVER_SLOTNAME) {
|
||||||
|
//factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
|
||||||
|
uint32 factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL);
|
||||||
|
if(factionCRC == 0) {
|
||||||
|
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();
|
|
||||||
}
|
}
|
||||||
|
//console.addLine("Found factions: " + intToStr(factionCRCList.size()));
|
||||||
gameSettings->setFactionCRCList(factionCRCList);
|
lastCheckedCRCTechtreeName = gameSettings->getTech();
|
||||||
gameSettings->setTechCRC(lastCheckedCRCTechtreeValue);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(gameSettings->getMap() != "") {
|
gameSettings->setFactionCRCList(factionCRCList);
|
||||||
if(lastCheckedCRCMapName != gameSettings->getMap()) {
|
gameSettings->setTechCRC(lastCheckedCRCTechtreeValue);
|
||||||
Checksum checksum;
|
|
||||||
string file = Map::getMapPath(gameSettings->getMap(),"",false);
|
|
||||||
//console.addLine("Checking map CRC [" + file + "]");
|
|
||||||
checksum.addFile(file);
|
|
||||||
lastCheckedCRCMapValue = checksum.getSum();
|
|
||||||
lastCheckedCRCMapName = gameSettings->getMap();
|
|
||||||
}
|
|
||||||
gameSettings->setMapCRC(lastCheckedCRCMapValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("this->masterserverMode = %d\n",this->masterserverMode);
|
if(gameSettings->getMap() != "") {
|
||||||
|
// Check if client has different data, if so force a CRC refresh
|
||||||
|
if(checkNetworkPlayerDataSynch(true,false,false) == false &&
|
||||||
|
last_Forced_CheckedCRCMapName != gameSettings->getMap()) {
|
||||||
|
lastCheckedCRCMapName = "";
|
||||||
|
last_Forced_CheckedCRCMapName = gameSettings->getMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lastCheckedCRCMapName != gameSettings->getMap()) {
|
||||||
|
Checksum checksum;
|
||||||
|
string file = Map::getMapPath(gameSettings->getMap(),"",false);
|
||||||
|
//console.addLine("Checking map CRC [" + file + "]");
|
||||||
|
checksum.addFile(file);
|
||||||
|
lastCheckedCRCMapValue = checksum.getSum();
|
||||||
|
lastCheckedCRCMapName = gameSettings->getMap();
|
||||||
|
}
|
||||||
|
gameSettings->setMapCRC(lastCheckedCRCMapValue);
|
||||||
|
}
|
||||||
|
|
||||||
if(this->headlessServerMode == true) {
|
if(this->headlessServerMode == true) {
|
||||||
time_t clientConnectedTime = 0;
|
time_t clientConnectedTime = 0;
|
||||||
|
|
|
@ -203,6 +203,11 @@ private:
|
||||||
string lastCheckedCRCTilesetName;
|
string lastCheckedCRCTilesetName;
|
||||||
string lastCheckedCRCTechtreeName;
|
string lastCheckedCRCTechtreeName;
|
||||||
string lastCheckedCRCMapName;
|
string lastCheckedCRCMapName;
|
||||||
|
|
||||||
|
string last_Forced_CheckedCRCTilesetName;
|
||||||
|
string last_Forced_CheckedCRCTechtreeName;
|
||||||
|
string last_Forced_CheckedCRCMapName;
|
||||||
|
|
||||||
uint32 lastCheckedCRCTilesetValue;
|
uint32 lastCheckedCRCTilesetValue;
|
||||||
uint32 lastCheckedCRCTechtreeValue;
|
uint32 lastCheckedCRCTechtreeValue;
|
||||||
uint32 lastCheckedCRCMapValue;
|
uint32 lastCheckedCRCMapValue;
|
||||||
|
@ -291,6 +296,9 @@ private:
|
||||||
void setupTilesetList(string scenario);
|
void setupTilesetList(string scenario);
|
||||||
|
|
||||||
void initFactionPreview(const GameSettings *gameSettings);
|
void initFactionPreview(const GameSettings *gameSettings);
|
||||||
|
|
||||||
|
bool checkNetworkPlayerDataSynch(bool checkMapCRC,bool checkTileSetCRC, bool checkTechTreeCRC);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
Loading…
Reference in New Issue
Block a user