Renamed poolNetworkIds to reuseNetworkIds

- Also changed header and range upper limit
This commit is contained in:
MrGadget 2024-01-13 16:22:07 -05:00
parent 3436df7ca4
commit 387be93703
2 changed files with 9 additions and 9 deletions

View File

@ -264,7 +264,7 @@ internal static void ResetClientStatics()
internal static void ResetServerStatics() internal static void ResetServerStatics()
{ {
poolNetworkIds = true; reuseNetworkIds = true;
reuseDelay = 1; reuseDelay = 1;
netIdPool.Clear(); netIdPool.Clear();
@ -276,7 +276,7 @@ internal static void ResetServerStatics()
#region NetworkID Handling #region NetworkID Handling
internal static bool poolNetworkIds = true; internal static bool reuseNetworkIds = true;
internal static byte reuseDelay = 1; internal static byte reuseDelay = 1;
internal struct NetworkIdPool internal struct NetworkIdPool
@ -291,7 +291,7 @@ internal struct NetworkIdPool
internal static uint GetNextNetworkId() 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(); NetworkIdPool entry = netIdPool.Dequeue();
//Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.poolNetId}."); //Debug.LogFormat(LogType.Log, LogOption.NoStacktrace, null, $"[GetNextNetworkId] Reusing NetworkId {entry.poolNetId}.");
@ -662,7 +662,7 @@ void OnDestroy()
NetworkServer.Destroy(gameObject); NetworkServer.Destroy(gameObject);
} }
if (isServer && poolNetworkIds && netId > 0) if (isServer && reuseNetworkIds && netId > 0)
netIdPool.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); netIdPool.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay });
if (isLocalPlayer) if (isLocalPlayer)
@ -1337,7 +1337,7 @@ internal void Reset()
if (netId > 0) if (netId > 0)
{ {
if (poolNetworkIds) if (reuseNetworkIds)
netIdPool.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay }); netIdPool.Enqueue(new NetworkIdPool { poolNetId = netId, timeAvailable = NetworkTime.time + reuseDelay });
netId = 0; netId = 0;

View File

@ -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.")] // [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 // public int clientSendRate = 30; // 33 ms
[Header("Network ID Pooling")] [Header("Network ID Reuse")]
[Tooltip("Reuse network IDs when objects are unspawned or destroyed?")] [Tooltip("Reuse network IDs when objects are unspawned or destroyed?")]
public bool poolNetworkIds = true; public bool reuseNetworkIds = true;
[Range(1, 30)] [Range(1, 60)]
[Tooltip("Delay in seconds before network IDs are reused")] [Tooltip("Delay in seconds before network IDs are reused")]
public byte reuseDelay = 1; public byte reuseDelay = 1;
@ -329,7 +329,7 @@ void SetupServer()
NetworkServer.exceptionsDisconnect = exceptionsDisconnect; NetworkServer.exceptionsDisconnect = exceptionsDisconnect;
// Setup reuseable network IDs // Setup reuseable network IDs
NetworkIdentity.poolNetworkIds = poolNetworkIds; NetworkIdentity.reuseNetworkIds = reuseNetworkIds;
NetworkIdentity.reuseDelay = reuseDelay; NetworkIdentity.reuseDelay = reuseDelay;
if (runInBackground) if (runInBackground)