Simplify admin promotion check in ValidateClient.

This also fixes a crash if we want to allow
multiple admins in a server.
This commit is contained in:
Paul Chote
2013-06-05 22:13:44 +12:00
parent 8c9fb382e3
commit 18f1683968

View File

@@ -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)
// 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);