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()
|
: LobbyProtocol()
|
||||||
{
|
{
|
||||||
m_auto_started = false;
|
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_server_auto_game_time = false;
|
||||||
m_received_server_result = false;
|
m_received_server_result = false;
|
||||||
m_state.store(NONE);
|
m_state.store(NONE);
|
||||||
m_server_address = a;
|
|
||||||
m_server = s;
|
m_server = s;
|
||||||
setHandleDisconnections(true);
|
setHandleDisconnections(true);
|
||||||
m_disconnected_msg[PDI_TIMEOUT] = _("Server connection timed out.");
|
m_disconnected_msg[PDI_TIMEOUT] = _("Server connection timed out.");
|
||||||
@ -137,7 +136,8 @@ void ClientLobby::setup()
|
|||||||
if (!GUIEngine::isNoGraphics())
|
if (!GUIEngine::isNoGraphics())
|
||||||
TracksScreen::getInstance()->resetVote();
|
TracksScreen::getInstance()->resetVote();
|
||||||
LobbyProtocol::setup();
|
LobbyProtocol::setup();
|
||||||
m_state.store(NONE);
|
// The client lobby is only created when connected to server
|
||||||
|
m_state.store(LINKED);
|
||||||
} // setup
|
} // setup
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -359,12 +359,6 @@ void ClientLobby::update(int ticks)
|
|||||||
{
|
{
|
||||||
switch (m_state.load())
|
switch (m_state.load())
|
||||||
{
|
{
|
||||||
case NONE:
|
|
||||||
if (STKHost::get()->isConnectedTo(m_server_address))
|
|
||||||
{
|
|
||||||
m_state.store(LINKED);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case LINKED:
|
case LINKED:
|
||||||
{
|
{
|
||||||
NetworkConfig::get()->clearServerCapabilities();
|
NetworkConfig::get()->clearServerCapabilities();
|
||||||
@ -483,6 +477,7 @@ void ClientLobby::update(int ticks)
|
|||||||
case SELECTING_ASSETS:
|
case SELECTING_ASSETS:
|
||||||
case RACING:
|
case RACING:
|
||||||
case EXITING:
|
case EXITING:
|
||||||
|
case NONE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // update
|
} // update
|
||||||
|
@ -73,8 +73,6 @@ private:
|
|||||||
void handleBadConnection();
|
void handleBadConnection();
|
||||||
void becomingServerOwner();
|
void becomingServerOwner();
|
||||||
|
|
||||||
ENetAddress m_server_address;
|
|
||||||
|
|
||||||
std::shared_ptr<Server> m_server;
|
std::shared_ptr<Server> m_server;
|
||||||
|
|
||||||
enum ClientState : unsigned int
|
enum ClientState : unsigned int
|
||||||
@ -143,7 +141,7 @@ private:
|
|||||||
bool* is_spectator = NULL) const;
|
bool* is_spectator = NULL) const;
|
||||||
void getKartsTracksNetworkString(BareNetworkString* ns);
|
void getKartsTracksNetworkString(BareNetworkString* ns);
|
||||||
public:
|
public:
|
||||||
ClientLobby(const ENetAddress& a, std::shared_ptr<Server> s);
|
ClientLobby(std::shared_ptr<Server> s);
|
||||||
virtual ~ClientLobby();
|
virtual ~ClientLobby();
|
||||||
void doneWithResults();
|
void doneWithResults();
|
||||||
bool receivedServerResult() { return m_received_server_result; }
|
bool receivedServerResult() { return m_received_server_result; }
|
||||||
|
@ -371,8 +371,7 @@ void ConnectToServer::update(int ticks)
|
|||||||
// Let main thread create ClientLobby for better
|
// Let main thread create ClientLobby for better
|
||||||
// synchronization with GUI
|
// synchronization with GUI
|
||||||
NetworkConfig::get()->clearActivePlayersForClient();
|
NetworkConfig::get()->clearActivePlayersForClient();
|
||||||
auto cl = LobbyProtocol::create<ClientLobby>(m_server_address,
|
auto cl = LobbyProtocol::create<ClientLobby>(m_server);
|
||||||
m_server);
|
|
||||||
STKHost::get()->startListening();
|
STKHost::get()->startListening();
|
||||||
cl->requestStart();
|
cl->requestStart();
|
||||||
}
|
}
|
||||||
|
@ -1283,25 +1283,6 @@ std::shared_ptr<STKPeer> STKHost::getServerPeerForClient() const
|
|||||||
return m_peers.begin()->second;
|
return m_peers.begin()->second;
|
||||||
} // getServerPeerForClient
|
} // 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
|
/** Sends data to all validated peers currently in server
|
||||||
* \param data Data to sent.
|
* \param data Data to sent.
|
||||||
|
@ -278,8 +278,6 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool peerExists(const SocketAddress& peer_address);
|
bool peerExists(const SocketAddress& peer_address);
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool isConnectedTo(const ENetAddress& peer_address);
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
std::shared_ptr<STKPeer> getServerPeerForClient() const;
|
std::shared_ptr<STKPeer> getServerPeerForClient() const;
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void setErrorMessage(const irr::core::stringw &message);
|
void setErrorMessage(const irr::core::stringw &message);
|
||||||
|
Loading…
Reference in New Issue
Block a user