Use the recieved port to connect, also fix a possible crash
This commit is contained in:
parent
33435de026
commit
005454ba7b
@ -120,20 +120,6 @@ void ConnectToPeer::asynchronousUpdate()
|
||||
if (StkTime::getRealTime() > m_timer + 2.0)
|
||||
{
|
||||
m_timer = StkTime::getRealTime();
|
||||
// Now we know the peer address. If it's a non-local host, start
|
||||
// the Ping protocol to keep the port available. We can't rely
|
||||
// on STKHost::isLAN(), since we might get a LAN connection even
|
||||
// if the server itself accepts connections from anywhere.
|
||||
if ((!m_is_lan &&
|
||||
m_peer_address.getIP() !=
|
||||
STKHost::get()->getPublicAddress().getIP()) ||
|
||||
NetworkConfig::m_disable_lan)
|
||||
{
|
||||
BareNetworkString data;
|
||||
data.addUInt8(0);
|
||||
STKHost::get()->sendRawPacket(data, m_peer_address);
|
||||
}
|
||||
|
||||
// Send a broadcast packet with the string aloha_stk inside,
|
||||
// the client will know our ip address and will connect
|
||||
// The wan remote should already start its ping message to us now
|
||||
|
@ -47,6 +47,7 @@ protected:
|
||||
/** Timer use for tracking broadcast. */
|
||||
double m_timer = 0.0;
|
||||
|
||||
/** If greater than a certain value, terminate this protocol. */
|
||||
unsigned m_tried_connection = 0;
|
||||
|
||||
enum STATE
|
||||
|
@ -211,7 +211,8 @@ void ConnectToServer::asynchronousUpdate()
|
||||
}
|
||||
m_state = DONE;
|
||||
// lobby room protocol if we're connected only
|
||||
if (STKHost::get()->getPeers()[0]->isConnected() &&
|
||||
if (STKHost::get()->getPeerCount() > 0 &&
|
||||
STKHost::get()->getPeers()[0]->isConnected() &&
|
||||
!m_server_address.isUnset())
|
||||
{
|
||||
auto cl = LobbyProtocol::create<ClientLobby>();
|
||||
@ -400,8 +401,8 @@ void ConnectToServer::waitingAloha(bool is_wan)
|
||||
}
|
||||
delete[] table;
|
||||
#endif
|
||||
m_server_address.copy(sender);
|
||||
}
|
||||
m_server_address.copy(sender);
|
||||
m_state = CONNECTING;
|
||||
// Reset timer for next usage
|
||||
m_timer = 0.0;
|
||||
|
Loading…
Reference in New Issue
Block a user