From e228601a5c4ff44630c3fb2bedb662ca0d482ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 6 Jun 2015 13:13:01 +0200 Subject: [PATCH] fix NullReferenceExceptions during client pings --- OpenRA.Game/Server/Server.cs | 6 +++++- OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 2d0f117e81..7b59ff8181 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -489,7 +489,11 @@ namespace OpenRA.Server break; } - var pingFromClient = LobbyInfo.PingFromClient(GetClient(conn)); + var client = GetClient(conn); + if (client == null) + return; + + var pingFromClient = LobbyInfo.PingFromClient(client); if (pingFromClient == null) return; diff --git a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs index e7eff5123f..32c89dc851 100644 --- a/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.Common/ServerTraits/LobbyCommands.cs @@ -186,8 +186,11 @@ namespace OpenRA.Mods.Common.Server server.LobbyInfo.Clients.Remove(occupant); server.SyncLobbyClients(); var ping = server.LobbyInfo.PingFromClient(occupant); - server.LobbyInfo.ClientPings.Remove(ping); - server.SyncClientPing(); + if (ping != null) + { + server.LobbyInfo.ClientPings.Remove(ping); + server.SyncClientPing(); + } } else { @@ -221,7 +224,11 @@ namespace OpenRA.Mods.Common.Server { server.LobbyInfo.Clients.Remove(occupant); var ping = server.LobbyInfo.PingFromClient(occupant); - server.LobbyInfo.ClientPings.Remove(ping); + if (ping != null) + { + server.LobbyInfo.ClientPings.Remove(ping); + server.SyncClientPing(); + } } server.SyncLobbyClients();