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:
@@ -293,11 +293,10 @@ namespace OpenRA.Server
|
|||||||
|
|
||||||
lobbyInfo.Clients.Add(client);
|
lobbyInfo.Clients.Add(client);
|
||||||
|
|
||||||
// Assume that first validated client is server admin
|
// Promote to admin if this is the first client
|
||||||
if (lobbyInfo.Clients.Where(c1 => c1.Bot == null).Count() == 1)
|
var clientAdmin = lobbyInfo.Clients.Where(c1 => c1.IsAdmin).FirstOrDefault() ?? client;
|
||||||
client.IsAdmin=true;
|
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}.",
|
Log.Write("server", "Client {0}: Accepted connection from {1}.",
|
||||||
newConn.PlayerIndex, newConn.socket.RemoteEndPoint);
|
newConn.PlayerIndex, newConn.socket.RemoteEndPoint);
|
||||||
|
|||||||
Reference in New Issue
Block a user