diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index a7be84ea6c..08552c0127 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(); } } @@ -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(); 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(); };