Fix server crash if player is not fully connected

coverity_scan^2
Koncord 8 years ago
parent 79532cf797
commit 50d989d767

@ -405,8 +405,11 @@ void Networking::NewPlayer(RakNet::RakNetGUID guid)
void Networking::DisconnectPlayer(RakNet::RakNetGUID guid)
{
Script::Call<Script::CallbackIdentity("OnPlayerDisconnect")>(Players::GetPlayer(guid)->GetID());
controller->GetPacket(ID_USER_DISCONNECTED)->Send(Players::GetPlayer(guid), true);
Player *player = Players::GetPlayer(guid);
if(!player)
return;
Script::Call<Script::CallbackIdentity("OnPlayerDisconnect")>(player->GetID());
controller->GetPacket(ID_USER_DISCONNECTED)->Send(player, true);
Players::DeletePlayer(guid);
}

Loading…
Cancel
Save