bandaid for invalid master client id being sent by server

upm
Anton Franzluebbers 2022-04-01 14:37:08 -04:00
parent 36f16b35df
commit eeb539ba49
1 changed files with 11 additions and 3 deletions

View File

@ -472,8 +472,16 @@ namespace VelNet
case ChangeMasterMessage cm:
{
if (masterPlayer == null)
{
if (players.ContainsKey(cm.masterId))
{
masterPlayer = players[cm.masterId];
}
else
{
masterPlayer = players.Aggregate((p1, p2) => p1.Value.userid.CompareTo(p2.Value.userid) > 0 ? p1 : p2).Value;
Debug.LogError("Got an invalid master client id from the server. Using fallback.");
}
// no master player yet, add the scene objects