diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 3532b87ec0..6ce5885c74 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -236,7 +236,25 @@ namespace OpenRA.Server } var handshake = HandshakeResponse.Deserialize(data); - var client = handshake.Client; + + var client = new Session.Client() + { + Name = handshake.Client.Name, + IpAddress = ((IPEndPoint)newConn.socket.RemoteEndPoint).Address.ToString(), + Index = newConn.PlayerIndex, + Slot = lobbyInfo.FirstEmptySlot(), + PreferredColor = handshake.Client.Color, + Color = handshake.Client.Color, + Country = "random", + SpawnPoint = 0, + Team = 0, + State = Session.ClientState.NotReady, + IsAdmin = !lobbyInfo.Clients.Any(c1 => c1.IsAdmin) + }; + + if (client.Slot != null) + SyncClientToPlayerReference(client, Map.Players[client.Slot]); + var mods = handshake.Mods; // Check that the client has compatible mods @@ -267,8 +285,6 @@ namespace OpenRA.Server return; } - client.IpAddress = ((IPEndPoint)newConn.socket.RemoteEndPoint).Address.ToString(); - // Check if IP is banned if (lobbyInfo.GlobalSettings.Ban != null) { @@ -287,21 +303,8 @@ namespace OpenRA.Server // Promote connection to a valid client preConns.Remove(newConn); conns.Add(newConn); - - // Enforce correct PlayerIndex and Slot - client.Index = newConn.PlayerIndex; - client.Slot = lobbyInfo.FirstEmptySlot(); - - if (client.Slot != null) - SyncClientToPlayerReference(client, Map.Players[client.Slot]); - lobbyInfo.Clients.Add(client); - // 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; - Log.Write("server", "Client {0}: Accepted connection from {1}.", newConn.PlayerIndex, newConn.socket.RemoteEndPoint); @@ -320,12 +323,6 @@ namespace OpenRA.Server SendOrderTo(newConn, "Message", motd); } - if (lobbyInfo.GlobalSettings.Dedicated) - { - var message = client.IsAdmin ? "You are the server admin." : "{0} is the server admin.".F(clientAdmin.Name); - SendOrderTo(newConn, "Message", message); - } - if (mods.Any(m => m.Contains("{DEV_VERSION}"))) SendMessage("{0} is running an unversioned development build, ".F(client.Name) + "and may desynchronize the game state if they have incompatible rules.");