From 6b164672eb075336b71566015870ad6c69763257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 7 Apr 2013 21:00:27 +0200 Subject: [PATCH] Don't crash when host leaves the lobby, fixes #2980 --- OpenRA.Game/Server/Server.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 6468f0c11a..ebdef63822 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -517,13 +517,14 @@ namespace OpenRA.Server SendDisconnected(toDrop); /* Report disconnection */ lobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex); - // remove the bots he added - lobbyInfo.Clients.RemoveAll(c => c.BotControllerClientIndex == toDrop.PlayerIndex); // reassign admin if necessary if (lobbyInfo.GlobalSettings.Dedicated && dropClient.IsAdmin && State == ServerState.WaitingPlayers) { - if (lobbyInfo.Clients.Where(c1 => c1.Bot == null).Count() > 0) + // clean up the bots that were added by the last admin + lobbyInfo.Clients.RemoveAll(c => c.Bot != null && c.BotControllerClientIndex == toDrop.PlayerIndex); + + if (lobbyInfo.Clients.Any(c1 => c1.Bot == null)) { // client was not alone on the server but he was admin: set admin to the last connected client OpenRA.Network.Session.Client lastClient = lobbyInfo.Clients.Where(c1 => c1.Bot == null).Last();