Always update player info on server join

This commit is contained in:
Paul Chote
2010-07-27 21:52:21 +12:00
parent cfd0e045cb
commit f10e3a4d2d
3 changed files with 21 additions and 4 deletions

View File

@@ -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());
}

View File

@@ -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,

View File

@@ -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<ChatDisplayWidget>("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)