diff --git a/OpenRA.Game/Network/OrderManager.cs b/OpenRA.Game/Network/OrderManager.cs index cd0724cdb5..44dc8ad93c 100755 --- a/OpenRA.Game/Network/OrderManager.cs +++ b/OpenRA.Game/Network/OrderManager.cs @@ -27,6 +27,7 @@ namespace OpenRA.Network public readonly string Host; public readonly int Port; + public string ServerError; public int NetFrameNumber { get; private set; } public int LocalFrameNumber; diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index efd62b056b..04d4b10d5a 100755 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -38,7 +38,7 @@ namespace OpenRA.Network switch (order.OrderString) { - case "Chat": + case "Chat": { var client = orderManager.LobbyInfo.ClientWithIndex(clientId); if (client != null) @@ -128,7 +128,9 @@ namespace OpenRA.Network orderManager.IssueOrder(Order.HandshakeResponse(response.Serialize())); break; } - + case "ServerError": + orderManager.ServerError = order.TargetString; + break; case "SyncInfo": { orderManager.LobbyInfo = Session.Deserialize(order.TargetString); diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index f8de2e542c..d62af107a9 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -310,10 +310,15 @@ namespace OpenRA.Server public void SendChatTo(Connection conn, string text) { - DispatchOrdersToClient(conn, 0, 0, - new ServerOrder("Chat", text).Serialize()); + SendOrderTo(conn, "Chat", text); } + public void SendOrderTo(Connection conn, string order, string data) + { + DispatchOrdersToClient(conn, 0, 0, + new ServerOrder(order, data).Serialize()); + } + public void SendChat(Connection asConn, string text) { DispatchOrders(asConn, 0, new ServerOrder("Chat", text).Serialize()); diff --git a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs index 53f5b1161b..06de8007cb 100644 --- a/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs +++ b/OpenRA.Mods.RA/ServerTraits/LobbyCommands.cs @@ -241,7 +241,8 @@ namespace OpenRA.Mods.RA.Server server.SendChatTo( conn, "Noone in that slot." ); return true; } - + + server.SendOrderTo(connToKick, "ServerError", "You have been kicked from the server"); server.DropClient(connToKick); server.SyncLobbyInfo(); diff --git a/OpenRA.Mods.RA/Widgets/Delegates/ConnectionDialogsDelegate.cs b/OpenRA.Mods.RA/Widgets/Delegates/ConnectionDialogsDelegate.cs index 81f39487e8..753fc00408 100644 --- a/OpenRA.Mods.RA/Widgets/Delegates/ConnectionDialogsDelegate.cs +++ b/OpenRA.Mods.RA/Widgets/Delegates/ConnectionDialogsDelegate.cs @@ -37,8 +37,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates [ObjectCreator.UseCtor] public ConnectionFailedDelegate( [ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] string host, - [ObjectCreator.Param] int port ) + [ObjectCreator.Param] OrderManager orderManager) { widget.GetWidget("CONNECTION_BUTTON_CANCEL").OnMouseUp = mi => { widget.GetWidget("CONNECTION_BUTTON_CANCEL").Parent.Visible = false; @@ -46,12 +45,12 @@ namespace OpenRA.Mods.RA.Widgets.Delegates return true; }; widget.GetWidget("CONNECTION_BUTTON_RETRY").OnMouseUp = mi => { - Game.JoinServer(host, port); + Game.JoinServer(orderManager.Host, orderManager.Port); return true; }; - widget.GetWidget("CONNECTION_FAILED_DESC").GetText = () => - "Could not connect to {0}:{1}".F(host, port); + widget.GetWidget("CONNECTION_FAILED_DESC").GetText = () => string.IsNullOrEmpty(orderManager.ServerError) ? + "Could not connect to {0}:{1}".F(orderManager.Host, orderManager.Port) : orderManager.ServerError; } } } diff --git a/OpenRA.Mods.RA/Widgets/Delegates/MainMenuButtonsDelegate.cs b/OpenRA.Mods.RA/Widgets/Delegates/MainMenuButtonsDelegate.cs index 93dcad4aee..28e82b2ee9 100755 --- a/OpenRA.Mods.RA/Widgets/Delegates/MainMenuButtonsDelegate.cs +++ b/OpenRA.Mods.RA/Widgets/Delegates/MainMenuButtonsDelegate.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates break; case ConnectionState.NotConnected: Widget.OpenWindow( "CONNECTION_FAILED_BG", - new Dictionary { { "host", orderManager.Host }, { "port", orderManager.Port } } ); + new Dictionary { { "orderManager", orderManager } } ); break; case ConnectionState.Connected: var lobby = Widget.OpenWindow( "SERVER_LOBBY", new Dictionary { { "orderManager", orderManager } } );