Skip to content

Commit 7cf31e1

Browse files
committed
remove empty space, comments and redudant else + add 1 missing log level check
1 parent 1c78a7a commit 7cf31e1

File tree

1 file changed

+7
-31
lines changed

1 file changed

+7
-31
lines changed

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

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,10 @@ internal void SpawnInternal(bool destroyWithScene, ulong ownerClientId, bool pla
18371837
}
18381838
else
18391839
{
1840-
NetworkLog.LogWarningServer($"[{name}] Ran into unknown conditional check during spawn when determining distributed authority mode or not");
1840+
if (NetworkManagerOwner.LogLevel <= LogLevel.Normal)
1841+
{
1842+
NetworkLog.LogWarningServer($"[{name}] Ran into unknown conditional check during spawn when determining distributed authority mode or not");
1843+
}
18411844
}
18421845
}
18431846

@@ -1863,7 +1866,6 @@ public static NetworkObject InstantiateAndSpawn(GameObject networkPrefab, Networ
18631866
{
18641867
NetworkLog.LogError($"The {nameof(NetworkPrefab)} {networkPrefab.name} does not have a {nameof(NetworkObject)} component!");
18651868
}
1866-
18671869
return null;
18681870
}
18691871
return networkObject.InstantiateAndSpawn(networkManager, ownerClientId, destroyWithScene, isPlayerObject, forceOverride, position, rotation);
@@ -1983,7 +1985,6 @@ public void Despawn(bool destroy = true)
19831985
{
19841986
NetworkLog.LogErrorServer($"[{name}][Attempted despawn before {nameof(NetworkObject)} was spawned]");
19851987
}
1986-
19871988
return;
19881989
}
19891990

@@ -2033,10 +2034,8 @@ public void ChangeOwnership(ulong newOwnerClientId)
20332034
{
20342035
NetworkLog.LogErrorServer($"[{name}][Attempted ownership change before {nameof(NetworkObject)} was spawned]");
20352036
}
2036-
20372037
return;
20382038
}
2039-
20402039
NetworkManagerOwner.SpawnManager.ChangeOwnership(this, newOwnerClientId, HasAuthority);
20412040
}
20422041

@@ -2052,7 +2051,6 @@ internal void InvokeBehaviourOnOwnershipChanged(ulong originalOwnerClientId, ulo
20522051
{
20532052
NetworkLog.LogErrorServer($"[{name}][Attempted behavior invoke on ownership changed before {nameof(NetworkObject)} was spawned]");
20542053
}
2055-
20562054
return;
20572055
}
20582056

@@ -2087,10 +2085,8 @@ internal void InvokeBehaviourOnOwnershipChanged(ulong originalOwnerClientId, ulo
20872085
{
20882086
NetworkLog.LogWarning($"[{name}] {childBehaviour.gameObject.name} is disabled! Netcode for GameObjects does not support disabled NetworkBehaviours! The {childBehaviour.GetType().Name} component was skipped during ownership assignment!");
20892087
}
2090-
20912088
continue;
20922089
}
2093-
20942090
childBehaviour.InternalOnGainedOwnership();
20952091
}
20962092
}
@@ -2741,7 +2737,6 @@ internal List<NetworkBehaviour> ChildNetworkBehaviours
27412737
}
27422738
#endif
27432739
}
2744-
27452740
return m_ChildNetworkBehaviours;
27462741
}
27472742
}
@@ -2908,9 +2903,7 @@ internal struct SerializedObject
29082903
public bool HasParent;
29092904
public bool IsSceneObject;
29102905
public bool HasTransform;
2911-
29122906
public bool IsLatestParentSet;
2913-
29142907
public bool WorldPositionStays;
29152908

29162909
/// <summary>
@@ -2920,15 +2913,10 @@ internal struct SerializedObject
29202913
/// to the current active scene when its scene is unloaded. (only for dynamically spawned)
29212914
/// </summary>
29222915
public bool DestroyWithScene;
2923-
29242916
public bool DontDestroyWithOwner;
2925-
29262917
public bool HasOwnershipFlags;
2927-
29282918
public bool SyncObservers;
2929-
29302919
public bool SpawnWithObservers;
2931-
29322920
public bool HasInstantiationData;
29332921

29342922
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -3020,9 +3008,6 @@ public struct TransformData : INetworkSerializeByMemcpy
30203008

30213009
public TransformData Transform;
30223010

3023-
//If(Metadata.IsReparented)
3024-
3025-
//If(IsLatestParentSet)
30263011
public ulong? LatestParent;
30273012

30283013
public NetworkObject OwnerObject;
@@ -3342,11 +3327,8 @@ internal static NetworkObject Deserialize(in SerializedObject serializedObject,
33423327
reader.ReadValueSafe(out instantiationData);
33433328
}
33443329

3345-
33463330
// Attempt to create a local NetworkObject
33473331
var networkObject = networkManager.SpawnManager.CreateLocalNetworkObject(serializedObject, instantiationData);
3348-
3349-
33503332
if (networkObject == null)
33513333
{
33523334
// Log the error that the NetworkObject failed to construct
@@ -3368,7 +3350,6 @@ internal static NetworkObject Deserialize(in SerializedObject serializedObject,
33683350
// We have nothing left to do here.
33693351
return null;
33703352
}
3371-
33723353
networkObject.NetworkManagerOwner = networkManager;
33733354

33743355
// This will get set again when the NetworkObject is spawned locally, but we set it here ahead of spawning
@@ -3392,7 +3373,6 @@ internal static NetworkObject Deserialize(in SerializedObject serializedObject,
33923373
{
33933374
NetworkLog.LogWarning($"[Size mismatch] Expected: {endOfSynchronizationData} Currently At: {reader.Position}!");
33943375
}
3395-
33963376
reader.Seek(endOfSynchronizationData);
33973377
}
33983378
}
@@ -3661,17 +3641,13 @@ internal uint CheckForGlobalObjectIdHashOverride()
36613641
{
36623642
return PrefabGlobalObjectIdHash;
36633643
}
3664-
else
3644+
// For legacy manual instantiation and spawning, check the OverrideToNetworkPrefab for a possible match
3645+
if (networkManager.NetworkConfig.Prefabs.OverrideToNetworkPrefab.ContainsKey(GlobalObjectIdHash))
36653646
{
3666-
// For legacy manual instantiation and spawning, check the OverrideToNetworkPrefab for a possible match
3667-
if (networkManager.NetworkConfig.Prefabs.OverrideToNetworkPrefab.ContainsKey(GlobalObjectIdHash))
3668-
{
3669-
return networkManager.NetworkConfig.Prefabs.OverrideToNetworkPrefab[GlobalObjectIdHash];
3670-
}
3647+
return networkManager.NetworkConfig.Prefabs.OverrideToNetworkPrefab[GlobalObjectIdHash];
36713648
}
36723649
}
36733650
}
3674-
36753651
return GlobalObjectIdHash;
36763652
}
36773653

0 commit comments

Comments
 (0)