From ebcaa2c1ad91c234d4c571f67c30f3ec1932cdcb Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 5 Mar 2018 13:04:17 +0800 Subject: [PATCH] Fix auto connect --- src/network/stk_host.hpp | 1 - src/states_screens/networking_lobby.cpp | 1 - src/states_screens/server_selection.cpp | 20 ++++++++++---------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/network/stk_host.hpp b/src/network/stk_host.hpp index c745b91ed..239cada33 100644 --- a/src/network/stk_host.hpp +++ b/src/network/stk_host.hpp @@ -25,7 +25,6 @@ #include "network/network.hpp" #include "network/network_config.hpp" #include "network/network_string.hpp" -#include "network/servers_manager.hpp" #include "network/stk_peer.hpp" #include "network/transport_address.hpp" #include "utils/synchronised.hpp" diff --git a/src/states_screens/networking_lobby.cpp b/src/states_screens/networking_lobby.cpp index da8a9d100..c4abb3559 100644 --- a/src/states_screens/networking_lobby.cpp +++ b/src/states_screens/networking_lobby.cpp @@ -100,7 +100,6 @@ void NetworkingLobby::beforeAddingWidget() */ void NetworkingLobby::init() { - m_server_info.clear(); Screen::init(); setInitialFocus(); m_start_button->setVisible(false); diff --git a/src/states_screens/server_selection.cpp b/src/states_screens/server_selection.cpp index 92c33251a..e8e01e81a 100644 --- a/src/states_screens/server_selection.cpp +++ b/src/states_screens/server_selection.cpp @@ -196,8 +196,7 @@ void ServerSelection::eventCallback(GUIEngine::Widget* widget, int selected_index = m_server_list_widget->getSelectionID(); // This can happen e.g. when the list is empty and the user // clicks somewhere. - if (selected_index < 0 || - m_refreshing_server || + if (selected_index < 0 || m_refreshing_server || selected_index >= (int)ServersManager::get()->getServers().size()) { return; @@ -215,6 +214,15 @@ void ServerSelection::eventCallback(GUIEngine::Widget* widget, void ServerSelection::onUpdate(float dt) { + // In case of auto-connect command line parameter, select the first server asap + if (NetworkConfig::get()->isAutoConnect() && + m_refreshing_server == false && + !ServersManager::get()->getServers().empty()) + { + ServerInfoDialog *sid = new ServerInfoDialog(ServersManager::get()->getServers()[0]); + sid->requestJoin(); + } + if (!m_refreshing_server) return; if (ServersManager::get()->listUpdated()) @@ -238,12 +246,4 @@ void ServerSelection::onUpdate(float dt) m_reload_widget->setActive(true); } - // In case of auto-connect command line parameter, select the first server asap - if (NetworkConfig::get()->isAutoConnect() && - m_refreshing_server == false && - !ServersManager::get()->getServers().empty()) - { - ServerInfoDialog *sid = new ServerInfoDialog(ServersManager::get()->getServers()[0]); - sid->requestJoin(); - } } // onUpdate