From 668dc91ffbe57cb92dd2a637d0215cdcc70ac62c Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Fri, 12 Jan 2024 11:37:14 -0500 Subject: [PATCH 1/9] feat(NetworkIdentity): Reuse Network IDs - Uses a Queue (FIFO) with delay time in seconds - Configurable in Network Manager (Enabled & Delay) - Pool shown in NI Info Panel --- Assets/Mirror/Core/NetworkIdentity.cs | 51 +++++++++++++++++-- Assets/Mirror/Core/NetworkManager.cs | 11 ++++ .../Editor/NetworkInformationPreview.cs | 21 ++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index 8248988cb..7e7082c43 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -264,17 +264,52 @@ internal static void ResetClientStatics() internal static void ResetServerStatics() { + poolNetworkIds = true; + reuseDelay = 1; + + netIdPool.Clear(); nextNetworkId = 1; } /// Gets the NetworkIdentity from the sceneIds dictionary with the corresponding id public static NetworkIdentity GetSceneIdentity(ulong id) => sceneIds[id]; + #region NetworkID Handling + + internal static bool poolNetworkIds = true; + internal static byte reuseDelay = 1; + + internal struct NetworkIdPool + { + public uint poolNetId; + public double timeAvailable; + } + + // pool of NetworkIds that can be reused + internal static readonly Queue netIdPool = new Queue(); static uint nextNetworkId = 1; - internal static uint GetNextNetworkId() => nextNetworkId++; + + internal static uint GetNextNetworkId() + { + if (poolNetworkIds && netIdPool.TryPeek(out NetworkIdPool entry) && entry.timeAvailable < NetworkTime.time) + { + //Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.poolNetId}."); + + netIdPool.Dequeue(); + return entry.poolNetId; + } + + return nextNetworkId++; + } /// Resets nextNetworkId = 1 - public static void ResetNextNetworkId() => nextNetworkId = 1; + public static void ResetNextNetworkId() + { + netIdPool.Clear(); + nextNetworkId = 1; + } + + #endregion /// The delegate type for the clientAuthorityCallback. public delegate void ClientAuthorityCallback(NetworkConnectionToClient conn, NetworkIdentity identity, bool authorityState); @@ -628,6 +663,9 @@ void OnDestroy() NetworkServer.Destroy(gameObject); } + if (isServer && poolNetworkIds && netId > 0) + netIdPool.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); + if (isLocalPlayer) { // previously there was a bug where isLocalPlayer was @@ -1298,7 +1336,14 @@ internal void Reset() isOwned = false; NotifyAuthority(); - netId = 0; + if (netId > 0) + { + if (poolNetworkIds) + netIdPool.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); + + netId = 0; + } + connectionToServer = null; connectionToClient = null; diff --git a/Assets/Mirror/Core/NetworkManager.cs b/Assets/Mirror/Core/NetworkManager.cs index 150daccb4..5648a4d92 100644 --- a/Assets/Mirror/Core/NetworkManager.cs +++ b/Assets/Mirror/Core/NetworkManager.cs @@ -63,6 +63,13 @@ public class NetworkManager : MonoBehaviour // [Tooltip("Client broadcasts 'sendRate' times per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.")] // public int clientSendRate = 30; // 33 ms + [Header("Network ID Pooling")] + [Tooltip("Reuse network IDs when objects are unspawned or destroyed?")] + public bool poolNetworkIds = true; + [Range(1, 30)] + [Tooltip("Delay in seconds before network IDs are reused")] + public byte reuseDelay = 1; + /// Automatically switch to this scene upon going offline (on start / on disconnect / on shutdown). [Header("Scene Management")] [Scene] @@ -321,6 +328,10 @@ void SetupServer() NetworkServer.disconnectInactiveTimeout = disconnectInactiveTimeout; NetworkServer.exceptionsDisconnect = exceptionsDisconnect; + // Setup reuseable network IDs + NetworkIdentity.poolNetworkIds = poolNetworkIds; + NetworkIdentity.reuseDelay = reuseDelay; + if (runInBackground) Application.runInBackground = true; diff --git a/Assets/Mirror/Editor/NetworkInformationPreview.cs b/Assets/Mirror/Editor/NetworkInformationPreview.cs index ec0a01e5c..b663cf641 100644 --- a/Assets/Mirror/Editor/NetworkInformationPreview.cs +++ b/Assets/Mirror/Editor/NetworkInformationPreview.cs @@ -113,6 +113,8 @@ public override void OnPreviewGUI(Rect r, GUIStyle background) Y = DrawObservers(identity, initialX, Y); + Y = DrawNetworkIDPool(initialX, Y); + _ = DrawOwner(identity, initialX, Y); } @@ -191,6 +193,25 @@ float DrawObservers(NetworkIdentity identity, float initialX, float Y) return Y; } + float DrawNetworkIDPool(float initialX, float Y) + { + if (NetworkIdentity.netIdPool.Count > 0) + { + Rect poolRect = new Rect(initialX, Y + 10, 200, 20); + GUI.Label(poolRect, new GUIContent("Network ID Pool"), styles.componentName); + poolRect.x += 20; + poolRect.y += poolRect.height; + foreach (var entry in NetworkIdentity.netIdPool) + { + GUI.Label(poolRect, $"[{entry.poolNetId}] {entry.timeAvailable:0.000}", styles.labelStyle); + poolRect.y += poolRect.height; + Y = poolRect.y; + } + } + + return Y; + } + float DrawOwner(NetworkIdentity identity, float initialX, float Y) { if (identity.connectionToClient != null) From 3436df7ca4aef5fc720deeb12dfdf7be012b2388 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Fri, 12 Jan 2024 12:24:45 -0500 Subject: [PATCH 2/9] Can't use TryPeek in older Unity --- Assets/Mirror/Core/NetworkIdentity.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index 7e7082c43..bad5968e7 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -291,11 +291,10 @@ internal struct NetworkIdPool internal static uint GetNextNetworkId() { - if (poolNetworkIds && netIdPool.TryPeek(out NetworkIdPool entry) && entry.timeAvailable < NetworkTime.time) + if (poolNetworkIds && netIdPool.Count > 0 && netIdPool.Peek().timeAvailable < NetworkTime.time) { + NetworkIdPool entry = netIdPool.Dequeue(); //Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.poolNetId}."); - - netIdPool.Dequeue(); return entry.poolNetId; } From 387be93703dec141752b6ea92d3cc80db06b4ede Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Sat, 13 Jan 2024 16:22:07 -0500 Subject: [PATCH 3/9] Renamed poolNetworkIds to reuseNetworkIds - Also changed header and range upper limit --- Assets/Mirror/Core/NetworkIdentity.cs | 10 +++++----- Assets/Mirror/Core/NetworkManager.cs | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index bad5968e7..622bc121e 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -264,7 +264,7 @@ internal static void ResetClientStatics() internal static void ResetServerStatics() { - poolNetworkIds = true; + reuseNetworkIds = true; reuseDelay = 1; netIdPool.Clear(); @@ -276,7 +276,7 @@ internal static void ResetServerStatics() #region NetworkID Handling - internal static bool poolNetworkIds = true; + internal static bool reuseNetworkIds = true; internal static byte reuseDelay = 1; internal struct NetworkIdPool @@ -291,7 +291,7 @@ internal struct NetworkIdPool internal static uint GetNextNetworkId() { - if (poolNetworkIds && netIdPool.Count > 0 && netIdPool.Peek().timeAvailable < NetworkTime.time) + if (reuseNetworkIds && netIdPool.Count > 0 && netIdPool.Peek().timeAvailable < NetworkTime.time) { NetworkIdPool entry = netIdPool.Dequeue(); //Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.poolNetId}."); @@ -662,7 +662,7 @@ void OnDestroy() NetworkServer.Destroy(gameObject); } - if (isServer && poolNetworkIds && netId > 0) + if (isServer && reuseNetworkIds && netId > 0) netIdPool.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); if (isLocalPlayer) @@ -1337,7 +1337,7 @@ internal void Reset() if (netId > 0) { - if (poolNetworkIds) + if (reuseNetworkIds) netIdPool.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); netId = 0; diff --git a/Assets/Mirror/Core/NetworkManager.cs b/Assets/Mirror/Core/NetworkManager.cs index 5648a4d92..41c52c47f 100644 --- a/Assets/Mirror/Core/NetworkManager.cs +++ b/Assets/Mirror/Core/NetworkManager.cs @@ -63,10 +63,10 @@ public class NetworkManager : MonoBehaviour // [Tooltip("Client broadcasts 'sendRate' times per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.")] // public int clientSendRate = 30; // 33 ms - [Header("Network ID Pooling")] + [Header("Network ID Reuse")] [Tooltip("Reuse network IDs when objects are unspawned or destroyed?")] - public bool poolNetworkIds = true; - [Range(1, 30)] + public bool reuseNetworkIds = true; + [Range(1, 60)] [Tooltip("Delay in seconds before network IDs are reused")] public byte reuseDelay = 1; @@ -329,7 +329,7 @@ void SetupServer() NetworkServer.exceptionsDisconnect = exceptionsDisconnect; // Setup reuseable network IDs - NetworkIdentity.poolNetworkIds = poolNetworkIds; + NetworkIdentity.reuseNetworkIds = reuseNetworkIds; NetworkIdentity.reuseDelay = reuseDelay; if (runInBackground) From 8de9789faa705f071ede923f1a946f60add77830 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Mon, 15 Jan 2024 17:01:52 -0500 Subject: [PATCH 4/9] Renamed netIdPool to netIdQueue --- Assets/Mirror/Core/NetworkIdentity.cs | 14 +++++++------- Assets/Mirror/Editor/NetworkInformationPreview.cs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index 622bc121e..19032e925 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -267,7 +267,7 @@ internal static void ResetServerStatics() reuseNetworkIds = true; reuseDelay = 1; - netIdPool.Clear(); + netIdQueue.Clear(); nextNetworkId = 1; } @@ -286,14 +286,14 @@ internal struct NetworkIdPool } // pool of NetworkIds that can be reused - internal static readonly Queue netIdPool = new Queue(); + internal static readonly Queue netIdQueue = new Queue(); static uint nextNetworkId = 1; internal static uint GetNextNetworkId() { - if (reuseNetworkIds && netIdPool.Count > 0 && netIdPool.Peek().timeAvailable < NetworkTime.time) + if (reuseNetworkIds && netIdQueue.Count > 0 && netIdQueue.Peek().timeAvailable < NetworkTime.time) { - NetworkIdPool entry = netIdPool.Dequeue(); + NetworkIdPool entry = netIdQueue.Dequeue(); //Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.poolNetId}."); return entry.poolNetId; } @@ -304,7 +304,7 @@ internal static uint GetNextNetworkId() /// Resets nextNetworkId = 1 public static void ResetNextNetworkId() { - netIdPool.Clear(); + netIdQueue.Clear(); nextNetworkId = 1; } @@ -663,7 +663,7 @@ void OnDestroy() } if (isServer && reuseNetworkIds && netId > 0) - netIdPool.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); + netIdQueue.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); if (isLocalPlayer) { @@ -1338,7 +1338,7 @@ internal void Reset() if (netId > 0) { if (reuseNetworkIds) - netIdPool.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); + netIdQueue.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); netId = 0; } diff --git a/Assets/Mirror/Editor/NetworkInformationPreview.cs b/Assets/Mirror/Editor/NetworkInformationPreview.cs index b663cf641..0dfd93945 100644 --- a/Assets/Mirror/Editor/NetworkInformationPreview.cs +++ b/Assets/Mirror/Editor/NetworkInformationPreview.cs @@ -195,13 +195,13 @@ float DrawObservers(NetworkIdentity identity, float initialX, float Y) float DrawNetworkIDPool(float initialX, float Y) { - if (NetworkIdentity.netIdPool.Count > 0) + if (NetworkIdentity.netIdQueue.Count > 0) { Rect poolRect = new Rect(initialX, Y + 10, 200, 20); - GUI.Label(poolRect, new GUIContent("Network ID Pool"), styles.componentName); + GUI.Label(poolRect, new GUIContent("Network ID Queue"), styles.componentName); poolRect.x += 20; poolRect.y += poolRect.height; - foreach (var entry in NetworkIdentity.netIdPool) + foreach (var entry in NetworkIdentity.netIdQueue) { GUI.Label(poolRect, $"[{entry.poolNetId}] {entry.timeAvailable:0.000}", styles.labelStyle); poolRect.y += poolRect.height; From 8df429d4748cc002f87cf98d7fc73d42a33d165f Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Mon, 15 Jan 2024 17:14:15 -0500 Subject: [PATCH 5/9] NetworkInformationPreview: fixed styles --- Assets/Mirror/Editor/NetworkInformationPreview.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Mirror/Editor/NetworkInformationPreview.cs b/Assets/Mirror/Editor/NetworkInformationPreview.cs index 0dfd93945..3998cd37e 100644 --- a/Assets/Mirror/Editor/NetworkInformationPreview.cs +++ b/Assets/Mirror/Editor/NetworkInformationPreview.cs @@ -198,12 +198,12 @@ float DrawNetworkIDPool(float initialX, float Y) if (NetworkIdentity.netIdQueue.Count > 0) { Rect poolRect = new Rect(initialX, Y + 10, 200, 20); - GUI.Label(poolRect, new GUIContent("Network ID Queue"), styles.componentName); + GUI.Label(poolRect, new GUIContent("Network ID Queue"), styles.labelStyle); poolRect.x += 20; poolRect.y += poolRect.height; foreach (var entry in NetworkIdentity.netIdQueue) { - GUI.Label(poolRect, $"[{entry.poolNetId}] {entry.timeAvailable:0.000}", styles.labelStyle); + GUI.Label(poolRect, $"[{entry.poolNetId}] {entry.timeAvailable:0.000}", styles.componentName); poolRect.y += poolRect.height; Y = poolRect.y; } From 035afd140e869acd92db604e9ae455578dda748a Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Mon, 15 Jan 2024 18:39:31 -0500 Subject: [PATCH 6/9] Better naming --- Assets/Mirror/Core/NetworkIdentity.cs | 16 ++++++++-------- .../Mirror/Editor/NetworkInformationPreview.cs | 18 +++++++++--------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index 19032e925..a3291e2e7 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -274,28 +274,28 @@ internal static void ResetServerStatics() /// Gets the NetworkIdentity from the sceneIds dictionary with the corresponding id public static NetworkIdentity GetSceneIdentity(ulong id) => sceneIds[id]; - #region NetworkID Handling + #region Network ID Reuse internal static bool reuseNetworkIds = true; internal static byte reuseDelay = 1; - internal struct NetworkIdPool + internal struct ReusableNetworkId { - public uint poolNetId; + public uint reusableNetId; public double timeAvailable; } // pool of NetworkIds that can be reused - internal static readonly Queue netIdQueue = new Queue(); + internal static readonly Queue netIdQueue = new Queue(); static uint nextNetworkId = 1; internal static uint GetNextNetworkId() { if (reuseNetworkIds && netIdQueue.Count > 0 && netIdQueue.Peek().timeAvailable < NetworkTime.time) { - NetworkIdPool entry = netIdQueue.Dequeue(); + ReusableNetworkId entry = netIdQueue.Dequeue(); //Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.poolNetId}."); - return entry.poolNetId; + return entry.reusableNetId; } return nextNetworkId++; @@ -663,7 +663,7 @@ void OnDestroy() } if (isServer && reuseNetworkIds && netId > 0) - netIdQueue.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); + netIdQueue.Enqueue(new ReusableNetworkId { reusableNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); if (isLocalPlayer) { @@ -1338,7 +1338,7 @@ internal void Reset() if (netId > 0) { if (reuseNetworkIds) - netIdQueue.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); + netIdQueue.Enqueue(new ReusableNetworkId { reusableNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); netId = 0; } diff --git a/Assets/Mirror/Editor/NetworkInformationPreview.cs b/Assets/Mirror/Editor/NetworkInformationPreview.cs index 3998cd37e..882483679 100644 --- a/Assets/Mirror/Editor/NetworkInformationPreview.cs +++ b/Assets/Mirror/Editor/NetworkInformationPreview.cs @@ -113,7 +113,7 @@ public override void OnPreviewGUI(Rect r, GUIStyle background) Y = DrawObservers(identity, initialX, Y); - Y = DrawNetworkIDPool(initialX, Y); + Y = DrawNetworkIDQueue(initialX, Y); _ = DrawOwner(identity, initialX, Y); @@ -193,19 +193,19 @@ float DrawObservers(NetworkIdentity identity, float initialX, float Y) return Y; } - float DrawNetworkIDPool(float initialX, float Y) + float DrawNetworkIDQueue(float initialX, float Y) { if (NetworkIdentity.netIdQueue.Count > 0) { - Rect poolRect = new Rect(initialX, Y + 10, 200, 20); - GUI.Label(poolRect, new GUIContent("Network ID Queue"), styles.labelStyle); - poolRect.x += 20; - poolRect.y += poolRect.height; + Rect netIdRect = new Rect(initialX, Y + 10, 200, 20); + GUI.Label(netIdRect, new GUIContent("Network ID Queue"), styles.labelStyle); + netIdRect.x += 20; + netIdRect.y += netIdRect.height; foreach (var entry in NetworkIdentity.netIdQueue) { - GUI.Label(poolRect, $"[{entry.poolNetId}] {entry.timeAvailable:0.000}", styles.componentName); - poolRect.y += poolRect.height; - Y = poolRect.y; + GUI.Label(netIdRect, $"[{entry.reusableNetId}] {entry.timeAvailable:0.000}", styles.componentName); + netIdRect.y += netIdRect.height; + Y = netIdRect.y; } } From 60a186c5f2de7a7c974891bc17afb4fa1511e4f6 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Wed, 17 Jan 2024 04:38:24 -0500 Subject: [PATCH 7/9] Comments --- Assets/Mirror/Core/NetworkIdentity.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index a3291e2e7..8b084a497 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -291,10 +291,11 @@ internal struct ReusableNetworkId internal static uint GetNextNetworkId() { + // Older Unity versions don't have TryPeek. if (reuseNetworkIds && netIdQueue.Count > 0 && netIdQueue.Peek().timeAvailable < NetworkTime.time) { ReusableNetworkId entry = netIdQueue.Dequeue(); - //Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.poolNetId}."); + //Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.reusableNetId}."); return entry.reusableNetId; } From dd4f345cb62f82a00ded8be8e9e7e6ab350f0539 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Wed, 17 Jan 2024 04:50:06 -0500 Subject: [PATCH 8/9] Better naming --- Assets/Mirror/Core/NetworkIdentity.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index 8b084a497..0e3cdd078 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -294,9 +294,9 @@ internal static uint GetNextNetworkId() // Older Unity versions don't have TryPeek. if (reuseNetworkIds && netIdQueue.Count > 0 && netIdQueue.Peek().timeAvailable < NetworkTime.time) { - ReusableNetworkId entry = netIdQueue.Dequeue(); - //Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.reusableNetId}."); - return entry.reusableNetId; + ReusableNetworkId nextNetId = netIdQueue.Dequeue(); + Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {nextNetId.reusableNetId}."); + return nextNetId.reusableNetId; } return nextNetworkId++; From c719049888834e0708298a0592ba35d887936eb2 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Wed, 17 Jan 2024 04:50:47 -0500 Subject: [PATCH 9/9] Disable log --- Assets/Mirror/Core/NetworkIdentity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index 0e3cdd078..7e51976b9 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -295,7 +295,7 @@ internal static uint GetNextNetworkId() if (reuseNetworkIds && netIdQueue.Count > 0 && netIdQueue.Peek().timeAvailable < NetworkTime.time) { ReusableNetworkId nextNetId = netIdQueue.Dequeue(); - Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {nextNetId.reusableNetId}."); + //Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {nextNetId.reusableNetId}."); return nextNetId.reusableNetId; }