Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Engine.SupportDir argument. #15514

Merged
merged 1 commit into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions OpenRA.Game/Game.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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