Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Assets/Mirror/Core/NetworkConnectionToClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ internal void DestroyOwnedObjects()
{
// disown scene objects, destroy instantiated objects.
if (netIdentity.sceneId != 0)
NetworkServer.RemovePlayerForConnection(this, RemovePlayerOptions.KeepActive);
netIdentity.RemoveClientOwner();
else
NetworkServer.Destroy(netIdentity.gameObject);
}
Expand Down
15 changes: 13 additions & 2 deletions Assets/Mirror/Core/NetworkIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,18 @@ internal void SetClientOwner(NetworkConnectionToClient conn)
connectionToClient = conn;
}

// Do not merge with RemoveClientAuthority
// This is called from NetworkConnectionToClient::DestroyOwnedObjects
// when a player disconnects to quietly remove ownerhip of scene objects
internal void RemoveClientOwner()
{
if (connectionToClient != null)
{
clientAuthorityCallback?.Invoke(connectionToClient, this, false);
connectionToClient = null;
}
}

/// <summary>Removes ownership for an object.</summary>
// Applies to objects that had authority set by AssignClientAuthority,
// or NetworkServer.Spawn with a NetworkConnection parameter included.
Expand All @@ -1611,9 +1623,8 @@ public void RemoveClientAuthority()

if (connectionToClient != null)
{
clientAuthorityCallback?.Invoke(connectionToClient, this, false);
NetworkConnectionToClient previousOwner = connectionToClient;
connectionToClient = null;
RemoveClientOwner();
NetworkServer.SendChangeOwnerMessage(this, previousOwner);
}
}
Expand Down