Merge pull request #12795 from pchote/settings-restart

Use external mod switching plumbing to restart after settings changes.
This commit is contained in:
reaperrr
2017-02-19 13:57:05 +01:00
committed by GitHub
4 changed files with 16 additions and 18 deletions

View File

@@ -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);

View File

@@ -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();
}
}
}