From 500da075654682ff7aca2ebcc2cb608d1d2e119b Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 18 Feb 2017 11:27:26 +0000 Subject: [PATCH 1/3] Fix mod switching failing when launchArgs is null. --- OpenRA.Game/Game.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index a7be84ea6c..48e6908ea8 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -470,10 +470,8 @@ namespace OpenRA { try { - var argsString = mod.LaunchArgs.Append(launchArguments) - .Select(a => "\"" + a + "\"").JoinWith(" "); - - var p = Process.Start(mod.LaunchPath, argsString); + var args = launchArguments != null ? mod.LaunchArgs.Append(launchArguments) : mod.LaunchArgs; + var p = Process.Start(mod.LaunchPath, args.Select(a => "\"" + a + "\"").JoinWith(" ")); if (p == null || p.HasExited) onFailed(); else @@ -482,8 +480,10 @@ namespace OpenRA Exit(); } } - catch + catch (Exception e) { + Log.Write("debug", "Failed to switch to external mod."); + Log.Write("debug", "Error was: " + e.Message); onFailed(); } } From 073a00a2f4eed2585db84d73e28e5235f5dc8292 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 18 Feb 2017 11:27:45 +0000 Subject: [PATCH 2/3] Use mod switching for settings menu restart. --- OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index b28c1d141c..505d0647d2 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -74,13 +74,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic OriginalGraphicsWindowedSize != current.Graphics.WindowedSize || OriginalGraphicsFullscreenSize != current.Graphics.FullscreenSize || OriginalServerDiscoverNatDevices != current.Server.DiscoverNatDevices) + { + Action restart = () => + { + var external = Game.ExternalMods[ExternalMod.MakeKey(Game.ModData.Manifest)]; + Game.SwitchToExternalMod(external, null, closeAndExit); + }; + ConfirmationDialogs.ButtonPrompt( title: "Restart Now?", text: "Some changes will not be applied until\nthe game is restarted. Restart now?", - onConfirm: Game.Restart, + onConfirm: restart, onCancel: closeAndExit, confirmText: "Restart Now", cancelText: "Restart Later"); + } else closeAndExit(); }; From 11df0216e57f2747d9232ec78102f7db57efad85 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 18 Feb 2017 11:30:27 +0000 Subject: [PATCH 3/3] Remove legacy restart behaviour. --- OpenRA.Game/Game.cs | 5 ----- OpenRA.Game/Support/Program.cs | 7 +------ OpenRA.GameMonitor/GameMonitor.cs | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 48e6908ea8..08552c0127 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -803,11 +803,6 @@ namespace OpenRA state = RunStatus.Success; } - public static void Restart() - { - state = RunStatus.Restart; - } - public static void AddChatLine(Color color, string name, string text) { OrderManager.AddChatLine(color, name, text); diff --git a/OpenRA.Game/Support/Program.cs b/OpenRA.Game/Support/Program.cs index f0f52841fd..b328aa5aed 100644 --- a/OpenRA.Game/Support/Program.cs +++ b/OpenRA.Game/Support/Program.cs @@ -22,7 +22,6 @@ namespace OpenRA { Error = -1, Success = 0, - Restart = 1, Running = int.MaxValue } @@ -131,11 +130,7 @@ namespace OpenRA { Game.Initialize(new Arguments(args)); GC.Collect(); - var status = Game.Run(); - if (status == RunStatus.Restart) - using (var p = Process.GetCurrentProcess()) - Process.Start(Assembly.GetEntryAssembly().Location, p.StartInfo.Arguments); - return status; + return Game.Run(); } } } \ No newline at end of file diff --git a/OpenRA.GameMonitor/GameMonitor.cs b/OpenRA.GameMonitor/GameMonitor.cs index c730795408..d153ee6737 100644 --- a/OpenRA.GameMonitor/GameMonitor.cs +++ b/OpenRA.GameMonitor/GameMonitor.cs @@ -116,7 +116,7 @@ namespace OpenRA static void GameProcessExited(object sender, EventArgs e) { - if (!(gameProcess.ExitCode == (int)RunStatus.Success || gameProcess.ExitCode == (int)RunStatus.Restart)) + if (gameProcess.ExitCode != (int)RunStatus.Success) ShowErrorDialog(); Exit();