Shift Client creation to the client, sent in the handshake response. Fixes the `Newbie' bug and removes a lot of fragmented behaviour on player join.

This commit is contained in:
Paul Chote
2010-12-31 12:51:19 +13:00
parent 8f9e32dcc0
commit e2d1eec56e
6 changed files with 84 additions and 108 deletions

View File

@@ -115,9 +115,6 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
// Todo: Only show if the map requirements are met for player slots
startGameButton.IsVisible = () => Game.IsHost;
Game.LobbyInfoChanged += JoinedServer;
Game.ConnectionStateChanged += ResetConnectionState;
Game.LobbyInfoChanged += UpdatePlayerList;
Game.AddChatLine += lobby.GetWidget<ChatDisplayWidget>("CHAT_DISPLAY").AddLine;
@@ -171,29 +168,6 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
title.Text = "OpenRA Multiplayer Lobby - " + orderManager.LobbyInfo.GlobalSettings.ServerName;
}
bool hasJoined = false;
void JoinedServer()
{
if (hasJoined)
return;
hasJoined = true;
if (orderManager.LocalClient.Name != Game.Settings.Player.Name)
orderManager.IssueOrder(Order.Command("name " + Game.Settings.Player.Name));
var c1 = Game.Settings.Player.Color1;
var c2 = Game.Settings.Player.Color2;
if (orderManager.LocalClient.Color1 != c1 || orderManager.LocalClient.Color2 != c2)
orderManager.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( OrderManager orderManager )
{
if( orderManager.Connection.ConnectionState == ConnectionState.PreConnecting )
hasJoined = false;
}
Session.Client GetClientInSlot(Session.Slot slot)
{
return orderManager.LobbyInfo.ClientInSlot( slot );