Renamed netIdPool to netIdQueue

This commit is contained in:
MrGadget 2024-01-15 17:01:52 -05:00
parent 387be93703
commit 8de9789faa
2 changed files with 10 additions and 10 deletions

View File

@ -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<NetworkIdPool> netIdPool = new Queue<NetworkIdPool>();
internal static readonly Queue<NetworkIdPool> netIdQueue = new Queue<NetworkIdPool>();
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()
/// <summary>Resets nextNetworkId = 1</summary>
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;
}

View File

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