fix: SendChangeOwnerMessage robustness

- Check netid == 0
- Check conn is observing the identity

Fixes #2988
This commit is contained in:
MrGadget1024 2021-11-09 09:10:05 -05:00
parent b854a8a6f1
commit d6d0ec88d0

View File

@ -956,7 +956,12 @@ internal static void SendSpawnMessage(NetworkIdentity identity, NetworkConnectio
internal static void SendChangeOwnerMessage(NetworkIdentity identity, NetworkConnection conn)
{
if (identity.serverOnly) return;
// Don't send if identity isn't spawned or only exists on server
if (identity.netId == 0 || identity.serverOnly) return;
// Don't send if conn doesn't have the identity spawned yet
// May be excluded from the client by interest management
if (!conn.observing.Contains(identity)) return;
//Debug.Log($"Server SendChangeOwnerMessage: name={identity.name} netid={identity.netId}");