From 36d955b14693b40b2d91b2597d3a41eed4fafdaf Mon Sep 17 00:00:00 2001 From: mischa Date: Wed, 28 Jun 2023 10:09:36 +0800 Subject: [PATCH] breaking: NetworkIdentity.isOwned renamed to isClientOwned to properly indicate that it's a client-side flag --- .../Experimental/NetworkLerpRigidbody.cs | 2 +- .../Experimental/NetworkRigidbody.cs | 4 +- .../Experimental/NetworkRigidbody2D.cs | 4 +- Assets/Mirror/Components/NetworkAnimator.cs | 20 ++++---- .../NetworkTransformReliable.cs | 2 +- .../NetworkTransformUnreliable.cs | 2 +- Assets/Mirror/Core/NetworkBehaviour.cs | 19 ++++--- Assets/Mirror/Core/NetworkClient.cs | 10 ++-- Assets/Mirror/Core/NetworkIdentity.cs | 20 +++++--- Assets/Mirror/Core/NetworkServer.cs | 8 +-- .../Editor/NetworkInformationPreview.cs | 2 +- Assets/Mirror/Tests/Common/MirrorTest.cs | 50 +++++++++---------- .../NetworkBehaviour/NetworkBehaviourTests.cs | 2 +- .../NetworkClientTests_OnSpawn.cs | 4 +- .../NetworkIdentitySerializationTests.cs | 2 +- .../NetworkIdentity/NetworkIdentityTests.cs | 18 +++---- .../Editor/NetworkServer/NetworkServerTest.cs | 8 +-- 17 files changed, 92 insertions(+), 85 deletions(-) diff --git a/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs b/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs index 1b19ab72988..38f3dd07d3b 100644 --- a/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs +++ b/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs @@ -33,7 +33,7 @@ public class NetworkLerpRigidbody : NetworkBehaviour /// bool IgnoreSync => isServer || ClientWithAuthority; - bool ClientWithAuthority => clientAuthority && isOwned; + bool ClientWithAuthority => clientAuthority && isClientOwned; protected override void OnValidate() { diff --git a/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs b/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs index 0c2498d7bfb..31873980274 100644 --- a/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs +++ b/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs @@ -72,7 +72,7 @@ protected override void OnValidate() /// bool IgnoreSync => isServer || ClientWithAuthority; - bool ClientWithAuthority => clientAuthority && isOwned; + bool ClientWithAuthority => clientAuthority && isClientOwned; void OnVelocityChanged(Vector3 _, Vector3 newValue) { @@ -180,7 +180,7 @@ void SyncToClients() [Client] void SendToServer() { - if (!isOwned) + if (!isClientOwned) { Debug.LogWarning("SendToServer called without authority"); return; diff --git a/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs b/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs index e3bdd2992b9..4a249a00b9e 100644 --- a/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs +++ b/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs @@ -69,7 +69,7 @@ protected override void OnValidate() /// bool IgnoreSync => isServer || ClientWithAuthority; - bool ClientWithAuthority => clientAuthority && isOwned; + bool ClientWithAuthority => clientAuthority && isClientOwned; void OnVelocityChanged(Vector2 _, Vector2 newValue) { @@ -177,7 +177,7 @@ void SyncToClients() [Client] void SendToServer() { - if (!isOwned) + if (!isClientOwned) { Debug.LogWarning("SendToServer called without authority"); return; diff --git a/Assets/Mirror/Components/NetworkAnimator.cs b/Assets/Mirror/Components/NetworkAnimator.cs index 9e9a929eaaa..525678edede 100644 --- a/Assets/Mirror/Components/NetworkAnimator.cs +++ b/Assets/Mirror/Components/NetworkAnimator.cs @@ -67,7 +67,7 @@ bool SendMessagesAllowed return true; } - return (isOwned && clientAuthority); + return (isClientOwned && clientAuthority); } } @@ -137,7 +137,7 @@ void OnAnimatorSpeedChanged(float _, float value) { // skip if host or client with authority // they will have already set the speed so don't set again - if (isServer || (isOwned && clientAuthority)) + if (isServer || (isClientOwned && clientAuthority)) return; animator.speed = value; @@ -227,7 +227,7 @@ void SendAnimationParametersMessage(byte[] parameters) void HandleAnimMsg(int stateHash, float normalizedTime, int layerId, float weight, NetworkReader reader) { - if (isOwned && clientAuthority) + if (isClientOwned && clientAuthority) return; // usually transitions will be triggered by parameters, if not, play anims directly. @@ -245,7 +245,7 @@ void HandleAnimMsg(int stateHash, float normalizedTime, int layerId, float weigh void HandleAnimParamsMsg(NetworkReader reader) { - if (isOwned && clientAuthority) + if (isClientOwned && clientAuthority) return; ReadParameters(reader); @@ -428,7 +428,7 @@ public void SetTrigger(int hash) return; } - if (!isOwned) + if (!isClientOwned) { Debug.LogWarning("Only the client with authority can set animations"); return; @@ -475,7 +475,7 @@ public void ResetTrigger(int hash) return; } - if (!isOwned) + if (!isClientOwned) { Debug.LogWarning("Only the client with authority can reset animations"); return; @@ -543,7 +543,7 @@ void CmdOnAnimationTriggerServerMessage(int hash) // handle and broadcast // host should have already the trigger - bool isHostOwner = isClient && isOwned; + bool isHostOwner = isClient && isClientOwned; if (!isHostOwner) { HandleAnimTriggerMsg(hash); @@ -561,7 +561,7 @@ void CmdOnAnimationResetTriggerServerMessage(int hash) // handle and broadcast // host should have already the trigger - bool isHostOwner = isClient && isOwned; + bool isHostOwner = isClient && isClientOwned; if (!isHostOwner) { HandleAnimResetTriggerMsg(hash); @@ -600,7 +600,7 @@ void RpcOnAnimationParametersClientMessage(byte[] parameters) void RpcOnAnimationTriggerClientMessage(int hash) { // host/owner handles this before it is sent - if (isServer || (clientAuthority && isOwned)) return; + if (isServer || (clientAuthority && isClientOwned)) return; HandleAnimTriggerMsg(hash); } @@ -609,7 +609,7 @@ void RpcOnAnimationTriggerClientMessage(int hash) void RpcOnAnimationResetTriggerClientMessage(int hash) { // host/owner handles this before it is sent - if (isServer || (clientAuthority && isOwned)) return; + if (isServer || (clientAuthority && isClientOwned)) return; HandleAnimResetTriggerMsg(hash); } diff --git a/Assets/Mirror/Components/NetworkTransform/NetworkTransformReliable.cs b/Assets/Mirror/Components/NetworkTransform/NetworkTransformReliable.cs index 86a8cf4d05c..aa1c1ee981a 100644 --- a/Assets/Mirror/Components/NetworkTransform/NetworkTransformReliable.cs +++ b/Assets/Mirror/Components/NetworkTransform/NetworkTransformReliable.cs @@ -87,7 +87,7 @@ protected virtual void UpdateServer() // https://github.com/MirrorNetworking/Mirror/issues/3329 if (syncDirection == SyncDirection.ClientToServer && connectionToClient != null && - !isOwned) + !isClientOwned) { if (serverSnapshots.Count > 0) { diff --git a/Assets/Mirror/Components/NetworkTransform/NetworkTransformUnreliable.cs b/Assets/Mirror/Components/NetworkTransform/NetworkTransformUnreliable.cs index 73ed8abb269..0f4865492b0 100644 --- a/Assets/Mirror/Components/NetworkTransform/NetworkTransformUnreliable.cs +++ b/Assets/Mirror/Components/NetworkTransform/NetworkTransformUnreliable.cs @@ -165,7 +165,7 @@ void UpdateServerInterpolation() // https://github.com/MirrorNetworking/Mirror/issues/3329 if (syncDirection == SyncDirection.ClientToServer && connectionToClient != null && - !isOwned) + !isClientOwned) { if (serverSnapshots.Count == 0) return; diff --git a/Assets/Mirror/Core/NetworkBehaviour.cs b/Assets/Mirror/Core/NetworkBehaviour.cs index 84d0d9de09d..b190ccc0ea3 100644 --- a/Assets/Mirror/Core/NetworkBehaviour.cs +++ b/Assets/Mirror/Core/NetworkBehaviour.cs @@ -65,11 +65,14 @@ public abstract class NetworkBehaviour : MonoBehaviour /// isOwned is true on the client if this NetworkIdentity is one of the .owned entities of our connection on the server. // for example: main player & pets are owned. monsters & npcs aren't. - public bool isOwned => netIdentity.isOwned; + public bool isClientOwned => netIdentity.isClientOwned; + + [Obsolete(".isOwned was renamed to .isClientOwned to reflect that it's a client-only flag.")] + public bool isOwned => isClientOwned; // Deprecated 2022-10-13 - [Obsolete(".hasAuthority was renamed to .isOwned. This is easier to understand and prepares for SyncDirection, where there is a difference betwen isOwned and authority.")] - public bool hasAuthority => isOwned; + [Obsolete(".hasAuthority was renamed to .isClientOwned. This is easier to understand and prepares for SyncDirection, where there is a difference betwen isOwned and authority.")] + public bool hasAuthority => isClientOwned; /// authority is true if we are allowed to modify this component's state. On server, it's true if SyncDirection is ServerToClient. On client, it's true if SyncDirection is ClientToServer and(!) if this object is owned by the client. // on the client: if owned and if clientAuthority sync direction @@ -86,7 +89,7 @@ public abstract class NetworkBehaviour : MonoBehaviour // another component may not be client authoritative, etc. public bool authority => isClient - ? syncDirection == SyncDirection.ClientToServer && isOwned + ? syncDirection == SyncDirection.ClientToServer && isClientOwned : syncDirection == SyncDirection.ServerToClient; /// The unique network Id of this object (unique at runtime). @@ -244,7 +247,7 @@ protected void InitSyncObject(SyncObject syncObject) // host mode: any ServerToClient and any local client owned if (NetworkServer.active && NetworkClient.active) - return syncDirection == SyncDirection.ServerToClient || isOwned; + return syncDirection == SyncDirection.ServerToClient || isClientOwned; // server only: any ServerToClient if (NetworkServer.active) @@ -254,7 +257,7 @@ protected void InitSyncObject(SyncObject syncObject) if (NetworkClient.active) { // spawned: only ClientToServer and owned - if (netId != 0) return syncDirection == SyncDirection.ClientToServer && isOwned; + if (netId != 0) return syncDirection == SyncDirection.ClientToServer && isClientOwned; // not spawned (character selection previews, etc.): always allow // fixes https://github.com/MirrorNetworking/Mirror/issues/3343 @@ -284,7 +287,7 @@ protected void InitSyncObject(SyncObject syncObject) if (isServer) return netIdentity.observers.Count > 0; // client only: only ClientToServer and owned - if (isClient) return syncDirection == SyncDirection.ClientToServer && isOwned; + if (isClient) return syncDirection == SyncDirection.ClientToServer && isClientOwned; // users may add to SyncLists before the object was spawned. // isServer / isClient would still be false. @@ -340,7 +343,7 @@ protected void SendCommandInternal(string functionFullName, int functionHashCode // local players can always send commands, regardless of authority, // other objects must have authority. - if (!(!requiresAuthority || isLocalPlayer || isOwned)) + if (!(!requiresAuthority || isLocalPlayer || isClientOwned)) { Debug.LogWarning($"Command {functionFullName} called on {name} without authority.", gameObject); return; diff --git a/Assets/Mirror/Core/NetworkClient.cs b/Assets/Mirror/Core/NetworkClient.cs index 5685f2058b4..37199987e9b 100644 --- a/Assets/Mirror/Core/NetworkClient.cs +++ b/Assets/Mirror/Core/NetworkClient.cs @@ -1044,7 +1044,7 @@ internal static void ApplySpawnPayload(NetworkIdentity identity, SpawnMessage me // the below DeserializeClient call invokes SyncVarHooks. // flags always need to be initialized before that. // fixes: https://github.com/MirrorNetworking/Mirror/issues/3259 - identity.isOwned = message.isOwner; + identity.isClientOwned = message.isOwner; identity.netId = message.netId; if (message.isLocalPlayer) @@ -1069,7 +1069,7 @@ internal static void ApplySpawnPayload(NetworkIdentity identity, SpawnMessage me } spawned[message.netId] = identity; - if (identity.isOwned) connection?.owned.Add(identity); + if (identity.isClientOwned) connection?.owned.Add(identity); // the initial spawn with OnObjectSpawnStarted/Finished calls all // object's OnStartClient/OnStartLocalPlayer after they were all @@ -1279,7 +1279,7 @@ internal static void OnHostClientSpawn(SpawnMessage message) if (aoi != null) aoi.SetHostVisibility(identity, true); - identity.isOwned = message.isOwner; + identity.isClientOwned = message.isOwner; BootstrapIdentity(identity); } } @@ -1357,10 +1357,10 @@ internal static void ChangeOwner(NetworkIdentity identity, ChangeOwnerMessage me } // set ownership flag (aka authority) - identity.isOwned = message.isOwner; + identity.isClientOwned = message.isOwner; // Add / Remove to client's connectionToServer.owned hashset. - if (identity.isOwned) + if (identity.isClientOwned) connection?.owned.Add(identity); else connection?.owned.Remove(identity); diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index 5b8120229ae..4c02823c2bf 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -91,11 +91,15 @@ public sealed class NetworkIdentity : MonoBehaviour /// isOwned is true on the client if this NetworkIdentity is one of the .owned entities of our connection on the server. // for example: main player & pets are owned. monsters & npcs aren't. - public bool isOwned { get; internal set; } + // this flag is client-only, not for the server. + public bool isClientOwned { get; internal set; } + + [Obsolete(".isOwned was renamed to .isClientOwned to reflect that it's a client-only flag.")] + public bool isOwned => isClientOwned; // Deprecated 2022-10-13 - [Obsolete(".hasAuthority was renamed to .isOwned. This is easier to understand and prepares for SyncDirection, where there is a difference betwen isOwned and authority.")] - public bool hasAuthority => isOwned; + [Obsolete(".hasAuthority was renamed to .isClientOwned. This is easier to understand and prepares for SyncDirection, where there is a difference betwen isOwned and authority.")] + public bool hasAuthority => isClientOwned; /// The set of network connections (players) that can see this object. public readonly Dictionary observers = @@ -864,7 +868,7 @@ ulong ClientDirtyMask() // on client, only consider owned components with SyncDirection to server NetworkBehaviour component = components[i]; - if (isOwned && component.syncDirection == SyncDirection.ClientToServer) + if (isClientOwned && component.syncDirection == SyncDirection.ClientToServer) { // set the n-th bit if dirty // shifting from small to large numbers is varint-efficient. @@ -1296,7 +1300,7 @@ internal void Reset() //isLocalPlayer = false; <- cleared AFTER ClearLocalPlayer below! // remove authority flag. This object may be unspawned, not destroyed, on client. - isOwned = false; + isClientOwned = false; NotifyAuthority(); netId = 0; @@ -1323,11 +1327,11 @@ internal void Reset() bool hadAuthority; internal void NotifyAuthority() { - if (!hadAuthority && isOwned) + if (!hadAuthority && isClientOwned) OnStartAuthority(); - if (hadAuthority && !isOwned) + if (hadAuthority && !isClientOwned) OnStopAuthority(); - hadAuthority = isOwned; + hadAuthority = isClientOwned; } internal void OnStartAuthority() diff --git a/Assets/Mirror/Core/NetworkServer.cs b/Assets/Mirror/Core/NetworkServer.cs index d3aee5be1aa..e0b5817807e 100644 --- a/Assets/Mirror/Core/NetworkServer.cs +++ b/Assets/Mirror/Core/NetworkServer.cs @@ -940,7 +940,7 @@ public static bool AddPlayerForConnection(NetworkConnectionToClient conn, GameOb // special case, we are in host mode, set hasAuthority to true so that all overrides see it if (conn is LocalConnectionToClient) { - identity.isOwned = true; + identity.isClientOwned = true; NetworkClient.InternalAddPlayer(identity); } @@ -983,7 +983,7 @@ public static bool ReplacePlayerForConnection(NetworkConnectionToClient conn, Ga // special case, we are in host mode, set hasAuthority to true so that all overrides see it if (conn is LocalConnectionToClient) { - identity.isOwned = true; + identity.isClientOwned = true; NetworkClient.InternalAddPlayer(identity); } @@ -1397,7 +1397,7 @@ static void SpawnObject(GameObject obj, NetworkConnection ownerConnection) // special case to make sure hasAuthority is set // on start server in host mode if (ownerConnection is LocalConnectionToClient) - identity.isOwned = true; + identity.isClientOwned = true; // only call OnStartServer if not spawned yet. // check used to be in NetworkIdentity. may not be necessary anymore. @@ -1515,7 +1515,7 @@ static void DestroyObject(NetworkIdentity identity, DestroyMode mode) // The object may have been spawned with host client ownership, // e.g. a pet so we need to clear hasAuthority and call // NotifyAuthority which invokes OnStopAuthority if hasAuthority. - identity.isOwned = false; + identity.isClientOwned = false; identity.NotifyAuthority(); // remove from NetworkClient dictionary diff --git a/Assets/Mirror/Editor/NetworkInformationPreview.cs b/Assets/Mirror/Editor/NetworkInformationPreview.cs index ec0a01e5c46..601a0f69381 100644 --- a/Assets/Mirror/Editor/NetworkInformationPreview.cs +++ b/Assets/Mirror/Editor/NetworkInformationPreview.cs @@ -252,7 +252,7 @@ IEnumerable GetNetworkIdentityInfo(NetworkIdentity identity infos.Add(GetString("Network ID", identity.netId.ToString())); infos.Add(GetBoolean("Is Client", identity.isClient)); infos.Add(GetBoolean("Is Server", identity.isServer)); - infos.Add(GetBoolean("Is Owned", identity.isOwned)); + infos.Add(GetBoolean("Is Owned", identity.isClientOwned)); infos.Add(GetBoolean("Is Local Player", identity.isLocalPlayer)); } return infos; diff --git a/Assets/Mirror/Tests/Common/MirrorTest.cs b/Assets/Mirror/Tests/Common/MirrorTest.cs index 41f0ce58f78..46d91641fd1 100644 --- a/Assets/Mirror/Tests/Common/MirrorTest.cs +++ b/Assets/Mirror/Tests/Common/MirrorTest.cs @@ -263,7 +263,7 @@ protected void CreateNetworkedAndSpawn( // double check that we have authority if we passed an owner connection if (ownerConnection != null) - Debug.Assert(clientIdentity.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientIdentity.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); // make sure the client really spawned it. Assert.That(NetworkClient.spawned.ContainsKey(serverIdentity.netId)); @@ -286,7 +286,7 @@ protected void CreateNetworkedAndSpawn(out GameObject go, out NetworkIdentity // double check that we have authority if we passed an owner connection if (ownerConnection != null) - Debug.Assert(component.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(component.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); } // create GameObject + NetworkIdentity + NetworkBehaviour in children & SPAWN @@ -306,7 +306,7 @@ protected void CreateNetworkedChildAndSpawn(out GameObject parent, out GameOb // double check that we have authority if we passed an owner connection if (ownerConnection != null) - Debug.Assert(component.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(component.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); } // create GameObject + NetworkIdentity + NetworkBehaviour & SPAWN @@ -342,7 +342,7 @@ protected void CreateNetworkedAndSpawn( // double check that we have authority if we passed an owner connection if (ownerConnection != null) - Debug.Assert(clientComponent.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientComponent.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); // make sure the client really spawned it. Assert.That(NetworkClient.spawned.ContainsKey(serverIdentity.netId)); @@ -381,7 +381,7 @@ protected void CreateNetworkedChildAndSpawn( // double check that we have authority if we passed an owner connection if (ownerConnection != null) - Debug.Assert(clientComponent.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientComponent.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); // make sure the client really spawned it. Assert.That(NetworkClient.spawned.ContainsKey(serverIdentity.netId)); @@ -406,8 +406,8 @@ protected void CreateNetworkedAndSpawn(out GameObject go, out NetworkIdent // double check that we have authority if we passed an owner connection if (ownerConnection != null) { - Debug.Assert(componentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); - Debug.Assert(componentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(componentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(componentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); } } @@ -430,8 +430,8 @@ protected void CreateNetworkedChildAndSpawn(out GameObject parent, out Gam // double check that we have authority if we passed an owner connection if (ownerConnection != null) { - Debug.Assert(componentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); - Debug.Assert(componentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(componentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(componentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); } } @@ -470,8 +470,8 @@ protected void CreateNetworkedAndSpawn( // double check that we have authority if we passed an owner connection if (ownerConnection != null) { - Debug.Assert(clientComponentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); - Debug.Assert(clientComponentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientComponentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientComponentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); } // make sure the client really spawned it. @@ -513,8 +513,8 @@ protected void CreateNetworkedChildAndSpawn( // double check that we have authority if we passed an owner connection if (ownerConnection != null) { - Debug.Assert(clientComponentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); - Debug.Assert(clientComponentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientComponentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientComponentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); } // make sure the client really spawned it. @@ -541,9 +541,9 @@ protected void CreateNetworkedAndSpawn(out GameObject go, out NetworkId // double check that we have authority if we passed an owner connection if (ownerConnection != null) { - Debug.Assert(componentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); - Debug.Assert(componentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); - Debug.Assert(componentC.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(componentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(componentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(componentC.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); } } @@ -567,9 +567,9 @@ protected void CreateNetworkedChildAndSpawn(out GameObject parent, out // double check that we have authority if we passed an owner connection if (ownerConnection != null) { - Debug.Assert(componentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); - Debug.Assert(componentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); - Debug.Assert(componentC.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(componentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(componentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(componentC.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); } } @@ -609,9 +609,9 @@ protected void CreateNetworkedAndSpawn( // double check that we have authority if we passed an owner connection if (ownerConnection != null) { - Debug.Assert(clientComponentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); - Debug.Assert(clientComponentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); - Debug.Assert(clientComponentC.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientComponentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientComponentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientComponentC.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); } // make sure the client really spawned it. @@ -654,9 +654,9 @@ protected void CreateNetworkedChildAndSpawn( // double check that we have authority if we passed an owner connection if (ownerConnection != null) { - Debug.Assert(clientComponentA.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); - Debug.Assert(clientComponentB.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); - Debug.Assert(clientComponentC.isOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientComponentA.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientComponentB.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); + Debug.Assert(clientComponentC.isClientOwned == true, $"Behaviour Had Wrong Authority when spawned, This means that the test is broken and will give the wrong results"); } // make sure the client really spawned it. diff --git a/Assets/Mirror/Tests/Editor/NetworkBehaviour/NetworkBehaviourTests.cs b/Assets/Mirror/Tests/Editor/NetworkBehaviour/NetworkBehaviourTests.cs index 712416a4bc1..9940beb9a90 100644 --- a/Assets/Mirror/Tests/Editor/NetworkBehaviour/NetworkBehaviourTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkBehaviour/NetworkBehaviourTests.cs @@ -106,7 +106,7 @@ public void HasNoAuthorityByDefault() { // no authority by default CreateNetworked(out _, out _, out EmptyBehaviour emptyBehaviour); - Assert.That(emptyBehaviour.isOwned, Is.False); + Assert.That(emptyBehaviour.isClientOwned, Is.False); } [Test] diff --git a/Assets/Mirror/Tests/Editor/NetworkClient/NetworkClientTests_OnSpawn.cs b/Assets/Mirror/Tests/Editor/NetworkClient/NetworkClientTests_OnSpawn.cs index 36181999b66..0a664a8c84a 100644 --- a/Assets/Mirror/Tests/Editor/NetworkClient/NetworkClientTests_OnSpawn.cs +++ b/Assets/Mirror/Tests/Editor/NetworkClient/NetworkClientTests_OnSpawn.cs @@ -415,11 +415,11 @@ public void ApplyPayload_AppliesAuthority(bool isOwner) }; // set to opposite to make sure it is changed - identity.isOwned = !isOwner; + identity.isClientOwned = !isOwner; NetworkClient.ApplySpawnPayload(identity, msg); - Assert.That(identity.isOwned, Is.EqualTo(isOwner)); + Assert.That(identity.isClientOwned, Is.EqualTo(isOwner)); } [Test] diff --git a/Assets/Mirror/Tests/Editor/NetworkIdentity/NetworkIdentitySerializationTests.cs b/Assets/Mirror/Tests/Editor/NetworkIdentity/NetworkIdentitySerializationTests.cs index 84bf9175b1a..d065115ad83 100644 --- a/Assets/Mirror/Tests/Editor/NetworkIdentity/NetworkIdentitySerializationTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkIdentity/NetworkIdentitySerializationTests.cs @@ -252,7 +252,7 @@ public void SerializeAndDeserialize_ClientToServer_NOT_OWNED() // set to CLIENT with some unique values // and set connection to server to pretend we are the owner. - identity.isOwned = false; + identity.isClientOwned = false; identity.connectionToServer = null; // NOT OWNED comp1.syncDirection = SyncDirection.ServerToClient; comp1.value = 12345; diff --git a/Assets/Mirror/Tests/Editor/NetworkIdentity/NetworkIdentityTests.cs b/Assets/Mirror/Tests/Editor/NetworkIdentity/NetworkIdentityTests.cs index 169c0141f06..1fa71f7a451 100644 --- a/Assets/Mirror/Tests/Editor/NetworkIdentity/NetworkIdentityTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkIdentity/NetworkIdentityTests.cs @@ -379,40 +379,40 @@ public void NotifyAuthorityCallsOnStartStopAuthority() CreateNetworked(out GameObject _, out NetworkIdentity identity, out NetworkBehaviourMock comp); // set authority from false to true, which should call OnStartAuthority - identity.isOwned = true; + identity.isClientOwned = true; identity.NotifyAuthority(); // shouldn't be touched - Assert.That(identity.isOwned, Is.True); + Assert.That(identity.isClientOwned, Is.True); // start should be called Assert.That(comp.onStartAuthorityCalled, Is.EqualTo(1)); // stop shouldn't Assert.That(comp.onStopAuthorityCalled, Is.EqualTo(0)); // set it to true again, should do nothing because already true - identity.isOwned = true; + identity.isClientOwned = true; identity.NotifyAuthority(); // shouldn't be touched - Assert.That(identity.isOwned, Is.True); + Assert.That(identity.isClientOwned, Is.True); // same as before Assert.That(comp.onStartAuthorityCalled, Is.EqualTo(1)); // same as before Assert.That(comp.onStopAuthorityCalled, Is.EqualTo(0)); // set it to false, should call OnStopAuthority - identity.isOwned = false; + identity.isClientOwned = false; identity.NotifyAuthority(); // should be changed - Assert.That(identity.isOwned, Is.False); + Assert.That(identity.isClientOwned, Is.False); // same as before Assert.That(comp.onStartAuthorityCalled, Is.EqualTo(1)); // stop should be called Assert.That(comp.onStopAuthorityCalled, Is.EqualTo(1)); // set it to false again, should do nothing because already false - identity.isOwned = false; + identity.isClientOwned = false; identity.NotifyAuthority(); // shouldn't be touched - Assert.That(identity.isOwned, Is.False); + Assert.That(identity.isClientOwned, Is.False); // same as before Assert.That(comp.onStartAuthorityCalled, Is.EqualTo(1)); // same as before @@ -676,7 +676,7 @@ public void Reset() Assert.That(identity.netId, Is.EqualTo(0)); Assert.That(identity.connectionToClient, Is.Null); Assert.That(identity.connectionToServer, Is.Null); - Assert.That(identity.isOwned, Is.False); + Assert.That(identity.isClientOwned, Is.False); Assert.That(identity.observers, Is.Empty); } diff --git a/Assets/Mirror/Tests/Editor/NetworkServer/NetworkServerTest.cs b/Assets/Mirror/Tests/Editor/NetworkServer/NetworkServerTest.cs index cd01b5f821b..897724c874a 100644 --- a/Assets/Mirror/Tests/Editor/NetworkServer/NetworkServerTest.cs +++ b/Assets/Mirror/Tests/Editor/NetworkServer/NetworkServerTest.cs @@ -324,7 +324,7 @@ public void Destroy_HostMode_CallsOnStopAuthority() NetworkServer.localConnection); // need to have authority for this test - Assert.That(player.isOwned, Is.True); + Assert.That(player.isClientOwned, Is.True); // destroy and ignore 'Destroy called in Edit mode' error LogAssert.ignoreFailingMessages = true; @@ -1070,11 +1070,11 @@ public void UnSpawnAndClearAuthority() go.SetActive(true); // set authority from false to true, which should call OnStartAuthority - identity.isOwned = true; + identity.isClientOwned = true; identity.NotifyAuthority(); // shouldn't be touched - Assert.That(identity.isOwned, Is.True); + Assert.That(identity.isClientOwned, Is.True); // start should be called Assert.That(comp.onStartAuthorityCalled, Is.EqualTo(1)); // stop shouldn't @@ -1085,7 +1085,7 @@ public void UnSpawnAndClearAuthority() Assert.That(identity.netId, Is.Zero); // should be changed - Assert.That(identity.isOwned, Is.False); + Assert.That(identity.isClientOwned, Is.False); // same as before Assert.That(comp.onStartAuthorityCalled, Is.EqualTo(1)); // stop should be called