From 2555a895c3898f7eaa87ccdc4f466ff1bf7da476 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 30 Jun 2010 14:51:30 +0000 Subject: [PATCH] - bugfix, only allow changing player info AFTER we get game settings from the server after requesting a change to avoid deadlocks etc. --- .../menu/menu_state_connected_game.cpp | 144 ++++++------------ 1 file changed, 47 insertions(+), 97 deletions(-) diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index f05e8f8cc..7554945f0 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -197,112 +197,62 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){ currentMap=""; returnToJoinMenu(); } - else if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) { - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); - soundRenderer.playFx(coreData.getClickSoundC()); - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); - } - else - { - int myCurrentIndex=-1; - for(int i=0; iisConnected() == true && + clientInterface->getGameSettingsReceived() == true) { + if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); + soundRenderer.playFx(coreData.getClickSoundC()); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); } - if (myCurrentIndex!=-1) - for(int i=0; iisConnected()){ - clientInterface->setGameSettingsReceived(false); - clientInterface->sendSwitchSetupRequest(listBoxFactions[i].getSelectedItem(),i,-1,listBoxTeams[i].getSelectedItemIndex()); - } - break; + int myCurrentIndex=-1; + for(int i=0; iisConnected()){ - clientInterface->setGameSettingsReceived(false); - clientInterface->sendSwitchSetupRequest(listBoxFactions[i].getSelectedItem(),i,-1,listBoxTeams[i].getSelectedItemIndex()); + if (myCurrentIndex!=-1) + for(int i=0; iisConnected()){ + clientInterface->setGameSettingsReceived(false); + clientInterface->sendSwitchSetupRequest(listBoxFactions[i].getSelectedItem(),i,-1,listBoxTeams[i].getSelectedItemIndex()); + } + break; } - break; } - } - if((listBoxControls[i].getSelectedItemIndex() == ctNetwork) && - (labelNetStatus[i].getText() == GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME)) { - if(grabSlotButton[i].mouseClick(x, y) ) - { - soundRenderer.playFx(coreData.getClickSoundA()); - clientInterface->setGameSettingsReceived(false); - settingsReceivedFromServer=false; - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] sending a switchSlot request from %d to %d\n",__FILE__,__FUNCTION__,__LINE__,clientInterface->getGameSettings()->getThisFactionIndex(),i); - clientInterface->sendSwitchSetupRequest(listBoxFactions[myCurrentIndex].getSelectedItem(),myCurrentIndex,i,listBoxTeams[myCurrentIndex].getSelectedItemIndex()); - break; + if(listBoxTeams[i].getEditable()){ + if(listBoxTeams[i].mouseClick(x, y)){ + soundRenderer.playFx(coreData.getClickSoundA()); + if(clientInterface->isConnected()){ + clientInterface->setGameSettingsReceived(false); + clientInterface->sendSwitchSetupRequest(listBoxFactions[i].getSelectedItem(),i,-1,listBoxTeams[i].getSelectedItemIndex()); + } + break; + } + } + if((listBoxControls[i].getSelectedItemIndex() == ctNetwork) && + (labelNetStatus[i].getText() == GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME)) { + if(grabSlotButton[i].mouseClick(x, y) ) + { + soundRenderer.playFx(coreData.getClickSoundA()); + clientInterface->setGameSettingsReceived(false); + settingsReceivedFromServer=false; + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] sending a switchSlot request from %d to %d\n",__FILE__,__FUNCTION__,__LINE__,clientInterface->getGameSettings()->getThisFactionIndex(),i); + clientInterface->sendSwitchSetupRequest(listBoxFactions[myCurrentIndex].getSelectedItem(),myCurrentIndex,i,listBoxTeams[myCurrentIndex].getSelectedItemIndex()); + break; + } } } } - - -// for(int i=0; i(listBoxControls[j].getSelectedItemIndex()); -// if(ct==ctHuman){ -// if(humanIndex1==-1){ -// humanIndex1= j; -// } -// else{ -// humanIndex2= j; -// } -// } -// } -// -// //no human -// if(humanIndex1==-1 && humanIndex2==-1){ -// listBoxControls[i].setSelectedItemIndex(ctHuman); -// } -// -// //2 humans -// if(humanIndex1!=-1 && humanIndex2!=-1){ -// listBoxControls[humanIndex1==i? humanIndex2: humanIndex1].setSelectedItemIndex(ctClosed); -// } -// -// if(hasNetworkGameSettings() == true) -// { -// needToSetChangedGameSettings = true; -// lastSetChangedGameSettings = time(NULL);; -// } -// } -// else if(listBoxFactions[i].mouseClick(x, y)){ -// -// if(hasNetworkGameSettings() == true) -// { -// needToSetChangedGameSettings = true; -// lastSetChangedGameSettings = time(NULL);; -// } -// } -// else if(listBoxTeams[i].mouseClick(x, y)) -// { -// if(hasNetworkGameSettings() == true) -// { -// needToSetChangedGameSettings = true; -// lastSetChangedGameSettings = time(NULL);; -// } -// } -// } } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); }