mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Correct order of Destroy in RemovePlayer (#262)
The RemovePlayerController call sets the playerController to null, causing a null dereference (and a memory leak as pointed out by @paulpach, since gameobjects are never destroyed)
This commit is contained in:
parent
eaa506fb26
commit
c490d9faa0
@ -121,10 +121,11 @@ public static bool RemovePlayer()
|
||||
RemovePlayerMessage msg = new RemovePlayerMessage();
|
||||
s_ReadyConnection.Send((short)MsgType.RemovePlayer, msg);
|
||||
|
||||
Object.Destroy(s_ReadyConnection.playerController.gameObject);
|
||||
|
||||
s_ReadyConnection.RemovePlayerController();
|
||||
s_LocalPlayer = null;
|
||||
|
||||
Object.Destroy(s_ReadyConnection.playerController.gameObject);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -821,8 +821,8 @@ static void OnRemovePlayerMessage(NetworkMessage netMsg)
|
||||
{
|
||||
if (netMsg.conn.playerController != null)
|
||||
{
|
||||
netMsg.conn.RemovePlayerController();
|
||||
Destroy(netMsg.conn.playerController.gameObject);
|
||||
netMsg.conn.RemovePlayerController();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user