Skip to content

Commit

Permalink
Add Engine.SupportDir argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote authored and reaperrr committed Aug 17, 2018
1 parent 8c5caaf commit d371196
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions OpenRA.Game/Game.cs
Expand Up @@ -258,6 +258,10 @@ public static RunStatus InitializeAndRun(string[] args)

static void Initialize(Arguments args)
{
var supportDirArg = args.GetValue("Engine.SupportDir", null);
if (supportDirArg != null)
Platform.OverrideSupportDir(supportDirArg);

Console.WriteLine("Platform is {0}", Platform.CurrentPlatform);

// Load the engine version as early as possible so it can be written to exception logs
Expand Down
21 changes: 21 additions & 0 deletions OpenRA.Game/Platform.cs
Expand Up @@ -71,9 +71,30 @@ public static string RuntimeVersion
/// </summary>
public static string SupportDir { get { return supportDir.Value; } }
static Lazy<string> supportDir = Exts.Lazy(GetSupportDir);
static string supportDirOverride;

/// <summary>
/// Specify a custom support directory that already exists on the filesystem.
/// MUST be called before Platform.SupportDir is first accessed.
/// </summary>
public static void OverrideSupportDir(string path)
{
if (!Directory.Exists(path))
throw new DirectoryNotFoundException(path);

if (!path.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal) &&
!path.EndsWith(Path.AltDirectorySeparatorChar.ToString(), StringComparison.Ordinal))
path += Path.DirectorySeparatorChar;

supportDirOverride = path;
}

static string GetSupportDir()
{
// Use the custom override if it has been defined
if (supportDirOverride != null)
return supportDirOverride;

// Use a local directory in the game root if it exists (shared with the system support dir)
var localSupportDir = Path.Combine(GameDir, "Support");
if (Directory.Exists(localSupportDir))
Expand Down
5 changes: 4 additions & 1 deletion OpenRA.Server/Program.cs
Expand Up @@ -11,7 +11,6 @@

using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
using OpenRA.Support;
Expand All @@ -23,6 +22,10 @@ class Program
static void Main(string[] args)
{
var arguments = new Arguments(args);
var supportDirArg = arguments.GetValue("Engine.SupportDir", null);
if (supportDirArg != null)
Platform.OverrideSupportDir(supportDirArg);

Log.AddChannel("debug", "dedicated-debug.log");
Log.AddChannel("perf", "dedicated-perf.log");
Log.AddChannel("server", "dedicated-server.log");
Expand Down

0 comments on commit d371196

Please sign in to comment.