From 0e0c43f14a5dd5a1677209b455d9944e8ae946bd Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Fri, 27 Jul 2012 00:39:13 +0000 Subject: [PATCH] - bugfix to close unconnected network slots if they are in a slot higher than map's max slots --- source/glest_game/menu/menu_state_custom_game.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 6a51ccb9..65384e54 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -3762,7 +3762,8 @@ void MenuStateCustomGame::closeUnusedSlots(){ try { if(checkBoxScenario.getValue() == false) { ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface(); - for(int i= 0; igetSlot(i) == NULL || @@ -3800,7 +3801,10 @@ void MenuStateCustomGame::updateNetworkSlots() { } for(int i= 0; i < GameConstants::maxPlayers; ++i) { - if(serverInterface->getSlot(i) == NULL && + ConnectionSlot *slot = serverInterface->getSlot(i); + //printf("A i = %d control type = %d slot [%p]\n",i,listBoxControls[i].getSelectedItemIndex(),slot); + + if(slot == NULL && listBoxControls[i].getSelectedItemIndex() == ctNetwork) { try { serverInterface->addSlot(i); @@ -3822,9 +3826,11 @@ void MenuStateCustomGame::updateNetworkSlots() { listBoxControls[i].setSelectedItemIndex(ctCpu); } } - ConnectionSlot *slot = serverInterface->getSlot(i); + slot = serverInterface->getSlot(i); if(slot != NULL) { - if(listBoxControls[i].getSelectedItemIndex() != ctNetwork) { + if((listBoxControls[i].getSelectedItemIndex() != ctNetwork) || + (listBoxControls[i].getSelectedItemIndex() == ctNetwork && + slot->isConnected() == false && i >= mapInfo.players)) { if(slot->getCanAcceptConnections() == true) { slot->setCanAcceptConnections(false); }