From c99f89c98746efb8557526033217f9af8ae89baa Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 19 Dec 2010 18:32:56 +1300 Subject: [PATCH] fix crash on server overfill, fix another problem preventing spec slots from autofilling --- OpenRA.Game/Server/Server.cs | 7 +++++-- OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index cf921d35bb..d1a7001bfe 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -263,15 +263,18 @@ namespace OpenRA.Server case "Chat": case "TeamChat": + var fromClient = GetClient(conn); + var fromIndex = fromClient != null ? fromClient.Index : 0; + foreach (var c in conns.Except(conn).ToArray()) - DispatchOrdersToClient(c, GetClient(conn).Index, 0, so.Serialize()); + DispatchOrdersToClient(c, fromIndex, 0, so.Serialize()); break; } } public Session.Client GetClient(Connection conn) { - return lobbyInfo.Clients.First(c => c.Index == conn.PlayerIndex); + return lobbyInfo.ClientWithIndex(conn.PlayerIndex); } public void DropClient(Connection toDrop, Exception e) diff --git a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs index d288ba4c7a..c5bb5dba45 100644 --- a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs @@ -285,7 +285,7 @@ namespace OpenRA.Mods.RA.Server }; var slotData = server.lobbyInfo.Slots.FirstOrDefault( x => x.Index == client.Slot ); - if (slotData != null) + if (slotData != null && slotData.MapPlayer != null) SyncClientToPlayerReference(client, server.Map.Players[slotData.MapPlayer]); server.lobbyInfo.Clients.Add(client);