Skip to content

Commit

Permalink
fix: fixing NRE when DestroyObject is called on unspawned object
Browse files Browse the repository at this point in the history
SendToRemoteObservers throws because server reference is not set
  • Loading branch information
James-Frowen committed Sep 4, 2024
1 parent 32a061c commit ce00f0d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Assets/Mirage/Runtime/ServerObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,13 @@ public void Destroy(NetworkIdentity identity, bool destroyServerObject = true)

private void DestroyObject(NetworkIdentity identity, bool destroyServerObject)
{
if (logger.LogEnabled()) logger.Log("DestroyObject instance:" + identity.NetId);
if (identity.NetId == 0)
{
if (logger.WarnEnabled()) logger.LogWarning("DestroyObject instance:" + identity.NetId);
return;
}

if (logger.LogEnabled()) logger.Log($"DestroyObject NetId={identity.NetId}");

_server.World.RemoveIdentity(identity);
identity.Owner?.RemoveOwnedObject(identity);
Expand Down

0 comments on commit ce00f0d

Please sign in to comment.