Try to fix crash related to bad connection and reconnecting

This commit is contained in:
def 2014-08-18 23:50:24 +02:00
parent 0916d8aba5
commit c9d70ed81b
3 changed files with 12 additions and 9 deletions

View file

@ -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

View file

@ -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)

View file

@ -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])
m_apPlayers[ClientID] = new(ClientID) CPlayer(this, ClientID, StartTeam);
//else
//{
// //delete m_apPlayers[ClientID];
// //m_apPlayers[ClientID] = new(ClientID) CPlayer(this, ClientID, StartTeam);
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);
// //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;