Merge branch 'develop' of github.com:MegaGlest/megaglest-source into feature/hp-bars
This commit is contained in:
commit
034b6066be
|
@ -44,7 +44,7 @@ static const int MAX_PING_LAG_COUNT = 6;
|
||||||
static const double REPROMPT_DOWNLOAD_SECONDS = 7;
|
static const double REPROMPT_DOWNLOAD_SECONDS = 7;
|
||||||
//static const string ITEM_MISSING = "***missing***";
|
//static const string ITEM_MISSING = "***missing***";
|
||||||
// above replaced with Lang::getInstance().getString("DataMissing","",true)
|
// above replaced with Lang::getInstance().getString("DataMissing","",true)
|
||||||
const int HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS = 4;
|
const int HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS = 2;
|
||||||
static const char *HEADLESS_SAVED_GAME_FILENAME = "lastHeadlessGameSettings.mgg";
|
static const char *HEADLESS_SAVED_GAME_FILENAME = "lastHeadlessGameSettings.mgg";
|
||||||
|
|
||||||
const int mapPreviewTexture_X = 5;
|
const int mapPreviewTexture_X = 5;
|
||||||
|
@ -81,6 +81,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
||||||
needToBroadcastServerSettings=false;
|
needToBroadcastServerSettings=false;
|
||||||
broadcastServerSettingsDelayTimer=0;
|
broadcastServerSettingsDelayTimer=0;
|
||||||
lastGameSettingsReceivedCount=0;
|
lastGameSettingsReceivedCount=0;
|
||||||
|
noReceiveTimer=time(NULL)-100; // old but inititialized ( must be an "old" time )
|
||||||
|
|
||||||
soundConnectionCount=0;
|
soundConnectionCount=0;
|
||||||
|
|
||||||
|
@ -132,6 +133,9 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
||||||
settingsReceivedFromServer=false;
|
settingsReceivedFromServer=false;
|
||||||
initialSettingsReceivedFromServer=false;
|
initialSettingsReceivedFromServer=false;
|
||||||
|
|
||||||
|
validOriginalGameSettings=false;
|
||||||
|
validDisplayedGamesettings=false;
|
||||||
|
|
||||||
returnMenuInfo=joinMenuInfo;
|
returnMenuInfo=joinMenuInfo;
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
|
@ -1531,6 +1535,7 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
switchSetupRequestFlagType,
|
switchSetupRequestFlagType,
|
||||||
lang.getLanguage());
|
lang.getLanguage());
|
||||||
switchSetupRequestFlagType= ssrft_None;
|
switchSetupRequestFlagType= ssrft_None;
|
||||||
|
noReceiveTimer=time(NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1724,14 +1729,17 @@ void MenuStateConnectedGame::broadCastGameSettingsToHeadlessServer(bool forceNow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameSettings gameSettings = *clientInterface->getGameSettings();
|
if(validDisplayedGamesettings){
|
||||||
loadGameSettings(&gameSettings);
|
loadGameSettings(&displayedGamesettings);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("broadcast settings:\n%s\n",gameSettings.toString().c_str());
|
|
||||||
|
|
||||||
//printf("Client sending map [%s] admin key [%d]\n",gameSettings.getMap().c_str(),gameSettings.getMasterserver_admin());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("broadcast settings:\n%s\n",displayedGamesettings.toString().c_str());
|
||||||
|
|
||||||
clientInterface->broadcastGameSetup(&gameSettings);
|
//printf("Client sending map [%s] admin key [%d]\n",gameSettings.getMap().c_str(),gameSettings.getMasterserver_admin());
|
||||||
|
|
||||||
|
clientInterface->broadcastGameSetup(&displayedGamesettings);
|
||||||
|
noReceiveTimer=time(NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2510,10 +2518,8 @@ void MenuStateConnectedGame::render() {
|
||||||
delete factionVideo;
|
delete factionVideo;
|
||||||
factionVideo = NULL;
|
factionVideo = NULL;
|
||||||
|
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
if(validDisplayedGamesettings) {
|
||||||
ClientInterface* clientInterface= networkManager.getClientInterface();
|
initFactionPreview(&displayedGamesettings);
|
||||||
if(clientInterface != NULL) {
|
|
||||||
initFactionPreview(clientInterface->getGameSettings());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2827,6 +2833,21 @@ void MenuStateConnectedGame::update() {
|
||||||
//printf("#2 admin key [%d] client key [%d]\n",settings->getMasterserver_admin(),clientInterface->getSessionKey());
|
//printf("#2 admin key [%d] client key [%d]\n",settings->getMasterserver_admin(),clientInterface->getSessionKey());
|
||||||
broadCastGameSettingsToHeadlessServer(false);
|
broadCastGameSettingsToHeadlessServer(false);
|
||||||
|
|
||||||
|
bool notCurrentlySwitching=(( difftime((long int) time(NULL), broadcastServerSettingsDelayTimer)) >= HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS );
|
||||||
|
bool receiveAllowedNow=difftime((long int) time(NULL), noReceiveTimer) > 2 ;
|
||||||
|
bool newMessage= lastGameSettingsReceivedCount < clientInterface->getGameSettingsReceivedCount();
|
||||||
|
if (validDisplayedGamesettings == false
|
||||||
|
|| ( notCurrentlySwitching
|
||||||
|
&& newMessage
|
||||||
|
&& receiveAllowedNow )) {
|
||||||
|
|
||||||
|
//printf("I take the whole settings top broadcastDelay=%d noReceiveTimer=%d\n", (int)difftime((long int) time(NULL), broadcastServerSettingsDelayTimer),(int)difftime((long int) time(NULL), noReceiveTimer));
|
||||||
|
|
||||||
|
displayedGamesettings = *(clientInterface->getGameSettings());
|
||||||
|
originalGamesettings = displayedGamesettings;
|
||||||
|
validDisplayedGamesettings = true;
|
||||||
|
}
|
||||||
|
|
||||||
checkBoxAllowNativeLanguageTechtree.setEditable(isHeadlessAdmin());
|
checkBoxAllowNativeLanguageTechtree.setEditable(isHeadlessAdmin());
|
||||||
checkBoxAllowNativeLanguageTechtree.setEnabled(isHeadlessAdmin());
|
checkBoxAllowNativeLanguageTechtree.setEnabled(isHeadlessAdmin());
|
||||||
|
|
||||||
|
@ -2874,7 +2895,7 @@ 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__));
|
||||||
if(fileFTPProgressList.empty() == true) {
|
if(fileFTPProgressList.empty() == true) {
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
const vector<string> languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
const vector<string> languageList = displayedGamesettings.getUniqueNetworkPlayerLanguages();
|
||||||
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
for(unsigned int i = 0; i < languageList.size(); ++i) {
|
||||||
clientInterface->sendTextMessage(lang.getString("ConnectionTimedOut",languageList[i]) + " : " + doubleToStr(clientInterface->getLastPingLag(),2),-1,false,languageList[i]);
|
clientInterface->sendTextMessage(lang.getString("ConnectionTimedOut",languageList[i]) + " : " + doubleToStr(clientInterface->getLastPingLag(),2),-1,false,languageList[i]);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
@ -2887,13 +2908,6 @@ void MenuStateConnectedGame::update() {
|
||||||
pingCount++;
|
pingCount++;
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
|
||||||
|
|
||||||
//update status label
|
|
||||||
if(clientInterface != NULL && clientInterface->isConnected()) {
|
|
||||||
buttonDisconnect.setText(lang.getString("Disconnect"));
|
buttonDisconnect.setText(lang.getString("Disconnect"));
|
||||||
|
|
||||||
if(clientInterface->getAllowDownloadDataSynch() == false) {
|
if(clientInterface->getAllowDownloadDataSynch() == false) {
|
||||||
|
@ -2905,64 +2919,63 @@ void MenuStateConnectedGame::update() {
|
||||||
|
|
||||||
label = label + ", " + clientInterface->getVersionString();
|
label = label + ", " + clientInterface->getVersionString();
|
||||||
|
|
||||||
const GameSettings *gameSettings = clientInterface->getGameSettings();
|
|
||||||
if(clientInterface->getAllowGameDataSynchCheck() == false &&
|
if(clientInterface->getAllowGameDataSynchCheck() == false &&
|
||||||
gameSettings->getTileset() != "" &&
|
displayedGamesettings.getTileset() != "" &&
|
||||||
gameSettings->getTech() != "" &&
|
displayedGamesettings.getTech() != "" &&
|
||||||
gameSettings->getMap() != "") {
|
displayedGamesettings.getMap() != "") {
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
|
||||||
MutexSafeWrapper safeMutexFTPProgress(ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
MutexSafeWrapper safeMutexFTPProgress(ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||||
|
|
||||||
uint32 tilesetCRC = lastCheckedCRCTilesetValue;
|
uint32 tilesetCRC = lastCheckedCRCTilesetValue;
|
||||||
if(lastCheckedCRCTilesetName != gameSettings->getTileset() &&
|
if(lastCheckedCRCTilesetName != displayedGamesettings.getTileset() &&
|
||||||
gameSettings->getTileset() != "") {
|
displayedGamesettings.getTileset() != "") {
|
||||||
//console.addLine("Checking tileset CRC [" + gameSettings->getTileset() + "]");
|
//console.addLine("Checking tileset CRC [" + displayedGamesettings.getTileset() + "]");
|
||||||
tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL);
|
tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + displayedGamesettings.getTileset() + string("/*"), ".xml", NULL);
|
||||||
if(tilesetCRC == 0 || tilesetCRC != gameSettings->getTilesetCRC()) {
|
if(tilesetCRC == 0 || tilesetCRC != displayedGamesettings.getTilesetCRC()) {
|
||||||
tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL, true);
|
tilesetCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + displayedGamesettings.getTileset() + string("/*"), ".xml", NULL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test data synch
|
// Test data synch
|
||||||
//tilesetCRC++;
|
//tilesetCRC++;
|
||||||
lastCheckedCRCTilesetValue = tilesetCRC;
|
lastCheckedCRCTilesetValue = tilesetCRC;
|
||||||
lastCheckedCRCTilesetName = gameSettings->getTileset();
|
lastCheckedCRCTilesetName = displayedGamesettings.getTileset();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 techCRC = lastCheckedCRCTechtreeValue;
|
uint32 techCRC = lastCheckedCRCTechtreeValue;
|
||||||
if(lastCheckedCRCTechtreeName != gameSettings->getTech() &&
|
if(lastCheckedCRCTechtreeName != displayedGamesettings.getTech() &&
|
||||||
gameSettings->getTech() != "") {
|
displayedGamesettings.getTech() != "") {
|
||||||
//console.addLine("Checking techtree CRC [" + gameSettings->getTech() + "]");
|
//console.addLine("Checking techtree CRC [" + displayedGamesettings.getTech() + "]");
|
||||||
techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), string("/") + gameSettings->getTech() + string("/*"), ".xml", NULL);
|
techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), string("/") + displayedGamesettings.getTech() + string("/*"), ".xml", NULL);
|
||||||
//clientInterface->sendTextMessage("#1 TechCRC = " + intToStr(techCRC) + " remoteCRC = " + intToStr(gameSettings->getTechCRC()),-1, true, "");
|
//clientInterface->sendTextMessage("#1 TechCRC = " + intToStr(techCRC) + " remoteCRC = " + intToStr(displayedGamesettings.getTechCRC()),-1, true, "");
|
||||||
|
|
||||||
if(techCRC == 0 || techCRC != gameSettings->getTechCRC()) {
|
if(techCRC == 0 || techCRC != displayedGamesettings.getTechCRC()) {
|
||||||
techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), string("/") + gameSettings->getTech() + string("/*"), ".xml", NULL, true);
|
techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), string("/") + displayedGamesettings.getTech() + string("/*"), ".xml", NULL, true);
|
||||||
//clientInterface->sendTextMessage("#2 TechCRC = " + intToStr(techCRC) + " remoteCRC = " + intToStr(gameSettings->getTechCRC()),-1, true, "");
|
//clientInterface->sendTextMessage("#2 TechCRC = " + intToStr(techCRC) + " remoteCRC = " + intToStr(displayedGamesettings.getTechCRC()),-1, true, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(techCRC != 0 && techCRC != gameSettings->getTechCRC() &&
|
if(techCRC != 0 && techCRC != displayedGamesettings.getTechCRC() &&
|
||||||
listBoxTechTree.getSelectedItemIndex() >= 0 &&
|
listBoxTechTree.getSelectedItemIndex() >= 0 &&
|
||||||
listBoxTechTree.getSelectedItem() != Lang::getInstance().getString("DataMissing","",true)) {
|
listBoxTechTree.getSelectedItem() != Lang::getInstance().getString("DataMissing","",true)) {
|
||||||
|
|
||||||
//time_t now = time(NULL);
|
//time_t now = time(NULL);
|
||||||
time_t lastUpdateDate = getFolderTreeContentsCheckSumRecursivelyLastGenerated(config.getPathListForType(ptTechs,""), string("/") + gameSettings->getTech() + string("/*"), ".xml");
|
time_t lastUpdateDate = getFolderTreeContentsCheckSumRecursivelyLastGenerated(config.getPathListForType(ptTechs,""), string("/") + displayedGamesettings.getTech() + string("/*"), ".xml");
|
||||||
|
|
||||||
const time_t REFRESH_CRC_DAY_SECONDS = 60 * 60 * 1;
|
const time_t REFRESH_CRC_DAY_SECONDS = 60 * 60 * 1;
|
||||||
if( lastUpdateDate <= 0 ||
|
if( lastUpdateDate <= 0 ||
|
||||||
difftime((long int)time(NULL),lastUpdateDate) >= REFRESH_CRC_DAY_SECONDS) {
|
difftime((long int)time(NULL),lastUpdateDate) >= REFRESH_CRC_DAY_SECONDS) {
|
||||||
techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), string("/") + gameSettings->getTech() + string("/*"), ".xml", NULL, true);
|
techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), string("/") + displayedGamesettings.getTech() + string("/*"), ".xml", NULL, true);
|
||||||
//clientInterface->sendTextMessage("#3 TechCRC = " + intToStr(techCRC) + " remoteCRC = " + intToStr(gameSettings->getTechCRC()),-1, true, "");
|
//clientInterface->sendTextMessage("#3 TechCRC = " + intToStr(techCRC) + " remoteCRC = " + intToStr(displayedGamesettings.getTechCRC()),-1, true, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test data synch
|
// Test data synch
|
||||||
//techCRC++;
|
//techCRC++;
|
||||||
lastCheckedCRCTechtreeValue = techCRC;
|
lastCheckedCRCTechtreeValue = techCRC;
|
||||||
lastCheckedCRCTechtreeName = gameSettings->getTech();
|
lastCheckedCRCTechtreeName = displayedGamesettings.getTech();
|
||||||
|
|
||||||
loadFactions(gameSettings,false);
|
loadFactions(&displayedGamesettings,false);
|
||||||
factionCRCList.clear();
|
factionCRCList.clear();
|
||||||
for(unsigned int factionIdx = 0; factionIdx < factionFiles.size(); ++factionIdx) {
|
for(unsigned int factionIdx = 0; factionIdx < factionFiles.size(); ++factionIdx) {
|
||||||
string factionName = factionFiles[factionIdx];
|
string factionName = factionFiles[factionIdx];
|
||||||
|
@ -2972,28 +2985,28 @@ void MenuStateConnectedGame::update() {
|
||||||
|
|
||||||
uint32 factionCRC = 0;
|
uint32 factionCRC = 0;
|
||||||
//time_t now = time(NULL);
|
//time_t now = time(NULL);
|
||||||
time_t lastUpdateDate = getFolderTreeContentsCheckSumRecursivelyLastGenerated(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml");
|
time_t lastUpdateDate = getFolderTreeContentsCheckSumRecursivelyLastGenerated(config.getPathListForType(ptTechs,""), "/" + displayedGamesettings.getTech() + "/factions/" + factionName + "/*", ".xml");
|
||||||
|
|
||||||
const time_t REFRESH_CRC_DAY_SECONDS = 60 * 60 * 24;
|
const time_t REFRESH_CRC_DAY_SECONDS = 60 * 60 * 24;
|
||||||
if( lastUpdateDate <= 0 ||
|
if( lastUpdateDate <= 0 ||
|
||||||
difftime((long int)time(NULL),lastUpdateDate) >= REFRESH_CRC_DAY_SECONDS ||
|
difftime((long int)time(NULL),lastUpdateDate) >= REFRESH_CRC_DAY_SECONDS ||
|
||||||
(techCRC != 0 && techCRC != gameSettings->getTechCRC())) {
|
(techCRC != 0 && techCRC != displayedGamesettings.getTechCRC())) {
|
||||||
factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
|
factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + displayedGamesettings.getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL);
|
factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + displayedGamesettings.getTech() + "/factions/" + factionName + "/*", ".xml", NULL);
|
||||||
}
|
}
|
||||||
if(factionCRC == 0) {
|
if(factionCRC == 0) {
|
||||||
factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
|
factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + displayedGamesettings.getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(factionCRC != 0) {
|
if(factionCRC != 0) {
|
||||||
vector<pair<string,uint32> > serverFactionCRCList = gameSettings->getFactionCRCList();
|
vector<pair<string,uint32> > serverFactionCRCList = displayedGamesettings.getFactionCRCList();
|
||||||
for(unsigned int factionIdx1 = 0; factionIdx1 < serverFactionCRCList.size(); ++factionIdx1) {
|
for(unsigned int factionIdx1 = 0; factionIdx1 < serverFactionCRCList.size(); ++factionIdx1) {
|
||||||
pair<string,uint32> &serverFaction = serverFactionCRCList[factionIdx1];
|
pair<string,uint32> &serverFaction = serverFactionCRCList[factionIdx1];
|
||||||
if(serverFaction.first == factionName) {
|
if(serverFaction.first == factionName) {
|
||||||
if(serverFaction.second != factionCRC) {
|
if(serverFaction.second != factionCRC) {
|
||||||
factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
|
factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + displayedGamesettings.getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3006,10 +3019,10 @@ void MenuStateConnectedGame::update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 mapCRC = lastCheckedCRCMapValue;
|
uint32 mapCRC = lastCheckedCRCMapValue;
|
||||||
if(lastCheckedCRCMapName != gameSettings->getMap() &&
|
if(lastCheckedCRCMapName != displayedGamesettings.getMap() &&
|
||||||
gameSettings->getMap() != "") {
|
displayedGamesettings.getMap() != "") {
|
||||||
Checksum checksum;
|
Checksum checksum;
|
||||||
string file = Config::getMapPath(gameSettings->getMap(),"",false);
|
string file = Config::getMapPath(displayedGamesettings.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();
|
||||||
|
@ -3017,22 +3030,23 @@ void MenuStateConnectedGame::update() {
|
||||||
//mapCRC++;
|
//mapCRC++;
|
||||||
|
|
||||||
lastCheckedCRCMapValue = mapCRC;
|
lastCheckedCRCMapValue = mapCRC;
|
||||||
lastCheckedCRCMapName = gameSettings->getMap();
|
lastCheckedCRCMapName = displayedGamesettings.getMap();
|
||||||
}
|
}
|
||||||
safeMutexFTPProgress.ReleaseLock();
|
safeMutexFTPProgress.ReleaseLock();
|
||||||
|
|
||||||
bool dataSynchMismatch = ((mapCRC != 0 && mapCRC != gameSettings->getMapCRC()) ||
|
bool dataSynchMismatch = ((mapCRC != 0 && mapCRC != displayedGamesettings.getMapCRC()) ||
|
||||||
(tilesetCRC != 0 && tilesetCRC != gameSettings->getTilesetCRC()) ||
|
(tilesetCRC != 0 && tilesetCRC != displayedGamesettings.getTilesetCRC()) ||
|
||||||
(techCRC != 0 && techCRC != gameSettings->getTechCRC()));
|
(techCRC != 0 && techCRC != displayedGamesettings.getTechCRC()));
|
||||||
|
|
||||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nmapCRC [%d] gameSettings->getMapCRC() [%d]\ntilesetCRC [%d] gameSettings->getTilesetCRC() [%d]\ntechCRC [%d] gameSettings->getTechCRC() [%d]\n",mapCRC,gameSettings->getMapCRC(),tilesetCRC,gameSettings->getTilesetCRC(),techCRC,gameSettings->getTechCRC());
|
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\nmapCRC [%d] displayedGamesettings.getMapCRC() [%d]\ntilesetCRC [%d] displayedGamesettings.getTilesetCRC() [%d]\ntechCRC [%d] displayedGamesettings.getTechCRC() [%d]\n",mapCRC,displayedGamesettings.getMapCRC(),tilesetCRC,displayedGamesettings.getTilesetCRC(),techCRC,displayedGamesettings.getTechCRC());
|
||||||
|
|
||||||
if(dataSynchMismatch == true) {
|
if(dataSynchMismatch == true &&
|
||||||
//printf("Data not synched: lmap %u rmap: %u ltile: %d rtile: %u ltech: %u rtech: %u\n",mapCRC,gameSettings->getMapCRC(),tilesetCRC,gameSettings->getTilesetCRC(),techCRC,gameSettings->getTechCRC());
|
( difftime((long int)time(NULL),broadcastServerSettingsDelayTimer) >= HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS)) {
|
||||||
|
//printf("Data not synched: lmap %u rmap: %u ltile: %d rtile: %u ltech: %u rtech: %u\n",mapCRC,displayedGamesettings.getMapCRC(),tilesetCRC,displayedGamesettings.getTilesetCRC(),techCRC,displayedGamesettings.getTechCRC());
|
||||||
|
|
||||||
string labelSynch = lang.getString("DataNotSynchedTitle");
|
string labelSynch = lang.getString("DataNotSynchedTitle");
|
||||||
|
|
||||||
if(mapCRC != 0 && mapCRC != gameSettings->getMapCRC() &&
|
if(mapCRC != 0 && mapCRC != displayedGamesettings.getMapCRC() &&
|
||||||
listBoxMap.getSelectedItemIndex() >= 0 &&
|
listBoxMap.getSelectedItemIndex() >= 0 &&
|
||||||
listBoxMap.getSelectedItem() != Lang::getInstance().getString("DataMissing","",true)) {
|
listBoxMap.getSelectedItem() != Lang::getInstance().getString("DataMissing","",true)) {
|
||||||
labelSynch = labelSynch + " " + lang.getString("Map");
|
labelSynch = labelSynch + " " + lang.getString("Map");
|
||||||
|
@ -3051,7 +3065,7 @@ void MenuStateConnectedGame::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tilesetCRC != 0 && tilesetCRC != gameSettings->getTilesetCRC() &&
|
if(tilesetCRC != 0 && tilesetCRC != displayedGamesettings.getTilesetCRC() &&
|
||||||
listBoxTileset.getSelectedItemIndex() >= 0 &&
|
listBoxTileset.getSelectedItemIndex() >= 0 &&
|
||||||
listBoxTileset.getSelectedItem() != Lang::getInstance().getString("DataMissing","",true)) {
|
listBoxTileset.getSelectedItem() != Lang::getInstance().getString("DataMissing","",true)) {
|
||||||
labelSynch = labelSynch + " " + lang.getString("Tileset");
|
labelSynch = labelSynch + " " + lang.getString("Tileset");
|
||||||
|
@ -3069,7 +3083,7 @@ void MenuStateConnectedGame::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(techCRC != 0 && techCRC != gameSettings->getTechCRC() &&
|
if(techCRC != 0 && techCRC != displayedGamesettings.getTechCRC() &&
|
||||||
listBoxTechTree.getSelectedItemIndex() >= 0 &&
|
listBoxTechTree.getSelectedItemIndex() >= 0 &&
|
||||||
listBoxTechTree.getSelectedItem() != Lang::getInstance().getString("DataMissing","",true)) {
|
listBoxTechTree.getSelectedItem() != Lang::getInstance().getString("DataMissing","",true)) {
|
||||||
labelSynch = labelSynch + " " + lang.getString("TechTree");
|
labelSynch = labelSynch + " " + lang.getString("TechTree");
|
||||||
|
@ -3092,7 +3106,7 @@ void MenuStateConnectedGame::update() {
|
||||||
|
|
||||||
string mismatchedFactionText = "";
|
string mismatchedFactionText = "";
|
||||||
vector<string> mismatchedFactionTextList;
|
vector<string> mismatchedFactionTextList;
|
||||||
vector<pair<string,uint32> > serverFactionCRCList = gameSettings->getFactionCRCList();
|
vector<pair<string,uint32> > serverFactionCRCList = displayedGamesettings.getFactionCRCList();
|
||||||
|
|
||||||
for(unsigned int factionIdx = 0; factionIdx < serverFactionCRCList.size(); ++factionIdx) {
|
for(unsigned int factionIdx = 0; factionIdx < serverFactionCRCList.size(); ++factionIdx) {
|
||||||
pair<string,uint32> &serverFaction = serverFactionCRCList[factionIdx];
|
pair<string,uint32> &serverFaction = serverFactionCRCList[factionIdx];
|
||||||
|
@ -3332,18 +3346,67 @@ void MenuStateConnectedGame::update() {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(clientInterface->getGameSettingsReceived() &&
|
if(clientInterface->getGameSettingsReceived() && validDisplayedGamesettings &&
|
||||||
lastGameSettingsReceivedCount != clientInterface->getGameSettingsReceivedCount()) {
|
lastGameSettingsReceivedCount != clientInterface->getGameSettingsReceivedCount()) {
|
||||||
broadCastGameSettingsToHeadlessServer(needToBroadcastServerSettings);
|
|
||||||
|
|
||||||
lastGameSettingsReceivedCount = clientInterface->getGameSettingsReceivedCount();
|
lastGameSettingsReceivedCount = clientInterface->getGameSettingsReceivedCount();
|
||||||
bool errorOnMissingData = (clientInterface->getAllowGameDataSynchCheck() == false);
|
bool errorOnMissingData = (clientInterface->getAllowGameDataSynchCheck() == false);
|
||||||
GameSettings *gameSettings = clientInterface->getGameSettingsPtr();
|
|
||||||
|
|
||||||
//printf("Menu got new settings thisfactionindex = %d startlocation: %d control = %d\n",gameSettings->getThisFactionIndex(),clientInterface->getGameSettings()->getStartLocationIndex(clientInterface->getGameSettings()->getThisFactionIndex()),gameSettings->getFactionControl(clientInterface->getGameSettings()->getThisFactionIndex()));
|
const GameSettings *receivedGameSettings= clientInterface->getGameSettings();
|
||||||
if ( difftime((long int)time(NULL),broadcastServerSettingsDelayTimer) >= HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS){
|
|
||||||
setupUIFromGameSettings(gameSettings, errorOnMissingData);
|
//printf("Menu got new settings thisfactionindex = %d startlocation: %d control = %d\n",displayedGamesettings.getThisFactionIndex(),clientInterface->getGameSettings()->getStartLocationIndex(clientInterface->getGameSettings()->getThisFactionIndex()),displayedGamesettings.getFactionControl(clientInterface->getGameSettings()->getThisFactionIndex()));
|
||||||
|
if ( difftime((long int)time(NULL),noReceiveTimer) < 3 || difftime((long int)time(NULL),broadcastServerSettingsDelayTimer) < HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS){
|
||||||
|
// copy my current settings in UI to displayedSettings;
|
||||||
|
loadGameSettings(&displayedGamesettings);
|
||||||
|
// check if there are any changed fields from others clients
|
||||||
|
if(isHeadlessAdmin()){
|
||||||
|
//printf("I am headless admin and will restore only some parts\n");
|
||||||
|
// only copy those parts which are editable by normal clients
|
||||||
|
for (int i=0;i<receivedGameSettings->getFactionCount();i++){
|
||||||
|
if(displayedGamesettings.getFactionControl(i)==ctNetwork){
|
||||||
|
if(originalGamesettings.getTeam(i)==displayedGamesettings.getTeam(i)){
|
||||||
|
displayedGamesettings.setTeam(i,receivedGameSettings->getTeam(i));
|
||||||
|
originalGamesettings.setTeam(i,receivedGameSettings->getTeam(i));
|
||||||
|
}
|
||||||
|
if(originalGamesettings.getFactionTypeName(i)==displayedGamesettings.getFactionTypeName(i)){
|
||||||
|
displayedGamesettings.setFactionTypeName(i,receivedGameSettings->getFactionTypeName(i));
|
||||||
|
originalGamesettings.setFactionTypeName(i,receivedGameSettings->getFactionTypeName(i));
|
||||||
|
}
|
||||||
|
displayedGamesettings.setNetworkPlayerGameStatus(i,receivedGameSettings->getNetworkPlayerGameStatus(i));
|
||||||
|
originalGamesettings.setNetworkPlayerGameStatus(i,receivedGameSettings->getNetworkPlayerGameStatus(i));
|
||||||
|
displayedGamesettings.setNetworkPlayerName(i,receivedGameSettings->getNetworkPlayerName(i));
|
||||||
|
originalGamesettings.setNetworkPlayerName(i,receivedGameSettings->getNetworkPlayerName(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//printf("I am client and restore everything but not my line\n");
|
||||||
|
// copy all received fields just not those which are editable for normal client
|
||||||
|
//store my changes
|
||||||
|
int i=clientInterface->getPlayerIndex();
|
||||||
|
int team=displayedGamesettings.getTeam(i);
|
||||||
|
string faction=displayedGamesettings.getFactionTypeName(i);
|
||||||
|
int status=displayedGamesettings.getNetworkPlayerGameStatus(i);
|
||||||
|
string networkPlayerName=displayedGamesettings.getNetworkPlayerName(i);
|
||||||
|
displayedGamesettings=*receivedGameSettings;
|
||||||
|
originalGamesettings=*receivedGameSettings;
|
||||||
|
|
||||||
|
displayedGamesettings.setTeam(i,team);
|
||||||
|
originalGamesettings.setTeam(i,team);
|
||||||
|
displayedGamesettings.setFactionTypeName(i,faction);
|
||||||
|
originalGamesettings.setFactionTypeName(i,faction);
|
||||||
|
displayedGamesettings.setNetworkPlayerGameStatus(i,status);
|
||||||
|
originalGamesettings.setNetworkPlayerGameStatus(i,status);
|
||||||
|
displayedGamesettings.setNetworkPlayerName(i,networkPlayerName);
|
||||||
|
originalGamesettings.setNetworkPlayerName(i,networkPlayerName);
|
||||||
|
|
||||||
|
}
|
||||||
|
setupUIFromGameSettings(&displayedGamesettings, errorOnMissingData);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// do nothing
|
||||||
|
setupUIFromGameSettings(&displayedGamesettings, errorOnMissingData);
|
||||||
|
}
|
||||||
|
broadCastGameSettingsToHeadlessServer(needToBroadcastServerSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we are joining an in progress game
|
// check if we are joining an in progress game
|
||||||
|
@ -3490,12 +3553,11 @@ void MenuStateConnectedGame::update() {
|
||||||
|
|
||||||
// check for need to switch music on again
|
// check for need to switch music on again
|
||||||
if(clientInterface != NULL) {
|
if(clientInterface != NULL) {
|
||||||
GameSettings *gameSettings = clientInterface->getGameSettingsPtr();
|
|
||||||
int currentConnectionCount=0;
|
int currentConnectionCount=0;
|
||||||
for(int i=0; i < GameConstants::maxPlayers; ++i) {
|
for(int i=0; i < GameConstants::maxPlayers; ++i) {
|
||||||
if(gameSettings->getFactionControl(i)==ctNetwork &&
|
if(displayedGamesettings.getFactionControl(i)==ctNetwork &&
|
||||||
gameSettings->getNetworkPlayerName(i) != "" &&
|
displayedGamesettings.getNetworkPlayerName(i) != "" &&
|
||||||
gameSettings->getNetworkPlayerName(i) != GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME)
|
displayedGamesettings.getNetworkPlayerName(i) != GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME)
|
||||||
{
|
{
|
||||||
currentConnectionCount++;
|
currentConnectionCount++;
|
||||||
}
|
}
|
||||||
|
@ -3828,13 +3890,14 @@ bool MenuStateConnectedGame::loadMapInfo(string file, MapInfo *mapInfo, bool loa
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
if(MapPreview::loadMapInfo(file, mapInfo, lang.getString("MaxPlayers"),lang.getString("Size"),true) == true) {
|
if(MapPreview::loadMapInfo(file, mapInfo, lang.getString("MaxPlayers"),lang.getString("Size"),true) == true) {
|
||||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||||
labelPlayers[i].setVisible(i+1 <= mapInfo->players);
|
bool visible=i+1 <= mapInfo->players;
|
||||||
labelPlayerNames[i].setVisible(i+1 <= mapInfo->players);
|
labelPlayers[i].setVisible(visible);
|
||||||
listBoxControls[i].setVisible(i+1 <= mapInfo->players);
|
labelPlayerNames[i].setVisible(visible);
|
||||||
listBoxRMultiplier[i].setVisible(i+1 <= mapInfo->players);
|
listBoxControls[i].setVisible(visible);
|
||||||
listBoxFactions[i].setVisible(i+1 <= mapInfo->players);
|
listBoxRMultiplier[i].setVisible(visible);
|
||||||
listBoxTeams[i].setVisible(i+1 <= mapInfo->players);
|
listBoxFactions[i].setVisible(visible);
|
||||||
labelNetStatus[i].setVisible(i+1 <= mapInfo->players);
|
listBoxTeams[i].setVisible(visible);
|
||||||
|
labelNetStatus[i].setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not painting properly so this is on hold
|
// Not painting properly so this is on hold
|
||||||
|
@ -4401,6 +4464,7 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
|
||||||
throw megaglest_runtime_error("gameSettings == NULL");
|
throw megaglest_runtime_error("gameSettings == NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
checkBoxScenario.setValue((gameSettings->getScenario() != ""));
|
checkBoxScenario.setValue((gameSettings->getScenario() != ""));
|
||||||
if(checkBoxScenario.getValue() == true) {
|
if(checkBoxScenario.getValue() == true) {
|
||||||
int originalFOWValue = listBoxFogOfWar.getSelectedItemIndex();
|
int originalFOWValue = listBoxFogOfWar.getSelectedItemIndex();
|
||||||
|
@ -4441,8 +4505,8 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
|
||||||
//listBoxMap.setItems(formattedPlayerSortedMaps[gameSettings.getMapFilterIndex()]);
|
//listBoxMap.setItems(formattedPlayerSortedMaps[gameSettings.getMapFilterIndex()]);
|
||||||
//printf("A gameSettings->getTileset() [%s]\n",gameSettings->getTileset().c_str());
|
//printf("A gameSettings->getTileset() [%s]\n",gameSettings->getTileset().c_str());
|
||||||
|
|
||||||
if(getMissingTilesetFromFTPServerInProgress == false &&
|
if ( getMissingTilesetFromFTPServerInProgress == false
|
||||||
gameSettings->getTileset() != "") {
|
&& gameSettings->getTileset() != "") {
|
||||||
// tileset
|
// tileset
|
||||||
tilesets = tilesetFiles;
|
tilesets = tilesetFiles;
|
||||||
std::for_each(tilesets.begin(), tilesets.end(), FormatString());
|
std::for_each(tilesets.begin(), tilesets.end(), FormatString());
|
||||||
|
@ -4602,6 +4666,7 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
|
||||||
loadFactions(gameSettings,false);
|
loadFactions(gameSettings,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(getMissingMapFromFTPServerInProgress == false &&
|
if(getMissingMapFromFTPServerInProgress == false &&
|
||||||
gameSettings->getMap() != "") {
|
gameSettings->getMap() != "") {
|
||||||
// map
|
// map
|
||||||
|
@ -4714,6 +4779,8 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
|
||||||
checkBoxAllowTeamResourceSharing.setValue(false);
|
checkBoxAllowTeamResourceSharing.setValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkBoxAllowNativeLanguageTechtree.setValue(gameSettings->getNetworkAllowNativeLanguageTechtree());
|
||||||
|
|
||||||
// Control
|
// Control
|
||||||
for(int i=0; i<GameConstants::maxPlayers; ++i) {
|
for(int i=0; i<GameConstants::maxPlayers; ++i) {
|
||||||
listBoxControls[i].setSelectedItemIndex(ctClosed);
|
listBoxControls[i].setSelectedItemIndex(ctClosed);
|
||||||
|
@ -4777,9 +4844,9 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
|
||||||
|
|
||||||
listBoxControls[slot].setSelectedItemIndex(gameSettings->getFactionControl(i),errorOnMissingData);
|
listBoxControls[slot].setSelectedItemIndex(gameSettings->getFactionControl(i),errorOnMissingData);
|
||||||
listBoxRMultiplier[slot].setSelectedItemIndex(gameSettings->getResourceMultiplierIndex(i),errorOnMissingData);
|
listBoxRMultiplier[slot].setSelectedItemIndex(gameSettings->getResourceMultiplierIndex(i),errorOnMissingData);
|
||||||
|
|
||||||
listBoxTeams[slot].setSelectedItemIndex(gameSettings->getTeam(i),errorOnMissingData);
|
listBoxTeams[slot].setSelectedItemIndex(gameSettings->getTeam(i),errorOnMissingData);
|
||||||
listBoxFactions[slot].setSelectedItem(formatString(gameSettings->getFactionTypeName(i)),false);
|
listBoxFactions[slot].setSelectedItem(formatString(gameSettings->getFactionTypeName(i)),false);
|
||||||
|
|
||||||
if( gameSettings->getFactionControl(i) == ctNetwork ||
|
if( gameSettings->getFactionControl(i) == ctNetwork ||
|
||||||
gameSettings->getFactionControl(i) == ctNetworkUnassigned) {
|
gameSettings->getFactionControl(i) == ctNetworkUnassigned) {
|
||||||
labelNetStatus[slot].setText(gameSettings->getNetworkPlayerName(i));
|
labelNetStatus[slot].setText(gameSettings->getNetworkPlayerName(i));
|
||||||
|
@ -4821,13 +4888,12 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
|
||||||
labelPlayerNames[slot].setText(gameSettings->getNetworkPlayerName(i));
|
labelPlayerNames[slot].setText(gameSettings->getNetworkPlayerName(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsReceivedFromServer=true;
|
|
||||||
initialSettingsReceivedFromServer=true;
|
|
||||||
|
|
||||||
needToSetChangedGameSettings = true;
|
|
||||||
lastSetChangedGameSettings = time(NULL);
|
|
||||||
}
|
}
|
||||||
|
settingsReceivedFromServer=true;
|
||||||
|
initialSettingsReceivedFromServer=true;
|
||||||
|
|
||||||
|
needToSetChangedGameSettings = true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(enableFactionTexturePreview == true) {
|
if(enableFactionTexturePreview == true) {
|
||||||
|
@ -4845,7 +4911,6 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkBoxAllowNativeLanguageTechtree.setValue(gameSettings->getNetworkAllowNativeLanguageTechtree());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateConnectedGame::initFactionPreview(const GameSettings *gameSettings) {
|
void MenuStateConnectedGame::initFactionPreview(const GameSettings *gameSettings) {
|
||||||
|
@ -4956,6 +5021,7 @@ void MenuStateConnectedGame::RestoreLastGameSettings() {
|
||||||
|
|
||||||
needToBroadcastServerSettings=true;
|
needToBroadcastServerSettings=true;
|
||||||
broadcastServerSettingsDelayTimer=time(NULL);
|
broadcastServerSettingsDelayTimer=time(NULL);
|
||||||
|
noReceiveTimer=time(NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,9 +238,17 @@ private:
|
||||||
time_t broadcastServerSettingsDelayTimer;
|
time_t broadcastServerSettingsDelayTimer;
|
||||||
int lastGameSettingsReceivedCount;
|
int lastGameSettingsReceivedCount;
|
||||||
|
|
||||||
|
time_t noReceiveTimer;
|
||||||
|
|
||||||
bool launchingNewGame;
|
bool launchingNewGame;
|
||||||
std::auto_ptr<TechTree> techTree;
|
std::auto_ptr<TechTree> techTree;
|
||||||
|
|
||||||
|
GameSettings originalGamesettings;
|
||||||
|
bool validOriginalGameSettings;
|
||||||
|
GameSettings displayedGamesettings;
|
||||||
|
bool validDisplayedGamesettings;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MenuStateConnectedGame(Program *program, MainMenu *mainMenu, JoinMenu joinMenuInfo=jmSimple, bool openNetworkSlots= false);
|
MenuStateConnectedGame(Program *program, MainMenu *mainMenu, JoinMenu joinMenuInfo=jmSimple, bool openNetworkSlots= false);
|
||||||
|
|
|
@ -172,6 +172,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
||||||
needToSetChangedGameSettings = false;
|
needToSetChangedGameSettings = false;
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
needToBroadcastServerSettings = false;
|
needToBroadcastServerSettings = false;
|
||||||
|
lastGameSettingsreceivedCount = -1;
|
||||||
showMasterserverError = false;
|
showMasterserverError = false;
|
||||||
tMasterserverErrorElapsed = 0;
|
tMasterserverErrorElapsed = 0;
|
||||||
masterServererErrorToShow = "---";
|
masterServererErrorToShow = "---";
|
||||||
|
@ -2439,7 +2440,8 @@ void MenuStateCustomGame::update() {
|
||||||
|
|
||||||
if(this->autoloadScenarioName != "") {
|
if(this->autoloadScenarioName != "") {
|
||||||
listBoxScenario.setSelectedItem(formatString(this->autoloadScenarioName),false);
|
listBoxScenario.setSelectedItem(formatString(this->autoloadScenarioName),false);
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
lastGameSettingsreceivedCount=serverInterface->getGameSettingsUpdateCount();
|
||||||
if(listBoxScenario.getSelectedItem() != formatString(this->autoloadScenarioName)) {
|
if(listBoxScenario.getSelectedItem() != formatString(this->autoloadScenarioName)) {
|
||||||
mainMessageBoxState=1;
|
mainMessageBoxState=1;
|
||||||
showMessageBox( "Could not find scenario name: " + formatString(this->autoloadScenarioName), "Scenario Missing", false);
|
showMessageBox( "Could not find scenario name: " + formatString(this->autoloadScenarioName), "Scenario Missing", false);
|
||||||
|
@ -2845,7 +2847,15 @@ void MenuStateCustomGame::update() {
|
||||||
if(needToPublishDelayed == false || headlessServerMode == true) {
|
if(needToPublishDelayed == false || headlessServerMode == true) {
|
||||||
bool broadCastSettings = (difftime((long int)time(NULL),lastSetChangedGameSettings) >= BROADCAST_SETTINGS_SECONDS);
|
bool broadCastSettings = (difftime((long int)time(NULL),lastSetChangedGameSettings) >= BROADCAST_SETTINGS_SECONDS);
|
||||||
|
|
||||||
//printf("broadCastSettings = %d\n",broadCastSettings);
|
if(headlessServerMode==true){
|
||||||
|
// publish settings directly when we receive them
|
||||||
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
if(lastGameSettingsreceivedCount<serverInterface->getGameSettingsUpdateCount()){
|
||||||
|
needToBroadcastServerSettings=true;
|
||||||
|
lastSetChangedGameSettings = time(NULL);
|
||||||
|
lastGameSettingsreceivedCount=serverInterface->getGameSettingsUpdateCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(broadCastSettings == true) {
|
if(broadCastSettings == true) {
|
||||||
needToBroadcastServerSettings=true;
|
needToBroadcastServerSettings=true;
|
||||||
|
@ -3342,7 +3352,7 @@ void MenuStateCustomGame::simpleTaskForClients(BaseThread *callingThread) {
|
||||||
}
|
}
|
||||||
ServerInterface *serverInterface= NetworkManager::getInstance().getServerInterface(false);
|
ServerInterface *serverInterface= NetworkManager::getInstance().getServerInterface(false);
|
||||||
if(serverInterface != NULL) {
|
if(serverInterface != NULL) {
|
||||||
|
lastGameSettingsreceivedCount++;
|
||||||
if(this->headlessServerMode == false || (serverInterface->getGameSettingsUpdateCount() <= lastMasterServerSettingsUpdateCount)) {
|
if(this->headlessServerMode == false || (serverInterface->getGameSettingsUpdateCount() <= lastMasterServerSettingsUpdateCount)) {
|
||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
loadGameSettings(&gameSettings);
|
loadGameSettings(&gameSettings);
|
||||||
|
|
|
@ -220,6 +220,8 @@ private:
|
||||||
|
|
||||||
string gameUUID;
|
string gameUUID;
|
||||||
|
|
||||||
|
int lastGameSettingsreceivedCount;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,
|
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,
|
||||||
bool openNetworkSlots= false, ParentMenuState parentMenuState=pNewGame,
|
bool openNetworkSlots= false, ParentMenuState parentMenuState=pNewGame,
|
||||||
|
|
Loading…
Reference in New Issue