From f10e3a4d2df4af193ccb250b8cae6820ef33a32b Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Tue, 27 Jul 2010 21:52:21 +1200 Subject: [PATCH] Always update player info on server join --- OpenRA.Game/Game.cs | 6 ++++++ OpenRA.Game/Server/Server.cs | 7 ++++--- OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs | 12 +++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index bdddf25f13..8011442a2d 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -161,6 +161,9 @@ namespace OpenRA CurrentHost = host; CurrentPort = port; + lastConnectionState = ConnectionState.PreConnecting; + ConnectionStateChanged(); + orderManager = new OrderManager(new NetworkConnection(host, port), ChooseReplayFilename()); } @@ -171,6 +174,9 @@ namespace OpenRA static void JoinLocal() { + lastConnectionState = ConnectionState.PreConnecting; + ConnectionStateChanged(); + if (orderManager != null) orderManager.Dispose(); orderManager = new OrderManager(new EchoConnection()); } diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index b32ac5ed11..7a0a74041d 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -136,13 +136,14 @@ namespace OpenRA.Server newConn.socket.Send(BitConverter.GetBytes(newConn.PlayerIndex)); conns.Add(newConn); + var defaults = new GameRules.UserSettings(); lobbyInfo.Clients.Add( new Session.Client() { Index = newConn.PlayerIndex, - Color1 = System.Drawing.Color.FromArgb(246,214,121), - Color2 = System.Drawing.Color.FromArgb(40,32,8), - Name = "Player {0}".F(1 + newConn.PlayerIndex), + Color1 = defaults.PlayerColor1, + Color2 = defaults.PlayerColor2, + Name = defaults.PlayerName, Country = "random", State = Session.ClientState.NotReady, SpawnPoint = 0, diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index e3bd43dce1..7345459f6f 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -12,7 +12,8 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; using OpenRA.FileFormats; -using OpenRA.Traits; +using OpenRA.Traits; +using OpenRA.Network; namespace OpenRA.Widgets.Delegates { @@ -107,7 +108,9 @@ namespace OpenRA.Widgets.Delegates startGameButton.IsVisible = () => Game.IsHost; Game.LobbyInfoChanged += JoinedServer; + Game.ConnectionStateChanged += ResetConnectionState; Game.LobbyInfoChanged += UpdatePlayerList; + Game.AddChatLine += lobby.GetWidget("CHAT_DISPLAY").AddLine; bool teamChat = false; @@ -229,6 +232,13 @@ namespace OpenRA.Widgets.Delegates Game.IssueOrder(Order.Command("color {0},{1},{2},{3},{4},{5}".F(c1.R,c1.G,c1.B,c2.R,c2.G,c2.B))); } } + + void ResetConnectionState() + { + if (Game.orderManager.Connection.ConnectionState == ConnectionState.PreConnecting) + hasJoined = false; + } + void UpdatePlayerList() { // This causes problems for people who are in the process of editing their names (the widgets vanish from beneath them)