diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 9d3d8aaf..195e3c79 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -375,7 +375,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, listBoxPublishServer.init(50, networkPos, 100); listBoxPublishServer.pushBackItem(lang.get("Yes")); listBoxPublishServer.pushBackItem(lang.get("No")); - if(openNetworkSlots && parentMenuState!=pLanGame) { + if(this->masterserverMode == true || + (openNetworkSlots == true && parentMenuState != pLanGame)) { listBoxPublishServer.setSelectedItemIndex(0); } else { @@ -1999,7 +2000,9 @@ void MenuStateCustomGame::update() { mainMessageBoxState=1; showMessageBox( masterServererErrorToShow, lang.get("ErrorFromMasterserver"), false); - listBoxPublishServer.setSelectedItemIndex(1); + if(this->masterserverMode == false) { + listBoxPublishServer.setSelectedItemIndex(1); + } ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface(); serverInterface->setPublishEnabled(listBoxPublishServer.getSelectedItemIndex() == 0); @@ -2153,7 +2156,8 @@ void MenuStateCustomGame::update() { } } - if(listBoxControls[i].getSelectedItemIndex() == ctNetwork || listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned) { + if(listBoxControls[i].getSelectedItemIndex() == ctNetwork || + listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned) { hasOneNetworkSlotOpen=true; if(serverInterface->getSlot(i) != NULL && @@ -2353,13 +2357,26 @@ void MenuStateCustomGame::update() { if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start(); - if(hasOneNetworkSlotOpen) { - //listBoxPublishServer.setSelectedItemIndex(0); + if(this->masterserverMode == true || hasOneNetworkSlotOpen == true) { + if(this->masterserverMode == true) { + listBoxPublishServer.setSelectedItemIndex(0); + } listBoxPublishServer.setEditable(true); //listBoxEnableServerControlledAI.setEditable(true); + + // Masterserver always needs one network slot + if(this->masterserverMode == true && hasOneNetworkSlotOpen == false) { + for(int i= 0; i < mapInfo.players; ++i) { + if(listBoxControls[i].getSelectedItemIndex() != ctNetwork && + listBoxControls[i].getSelectedItemIndex() != ctNetworkUnassigned) { + listBoxControls[i].setSelectedItemIndex(ctNetwork); + } + } + + updateNetworkSlots(); + } } - else - { + else { listBoxPublishServer.setSelectedItemIndex(1); listBoxPublishServer.setEditable(false); diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index 8c0e8170..1a8c34ca 100644 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -694,11 +694,21 @@ void ClientInterface::waitUntilReady(Checksum* checksum) { Lang &lang= Lang::getInstance(); int64 lastMillisCheck = 0; + + uint64 waitLoopIterationCount = 0; + const uint64 MAX_LOOP_COUNT_BEFORE_SLEEP = 300; + //wait until we get a ready message from the server while(true) { // FOR TESTING ONLY - delay to see the client count up while waiting //sleep(2000); + waitLoopIterationCount++; + if(waitLoopIterationCount > 0 && waitLoopIterationCount % MAX_LOOP_COUNT_BEFORE_SLEEP == 0) { + sleep(1); + waitLoopIterationCount = 0; + } + if(isConnected() == false) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index 4950518c..1f3f3c09 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -1175,7 +1175,14 @@ void ServerInterface::waitUntilReady(Checksum *checksum) { } Lang &lang= Lang::getInstance(); + uint64 waitLoopIterationCount = 0; + const uint64 MAX_LOOP_COUNT_BEFORE_SLEEP = 300; while(exitServer == false && allReady == false && logger.getCancelLoading() == false) { + waitLoopIterationCount++; + if(waitLoopIterationCount > 0 && waitLoopIterationCount % MAX_LOOP_COUNT_BEFORE_SLEEP == 0) { + sleep(1); + waitLoopIterationCount = 0; + } vector waitingForHosts; allReady= true; for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {