From 18f1683968b335c52e056d81617f08680e7dbf87 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 5 Jun 2013 22:13:44 +1200 Subject: [PATCH] Simplify admin promotion check in ValidateClient. This also fixes a crash if we want to allow multiple admins in a server. --- OpenRA.Game/Server/Server.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index cb0d481268..8c1d686f38 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -293,12 +293,11 @@ namespace OpenRA.Server lobbyInfo.Clients.Add(client); - // Assume that first validated client is server admin - if (lobbyInfo.Clients.Where(c1 => c1.Bot == null).Count() == 1) - client.IsAdmin=true; + // Promote to admin if this is the first client + var clientAdmin = lobbyInfo.Clients.Where(c1 => c1.IsAdmin).FirstOrDefault() ?? client; + if (clientAdmin == client) + client.IsAdmin = true; - OpenRA.Network.Session.Client clientAdmin = lobbyInfo.Clients.Where(c1 => c1.IsAdmin).Single(); - Log.Write("server", "Client {0}: Accepted connection from {1}.", newConn.PlayerIndex, newConn.socket.RemoteEndPoint);