mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Try to fix crash related to bad connection and reconnecting
This commit is contained in:
parent
0916d8aba5
commit
c9d70ed81b
|
@ -239,9 +239,8 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr)
|
|||
}
|
||||
else
|
||||
{
|
||||
if(State() == NET_CONNSTATE_OFFLINE || State() == NET_CONNSTATE_ERROR)
|
||||
if(State() == NET_CONNSTATE_OFFLINE)
|
||||
{
|
||||
m_State = NET_CONNSTATE_OFFLINE;
|
||||
if(CtrlMsg == NET_CTRLMSG_CONNECT)
|
||||
{
|
||||
// send response and init connection
|
||||
|
|
|
@ -140,6 +140,7 @@ int CNetServer::Recv(CNetChunk *pChunk)
|
|||
for(int i = 0; i < MaxClients(); i++)
|
||||
{
|
||||
if(m_aSlots[i].m_Connection.State() != NET_CONNSTATE_OFFLINE &&
|
||||
m_aSlots[i].m_Connection.State() != NET_CONNSTATE_ERROR &&
|
||||
net_addr_comp(m_aSlots[i].m_Connection.PeerAddress(), &Addr) == 0)
|
||||
{
|
||||
Found = true; // silent ignore.. we got this client already
|
||||
|
@ -205,6 +206,9 @@ int CNetServer::Recv(CNetChunk *pChunk)
|
|||
{
|
||||
if(net_addr_comp(m_aSlots[i].m_Connection.PeerAddress(), &Addr) == 0)
|
||||
{
|
||||
if(m_aSlots[i].m_Connection.State() == NET_CONNSTATE_OFFLINE ||
|
||||
m_aSlots[i].m_Connection.State() == NET_CONNSTATE_ERROR)
|
||||
continue;
|
||||
if(m_aSlots[i].m_Connection.Feed(&m_RecvUnpacker.m_Data, &Addr))
|
||||
{
|
||||
if(m_RecvUnpacker.m_Data.m_DataSize)
|
||||
|
|
|
@ -844,16 +844,16 @@ void CGameContext::OnClientConnected(int ClientID)
|
|||
// Check which team the player should be on
|
||||
const int StartTeam = g_Config.m_SvTournamentMode ? TEAM_SPECTATORS : m_pController->GetAutoTeam(ClientID);
|
||||
|
||||
//if (!m_apPlayers[ClientID])
|
||||
if (!m_apPlayers[ClientID])
|
||||
m_apPlayers[ClientID] = new(ClientID) CPlayer(this, ClientID, StartTeam);
|
||||
else
|
||||
{
|
||||
delete m_apPlayers[ClientID];
|
||||
m_apPlayers[ClientID] = new(ClientID) CPlayer(this, ClientID, StartTeam);
|
||||
//else
|
||||
//{
|
||||
// //delete m_apPlayers[ClientID];
|
||||
// //m_apPlayers[ClientID] = new(ClientID) CPlayer(this, ClientID, StartTeam);
|
||||
// //m_apPlayers[ClientID]->Reset();
|
||||
// //((CServer*)Server())->m_aClients[ClientID].Reset();
|
||||
// ((CServer*)Server())->m_aClients[ClientID].m_State = 4;
|
||||
//}
|
||||
}
|
||||
//players[client_id].init(client_id);
|
||||
//players[client_id].client_id = client_id;
|
||||
|
||||
|
|
Loading…
Reference in a new issue