Defer setting slot on client to completeConnection

This commit is contained in:
teinarss
2018-11-15 21:27:36 +01:00
committed by Paul Chote
parent b8d3c9f73a
commit 3b6024c086

View File

@@ -324,7 +324,6 @@ namespace OpenRA.Server
Name = OpenRA.Settings.SanitizedPlayerName(handshake.Client.Name), Name = OpenRA.Settings.SanitizedPlayerName(handshake.Client.Name),
IpAddress = ((IPEndPoint)newConn.Socket.RemoteEndPoint).Address.ToString(), IpAddress = ((IPEndPoint)newConn.Socket.RemoteEndPoint).Address.ToString(),
Index = newConn.PlayerIndex, Index = newConn.PlayerIndex,
Slot = LobbyInfo.FirstEmptySlot(),
PreferredColor = handshake.Client.PreferredColor, PreferredColor = handshake.Client.PreferredColor,
Color = handshake.Client.Color, Color = handshake.Client.Color,
Faction = "Random", Faction = "Random",
@@ -341,11 +340,6 @@ namespace OpenRA.Server
return; return;
} }
if (client.Slot != null)
SyncClientToPlayerReference(client, Map.Players.Players[client.Slot]);
else
client.Color = HSLColor.FromRGB(255, 255, 255);
if (ModData.Manifest.Id != handshake.Mod) if (ModData.Manifest.Id != handshake.Mod)
{ {
Log.Write("server", "Rejected connection from {0}; mods do not match.", Log.Write("server", "Rejected connection from {0}; mods do not match.",
@@ -378,6 +372,13 @@ namespace OpenRA.Server
Action completeConnection = () => Action completeConnection = () =>
{ {
client.Slot = LobbyInfo.FirstEmptySlot();
if (client.Slot != null)
SyncClientToPlayerReference(client, Map.Players.Players[client.Slot]);
else
client.Color = HSLColor.FromRGB(255, 255, 255);
// Promote connection to a valid client // Promote connection to a valid client
PreConns.Remove(newConn); PreConns.Remove(newConn);
Conns.Add(newConn); Conns.Add(newConn);