Fix auto connect

This commit is contained in:
Benau 2018-03-05 13:04:17 +08:00
parent aa027bd09c
commit ebcaa2c1ad
3 changed files with 10 additions and 12 deletions

View File

@ -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"

View File

@ -100,7 +100,6 @@ void NetworkingLobby::beforeAddingWidget()
*/
void NetworkingLobby::init()
{
m_server_info.clear();
Screen::init();
setInitialFocus();
m_start_button->setVisible(false);

View File

@ -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