From 9de07af7c94b51bb08c5575e34bfa9e99a68b0ee Mon Sep 17 00:00:00 2001 From: vis2k Date: Mon, 11 Jun 2018 20:12:02 +0200 Subject: [PATCH] NetworkLobbyManager.FindSlot changed to int so it can return '-1' for 'not found', which is more obvious than Byte.MaxValue --- .../Runtime/NetworkLobbyManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Unity-Technologies-networking/Runtime/NetworkLobbyManager.cs b/Unity-Technologies-networking/Runtime/NetworkLobbyManager.cs index ab0a6ba3a..5185b1e2e 100644 --- a/Unity-Technologies-networking/Runtime/NetworkLobbyManager.cs +++ b/Unity-Technologies-networking/Runtime/NetworkLobbyManager.cs @@ -68,10 +68,9 @@ void OnValidate() } } - Byte FindSlot() + int FindSlot() { - int index = Array.FindIndex(lobbySlots, sl => sl == null); - return index != -1 ? (byte)index : Byte.MaxValue; + return Array.FindIndex(lobbySlots, sl => sl == null); } void SceneLoadedForPlayer(NetworkConnection conn, GameObject lobbyPlayerGameObject) @@ -287,8 +286,9 @@ public override void OnServerAddPlayer(NetworkConnection conn, short playerContr return; } - byte slot = FindSlot(); - if (slot == Byte.MaxValue) + // find empty slot and make sure that it's within byte range for packet + int slot = FindSlot(); + if (slot == -1 || slot > byte.MaxValue) { if (LogFilter.logWarn) { Debug.LogWarning("NetworkLobbyManager no space for more players"); } @@ -303,7 +303,7 @@ public override void OnServerAddPlayer(NetworkConnection conn, short playerContr } var newLobbyPlayer = newLobbyGameObject.GetComponent(); - newLobbyPlayer.slot = slot; + newLobbyPlayer.slot = (byte)slot; lobbySlots[slot] = newLobbyPlayer; NetworkServer.AddPlayerForConnection(conn, newLobbyGameObject, playerControllerId);