diff --git a/src/network/protocols/client_lobby.cpp b/src/network/protocols/client_lobby.cpp index f26645f09..6be87324a 100644 --- a/src/network/protocols/client_lobby.cpp +++ b/src/network/protocols/client_lobby.cpp @@ -87,7 +87,7 @@ engine. */ -ClientLobby::ClientLobby(const ENetAddress& a, std::shared_ptr s) +ClientLobby::ClientLobby(std::shared_ptr s) : LobbyProtocol() { m_auto_started = false; @@ -95,7 +95,6 @@ ClientLobby::ClientLobby(const ENetAddress& a, std::shared_ptr s) m_server_auto_game_time = false; m_received_server_result = false; m_state.store(NONE); - m_server_address = a; m_server = s; setHandleDisconnections(true); m_disconnected_msg[PDI_TIMEOUT] = _("Server connection timed out."); @@ -137,7 +136,8 @@ void ClientLobby::setup() if (!GUIEngine::isNoGraphics()) TracksScreen::getInstance()->resetVote(); LobbyProtocol::setup(); - m_state.store(NONE); + // The client lobby is only created when connected to server + m_state.store(LINKED); } // setup //----------------------------------------------------------------------------- @@ -359,12 +359,6 @@ void ClientLobby::update(int ticks) { switch (m_state.load()) { - case NONE: - if (STKHost::get()->isConnectedTo(m_server_address)) - { - m_state.store(LINKED); - } - break; case LINKED: { NetworkConfig::get()->clearServerCapabilities(); @@ -483,6 +477,7 @@ void ClientLobby::update(int ticks) case SELECTING_ASSETS: case RACING: case EXITING: + case NONE: break; } } // update diff --git a/src/network/protocols/client_lobby.hpp b/src/network/protocols/client_lobby.hpp index 240488756..8ccec3aa9 100644 --- a/src/network/protocols/client_lobby.hpp +++ b/src/network/protocols/client_lobby.hpp @@ -73,8 +73,6 @@ private: void handleBadConnection(); void becomingServerOwner(); - ENetAddress m_server_address; - std::shared_ptr m_server; enum ClientState : unsigned int @@ -143,7 +141,7 @@ private: bool* is_spectator = NULL) const; void getKartsTracksNetworkString(BareNetworkString* ns); public: - ClientLobby(const ENetAddress& a, std::shared_ptr s); + ClientLobby(std::shared_ptr s); virtual ~ClientLobby(); void doneWithResults(); bool receivedServerResult() { return m_received_server_result; } diff --git a/src/network/protocols/connect_to_server.cpp b/src/network/protocols/connect_to_server.cpp index 0ff356cfe..9584c96f8 100644 --- a/src/network/protocols/connect_to_server.cpp +++ b/src/network/protocols/connect_to_server.cpp @@ -371,8 +371,7 @@ void ConnectToServer::update(int ticks) // Let main thread create ClientLobby for better // synchronization with GUI NetworkConfig::get()->clearActivePlayersForClient(); - auto cl = LobbyProtocol::create(m_server_address, - m_server); + auto cl = LobbyProtocol::create(m_server); STKHost::get()->startListening(); cl->requestStart(); } diff --git a/src/network/stk_host.cpp b/src/network/stk_host.cpp index f041e8926..49c78948a 100644 --- a/src/network/stk_host.cpp +++ b/src/network/stk_host.cpp @@ -1283,25 +1283,6 @@ std::shared_ptr STKHost::getServerPeerForClient() const return m_peers.begin()->second; } // getServerPeerForClient -// ---------------------------------------------------------------------------- -/** \brief Tells if a peer is known and connected. - * \return True if the peer is known and connected, false elseway. - */ -bool STKHost::isConnectedTo(const ENetAddress& peer) -{ - ENetHost *host = m_network->getENetHost(); - for (unsigned int i = 0; i < host->peerCount; i++) - { - if (peer.host == host->peers[i].address.host && - peer.port == host->peers[i].address.port && - host->peers[i].state == ENET_PEER_STATE_CONNECTED) - { - return true; - } - } - return false; -} // isConnectedTo - //----------------------------------------------------------------------------- /** Sends data to all validated peers currently in server * \param data Data to sent. diff --git a/src/network/stk_host.hpp b/src/network/stk_host.hpp index 9060ec44c..4ab45a9cd 100644 --- a/src/network/stk_host.hpp +++ b/src/network/stk_host.hpp @@ -278,8 +278,6 @@ public: // ------------------------------------------------------------------------ bool peerExists(const SocketAddress& peer_address); // ------------------------------------------------------------------------ - bool isConnectedTo(const ENetAddress& peer_address); - // ------------------------------------------------------------------------ std::shared_ptr getServerPeerForClient() const; // ------------------------------------------------------------------------ void setErrorMessage(const irr::core::stringw &message);