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; } }