mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkLobbyManager.FindSlot changed to int so it can return '-1' for 'not found', which is more obvious than Byte.MaxValue
This commit is contained in:
parent
3ac3790ee7
commit
9de07af7c9
@ -68,10 +68,9 @@ void OnValidate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte FindSlot()
|
int FindSlot()
|
||||||
{
|
{
|
||||||
int index = Array.FindIndex(lobbySlots, sl => sl == null);
|
return Array.FindIndex(lobbySlots, sl => sl == null);
|
||||||
return index != -1 ? (byte)index : Byte.MaxValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneLoadedForPlayer(NetworkConnection conn, GameObject lobbyPlayerGameObject)
|
void SceneLoadedForPlayer(NetworkConnection conn, GameObject lobbyPlayerGameObject)
|
||||||
@ -287,8 +286,9 @@ public override void OnServerAddPlayer(NetworkConnection conn, short playerContr
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte slot = FindSlot();
|
// find empty slot and make sure that it's within byte range for packet
|
||||||
if (slot == Byte.MaxValue)
|
int slot = FindSlot();
|
||||||
|
if (slot == -1 || slot > byte.MaxValue)
|
||||||
{
|
{
|
||||||
if (LogFilter.logWarn) { Debug.LogWarning("NetworkLobbyManager no space for more players"); }
|
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<NetworkLobbyPlayer>();
|
var newLobbyPlayer = newLobbyGameObject.GetComponent<NetworkLobbyPlayer>();
|
||||||
newLobbyPlayer.slot = slot;
|
newLobbyPlayer.slot = (byte)slot;
|
||||||
lobbySlots[slot] = newLobbyPlayer;
|
lobbySlots[slot] = newLobbyPlayer;
|
||||||
|
|
||||||
NetworkServer.AddPlayerForConnection(conn, newLobbyGameObject, playerControllerId);
|
NetworkServer.AddPlayerForConnection(conn, newLobbyGameObject, playerControllerId);
|
||||||
|
Loading…
Reference in New Issue
Block a user