From 203d37bb6f6ae69f1d0c5d03b092a8f9f5596799 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sun, 11 Apr 2010 04:29:23 +0000 Subject: [PATCH] Added status update for LAN server searching and guard against people who click find like mad. --- .../glest_game/menu/menu_state_join_game.cpp | 20 +++++++++++++------ .../sources/platform/win32/socket.cpp | 3 +-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/source/glest_game/menu/menu_state_join_game.cpp b/source/glest_game/menu/menu_state_join_game.cpp index 7dca3385..6c7eb877 100644 --- a/source/glest_game/menu/menu_state_join_game.cpp +++ b/source/glest_game/menu/menu_state_join_game.cpp @@ -60,6 +60,7 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool buttonAutoFindServers.init(595, 300, 125); buttonAutoFindServers.setText(lang.get("FindLANGames")); + buttonAutoFindServers.setEnabled(true); //server type label labelServerType.init(330, 490); @@ -131,6 +132,7 @@ MenuStateJoinGame::~MenuStateJoinGame() { void MenuStateJoinGame::DiscoveredServers(std::vector serverList) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + buttonAutoFindServers.setEnabled(true); if(serverList.size() > 0) { string bestIPMatch = ""; std::vector localIPList = Socket::getLocalIPAddressList(); @@ -208,18 +210,20 @@ void MenuStateJoinGame::mouseClick(int x, int y, MouseButton mouseButton) connectToServer(); } } - else if(buttonAutoFindServers.mouseClick(x, y)) { + else if(buttonAutoFindServers.mouseClick(x, y) && buttonAutoFindServers.getEnabled() == true) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); ClientInterface* clientInterface= networkManager.getClientInterface(); - soundRenderer.playFx(coreData.getClickSoundA()); - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - // Triggers a thread which calls back into MenuStateJoinGame::DiscoveredServers // with the results - clientInterface->discoverServers(this); + if(clientInterface->isConnected() == false) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + buttonAutoFindServers.setEnabled(false); + clientInterface->discoverServers(this); + } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } @@ -355,7 +359,11 @@ void MenuStateJoinGame::update() else { buttonConnect.setText(lang.get("Connect")); - labelStatus.setText(lang.get("NotConnected")); + string connectedStatus = lang.get("NotConnected"); + if(buttonAutoFindServers.getEnabled() == false) { + connectedStatus += " - searching for servers, please wait..."; + } + labelStatus.setText(connectedStatus); labelInfo.setText(""); } diff --git a/source/shared_lib/sources/platform/win32/socket.cpp b/source/shared_lib/sources/platform/win32/socket.cpp index 903fdd81..3957e5f4 100644 --- a/source/shared_lib/sources/platform/win32/socket.cpp +++ b/source/shared_lib/sources/platform/win32/socket.cpp @@ -1052,8 +1052,7 @@ void ServerSocket::listen(int connectionQueueSize){ if(err==SOCKET_ERROR){ throwException("Error listening socket"); } - broadCastThread = new BroadCastSocketThread(); - broadCastThread->start(); + startBroadCastThread(); } Socket *ServerSocket::accept(){