- always ensure headless server has an open slot in the lobby

This commit is contained in:
Mark Vejvoda 2012-07-11 22:41:31 +00:00
parent be61ed89da
commit 109401b2e8
1 changed files with 17 additions and 3 deletions

View File

@ -2078,7 +2078,10 @@ void MenuStateCustomGame::update() {
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
return;
if(this->headlessServerMode == false) {
return;
}
}
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
Lang& lang= Lang::getInstance();
@ -2431,9 +2434,20 @@ void MenuStateCustomGame::update() {
// Masterserver always needs one network slot
if(this->headlessServerMode == true && hasOneNetworkSlotOpen == false) {
bool anyoneConnected = false;
for(int i= 0; i < mapInfo.players; ++i) {
if(listBoxControls[i].getSelectedItemIndex() != ctNetwork &&
listBoxControls[i].getSelectedItemIndex() != ctNetworkUnassigned) {
MutexSafeWrapper safeMutex((publishToMasterserverThread != NULL ? publishToMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
ConnectionSlot *slot = serverInterface->getSlot(i);
if(slot != NULL && slot->isConnected() == true) {
anyoneConnected = true;
break;
}
}
for(int i= 0; i < mapInfo.players; ++i) {
if(anyoneConnected == false && listBoxControls[i].getSelectedItemIndex() != ctNetwork) {
listBoxControls[i].setSelectedItemIndex(ctNetwork);
}
}