Skip to content

Commit 63301e0

Browse files
fix - update
Removing the additional authority check as it is not needed. Fixing a very edge case scenario that shouldn't happen but in the event it does when finding objects by type within a specific scene, if the scene is invalid then use an empty array for the found objects.
1 parent 9571eda commit 63301e0

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ private struct ObjectsInSceneEnumerator<T> : IEnumerable<T>, IEnumerator<T> wher
6969
internal ObjectsInSceneEnumerator(Scene scene, bool includeInactive)
7070
{
7171
m_IncludeInactive = includeInactive;
72-
73-
m_RootObjects = scene.GetRootGameObjects();
72+
// If the scene is invalid, use an empty array.
73+
m_RootObjects = scene.IsValid() ? scene.GetRootGameObjects() : new UnityEngine.GameObject[0];
7474
m_RootIndex = 0;
7575
m_CurrentChildObjects = null;
7676
m_CurrentChildIndex = 0;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2961,7 +2961,7 @@ internal bool InitializeChildNetworkBehaviours()
29612961
/// </remarks>
29622962
/// <param name="originalOwnerId">the owner prior to beginning the change in ownership change.</param>
29632963
/// <param name="originalPreviousOwnerId">the previous owner prior to beginning the change in ownership change.</param>
2964-
internal void SynchronizeOwnerNetworkVariables(ulong originalOwnerId, ulong originalPreviousOwnerId, bool authorityChangedOwnership = false)
2964+
internal void SynchronizeOwnerNetworkVariables(ulong originalOwnerId, ulong originalPreviousOwnerId)
29652965
{
29662966
var currentOwnerId = OwnerClientId;
29672967
OwnerClientId = originalOwnerId;
@@ -2973,7 +2973,7 @@ internal void SynchronizeOwnerNetworkVariables(ulong originalOwnerId, ulong orig
29732973

29742974
// If the spawn authority of a distributed authority network topology has invoked a change in ownership,
29752975
// then we want to invoke the NetworkBehaviourUpdate prior to changing the owner back.
2976-
if (authorityChangedOwnership && NetworkManager.DistributedAuthorityMode)
2976+
if (NetworkManager.DistributedAuthorityMode)
29772977
{
29782978
// Force send a state update for all owner read NetworkVariables and any currently dirty
29792979
// owner write NetworkVariables.

com.unity.netcode.gameobjects/Runtime/Messaging/Messages/ChangeOwnershipMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private void HandleOwnershipChange(ref NetworkContext context, ref NetworkManage
241241
if (!distributedAuthorityMode && originalOwner == networkManager.LocalClientId)
242242
{
243243
// Fully synchronize NetworkVariables with either read or write ownership permissions.
244-
networkObject.SynchronizeOwnerNetworkVariables(originalOwner, networkObject.PreviousOwnerId, true);
244+
networkObject.SynchronizeOwnerNetworkVariables(originalOwner, networkObject.PreviousOwnerId);
245245
}
246246

247247
// Always invoke ownership change notifications

0 commit comments

Comments
 (0)