Skip to content

Calls to ChangeOwnership(NetworkManager.ServerClientId) and RemoveOwnership() doesn't have same effect #2511

@PitouGames

Description

@PitouGames

Description

While working on #2507, I remarked that calling serverObject.ChangeOwnership(NetworkManager.ServerClientId) doesn't have the same effect as serverObject.RemoveOwnership(). Moreover, some automated tests use the first one, others the second.

The difference is subtil, but server side, when removing the ownership, the object entry is deleted in NetworkSpawnManager.OwnershipToObjectsTable, while giving ownership back to the server keeps it.
Since the ownership is given back to the server in both case, I think we should let the entry in the table. The entry should be deleted only on despawn.

internal void RemoveOwnership(NetworkObject networkObject)
VS
internal void ChangeOwnership(NetworkObject networkObject, ulong clientId)

Shouldn't RemoveOwnership() just calls ChangeOwnership(NetworkManager.ServerClientId) instead of having a "copy/paste but not identical" implementation?
If there is a difference made on purpose between those two calls, documentation needs to be updated to explain it.

Environment

  • OS: Windows 11
  • Unity Version: 2020.3.40f1 (the automated testing project of this repo)
  • Netcode Version: develop
  • Netcode Commit: 449bf94

Metadata

Metadata

Labels

priority:highThis issue has high priority and we are focusing to resolve itstat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions