Remove unneeded checking of client lobby peer connection
This commit is contained in:
parent
2ddc26ef9c
commit
6d85a03423
@ -87,7 +87,7 @@ engine.
|
||||
|
||||
*/
|
||||
|
||||
ClientLobby::ClientLobby(const ENetAddress& a, std::shared_ptr<Server> s)
|
||||
ClientLobby::ClientLobby(std::shared_ptr<Server> s)
|
||||
: LobbyProtocol()
|
||||
{
|
||||
m_auto_started = false;
|
||||
@ -95,7 +95,6 @@ ClientLobby::ClientLobby(const ENetAddress& a, std::shared_ptr<Server> 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
|
||||
|
@ -73,8 +73,6 @@ private:
|
||||
void handleBadConnection();
|
||||
void becomingServerOwner();
|
||||
|
||||
ENetAddress m_server_address;
|
||||
|
||||
std::shared_ptr<Server> 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<Server> s);
|
||||
ClientLobby(std::shared_ptr<Server> s);
|
||||
virtual ~ClientLobby();
|
||||
void doneWithResults();
|
||||
bool receivedServerResult() { return m_received_server_result; }
|
||||
|
@ -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<ClientLobby>(m_server_address,
|
||||
m_server);
|
||||
auto cl = LobbyProtocol::create<ClientLobby>(m_server);
|
||||
STKHost::get()->startListening();
|
||||
cl->requestStart();
|
||||
}
|
||||
|
@ -1283,25 +1283,6 @@ std::shared_ptr<STKPeer> 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.
|
||||
|
@ -278,8 +278,6 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
bool peerExists(const SocketAddress& peer_address);
|
||||
// ------------------------------------------------------------------------
|
||||
bool isConnectedTo(const ENetAddress& peer_address);
|
||||
// ------------------------------------------------------------------------
|
||||
std::shared_ptr<STKPeer> getServerPeerForClient() const;
|
||||
// ------------------------------------------------------------------------
|
||||
void setErrorMessage(const irr::core::stringw &message);
|
||||
|
Loading…
Reference in New Issue
Block a user