Skip to content
16 changes: 8 additions & 8 deletions com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -785,13 +785,13 @@ public OwnershipRequestStatus RequestOwnership()
// Otherwise, send the request ownership message
var changeOwnership = new ChangeOwnershipMessage
{
ChangeMessageType = ChangeOwnershipMessage.ChangeType.RequestOwnership,
NetworkObjectId = NetworkObjectId,
OwnerClientId = OwnerClientId,
ClientIdCount = 1,
RequestClientId = NetworkManager.LocalClientId,
ClientIds = new ulong[1] { OwnerClientId },
DistributedAuthorityMode = true,
RequestOwnership = true,
OwnershipFlags = (ushort)Ownership,
};

Expand Down Expand Up @@ -866,18 +866,18 @@ internal void OwnershipRequest(ulong clientRequestingOwnership)
else
{
// Otherwise, send back the reason why the ownership request was denied for the clientRequestingOwnership
/// Notes:
/// We always apply the <see cref="NetworkManager.LocalClientId"/> as opposed to <see cref="OwnerClientId"/> to the
/// <see cref="ChangeOwnershipMessage.OwnerClientId"/> value as ownership could have changed and the denied requests
/// targeting this instance are because there is a request pending.
/// DANGO-TODO: What happens if the client requesting disconnects prior to responding with the update in request pending?
// Notes:
// We always apply the <see cref="NetworkManager.LocalClientId"/> as opposed to <see cref="OwnerClientId"/> to the
// <see cref="ChangeOwnershipMessage.OwnerClientId"/> value as ownership could have changed and the denied requests
// targeting this instance are because there is a request pending.
// DANGO-TODO: What happens if the client requesting disconnects prior to responding with the update in request pending?
var changeOwnership = new ChangeOwnershipMessage
{
ChangeMessageType = ChangeOwnershipMessage.ChangeType.RequestDenied,
NetworkObjectId = NetworkObjectId,
OwnerClientId = NetworkManager.LocalClientId, // Always use the local clientId (see above notes)
RequestClientId = clientRequestingOwnership,
DistributedAuthorityMode = true,
RequestDenied = true,
OwnershipRequestResponseStatus = (byte)response,
OwnershipFlags = (ushort)Ownership,
};
Expand Down Expand Up @@ -1063,10 +1063,10 @@ internal void SendOwnershipStatusUpdate()

var changeOwnership = new ChangeOwnershipMessage
{
ChangeMessageType = ChangeOwnershipMessage.ChangeType.OwnershipFlagsUpdate,
NetworkObjectId = NetworkObjectId,
OwnerClientId = OwnerClientId,
DistributedAuthorityMode = true,
OwnershipFlagsUpdate = true,
OwnershipFlags = (ushort)Ownership,
};

Expand Down
Loading