Skip to content

Commit c63202f

Browse files
authored
chore: Move ChangeOwnership OwnershipMessageTypeFlags to an enum (#3648)
## Purpose of this PR Swaps the `m_OwnershipMessageTypeFlags` from a bitfield to an enum as the field is being used like an enum. ### Jira ticket _Link to related jira ticket ([Use the smart commits](https://support.atlassian.com/bitbucket-cloud/docs/use-smart-commits/)). Short version (e.g. MTT-123) also works and gets auto-linked_ ### Changelog [//]: # (updated with all public facing changes - API changes, UI/UX changes, behaviour changes, bug fixes. Remove if not relevant.) - Changed: Internal representation of ChangeOwnershipMessage now uses an enum rather than a bitfield. ## Documentation - No documentation changes or additions were necessary. ## Testing & QA (How your changes can be verified during release Playtest) Can be playtested with the Astroids Ownership demos. <!-- Add any performance testing results here if relevant. --> ### Functional Testing [//]: # (If checked, List manual tests that have been performed.) _Manual testing :_ - [ ] `Manual testing done` _Automated tests:_ - [x] `Covered by existing automated tests` - [ ] `Covered by new automated tests` _Does the change require QA team to:_ - [ ] `Review automated tests`? - [ ] `Execute manual tests`? - [ ] `Provide feedback about the PR`? If any boxes above are checked the QA team will be automatically added as a PR reviewer. ## Backports Performance improvement is only required to be in 2.x
1 parent 2275c2f commit c63202f

File tree

5 files changed

+338
-309
lines changed

5 files changed

+338
-309
lines changed

com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -785,13 +785,13 @@ public OwnershipRequestStatus RequestOwnership()
785785
// Otherwise, send the request ownership message
786786
var changeOwnership = new ChangeOwnershipMessage
787787
{
788+
ChangeMessageType = ChangeOwnershipMessage.ChangeType.RequestOwnership,
788789
NetworkObjectId = NetworkObjectId,
789790
OwnerClientId = OwnerClientId,
790791
ClientIdCount = 1,
791792
RequestClientId = NetworkManager.LocalClientId,
792793
ClientIds = new ulong[1] { OwnerClientId },
793794
DistributedAuthorityMode = true,
794-
RequestOwnership = true,
795795
OwnershipFlags = (ushort)Ownership,
796796
};
797797

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

10641064
var changeOwnership = new ChangeOwnershipMessage
10651065
{
1066+
ChangeMessageType = ChangeOwnershipMessage.ChangeType.OwnershipFlagsUpdate,
10661067
NetworkObjectId = NetworkObjectId,
10671068
OwnerClientId = OwnerClientId,
10681069
DistributedAuthorityMode = true,
1069-
OwnershipFlagsUpdate = true,
10701070
OwnershipFlags = (ushort)Ownership,
10711071
};
10721072

0 commit comments

Comments
 (0)