From b3b10729cda46763767598e337f4d208d65706ee Mon Sep 17 00:00:00 2001 From: teinarss Date: Mon, 19 Apr 2021 19:34:58 +0200 Subject: [PATCH] Remove ServerExternalMod from OrderManager --- OpenRA.Game/Game.cs | 1 + OpenRA.Game/Network/OrderManager.cs | 1 - OpenRA.Game/Network/UnitOrders.cs | 2 +- OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs | 8 ++++---- OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index efff4ea603..9ce90296df 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -1006,5 +1006,6 @@ namespace OpenRA { public static string Password; public static ConnectionTarget Target; + public static ExternalMod ServerExternalMod; } } diff --git a/OpenRA.Game/Network/OrderManager.cs b/OpenRA.Game/Network/OrderManager.cs index 55013af1c2..7562fff0a5 100644 --- a/OpenRA.Game/Network/OrderManager.cs +++ b/OpenRA.Game/Network/OrderManager.cs @@ -30,7 +30,6 @@ namespace OpenRA.Network public string ServerError = null; public bool AuthenticationFailed = false; - public ExternalMod ServerExternalMod = null; public int NetFrameNumber { get; private set; } public int LocalFrameNumber; diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index 4a9ccb82e1..cf8e6c71f6 100644 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -192,7 +192,7 @@ namespace OpenRA.Network Game.ExternalMods.TryGetValue(externalKey, out var external)) { // The ConnectionFailedLogic will prompt the user to switch mods - orderManager.ServerExternalMod = external; + CurrentServerSettings.ServerExternalMod = external; orderManager.Connection.Dispose(); break; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs index e710e1015f..ebb0055949 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ConnectionLogic.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { CloseWindow(); - var switchPanel = om.ServerExternalMod != null ? "CONNECTION_SWITCHMOD_PANEL" : "CONNECTIONFAILED_PANEL"; + var switchPanel = CurrentServerSettings.ServerExternalMod != null ? "CONNECTION_SWITCHMOD_PANEL" : "CONNECTIONFAILED_PANEL"; Ui.OpenWindow(switchPanel, new WidgetArgs() { { "orderManager", om }, @@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic widget.Get("CONNECTING_DESC").GetText = () => $"Could not connect to {connection.Target}"; var connectionError = widget.Get("CONNECTION_ERROR"); - connectionError.GetText = () => orderManager.ServerError ?? orderManager.Connection.ErrorMessage ?? "Unknown error"; + connectionError.GetText = () => orderManager.ServerError ?? connection.ErrorMessage ?? "Unknown error"; var panelTitle = widget.Get("TITLE"); panelTitle.GetText = () => orderManager.AuthenticationFailed ? "Password Required" : "Connection Failed"; @@ -157,14 +157,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic var abortButton = panel.Get("ABORT_BUTTON"); var switchButton = panel.Get("SWITCH_BUTTON"); - var mod = orderManager.ServerExternalMod; + var mod = CurrentServerSettings.ServerExternalMod; var modTitle = mod.Title; var modVersion = mod.Version; switchButton.OnClick = () => { var launchCommand = $"Launch.URI={new UriBuilder("tcp", connection.EndPoint.Address.ToString(), connection.EndPoint.Port)}"; - Game.SwitchToExternalMod(orderManager.ServerExternalMod, new[] { launchCommand }, () => + Game.SwitchToExternalMod(CurrentServerSettings.ServerExternalMod, new[] { launchCommand }, () => { orderManager.ServerError = "Failed to switch mod."; Ui.CloseWindow(); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index 1338520120..93dd9aa4b2 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic Action onRetry = pass => ConnectionLogic.Connect(connection.Target, pass, onConnect, onExit); - var switchPanel = om.ServerExternalMod != null ? "CONNECTION_SWITCHMOD_PANEL" : "CONNECTIONFAILED_PANEL"; + var switchPanel = CurrentServerSettings.ServerExternalMod != null ? "CONNECTION_SWITCHMOD_PANEL" : "CONNECTIONFAILED_PANEL"; Ui.OpenWindow(switchPanel, new WidgetArgs() { { "orderManager", om },