diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs
index 848eaa2e4e..6d42f0ef8a 100644
--- a/OpenRA.Game/Game.cs
+++ b/OpenRA.Game/Game.cs
@@ -191,7 +191,7 @@ namespace OpenRA
public static void InitializeSettings(Arguments args)
{
- Settings = new Settings(Platform.ResolvePath("^", "settings.yaml"), args);
+ Settings = new Settings(Platform.ResolvePath(Path.Combine("^", "settings.yaml")), args);
}
internal static void Initialize(Arguments args)
diff --git a/OpenRA.Game/Platform.cs b/OpenRA.Game/Platform.cs
index 62da9a8548..260684d20e 100644
--- a/OpenRA.Game/Platform.cs
+++ b/OpenRA.Game/Platform.cs
@@ -95,11 +95,19 @@ namespace OpenRA
public static string GameDir { get { return AppDomain.CurrentDomain.BaseDirectory; } }
- /// Replace special character prefixes with full paths
+ /// Replaces special character prefixes with full paths.
public static string ResolvePath(string path)
{
path = path.TrimEnd(new char[] { ' ', '\t' });
+ // If the path contains ':', chances are it is a package path.
+ // If it isn't, someone passed an already resolved path, which is wrong.
+ if (path.IndexOf(":", StringComparison.Ordinal) > 1)
+ {
+ var split = path.Split(':');
+ return ResolvePath(split[0], split[1]);
+ }
+
// paths starting with ^ are relative to the support dir
if (path.StartsWith("^"))
path = SupportDir + path.Substring(1);
@@ -111,7 +119,17 @@ namespace OpenRA
return path;
}
- /// Replace special character prefixes with full paths
+ /// Replaces package names with full paths. Avoid using this for non-package paths.
+ public static string ResolvePath(string package, string target)
+ {
+ // Resolve mod package paths.
+ if (ModMetadata.AllMods.ContainsKey(package))
+ package = ModMetadata.CandidateModPaths[package];
+
+ return ResolvePath(Path.Combine(package, target));
+ }
+
+ /// Replace special character prefixes with full paths.
public static string ResolvePath(params string[] path)
{
return ResolvePath(path.Aggregate(Path.Combine));
diff --git a/OpenRA.Game/Renderer.cs b/OpenRA.Game/Renderer.cs
index 114ddbd98b..6989ec3ca7 100644
--- a/OpenRA.Game/Renderer.cs
+++ b/OpenRA.Game/Renderer.cs
@@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
+using System.IO;
using System.Linq;
using System.Reflection;
using OpenRA.Graphics;
@@ -49,7 +50,7 @@ namespace OpenRA
var resolution = GetResolution(graphicSettings);
var rendererName = serverSettings.Dedicated ? "Null" : graphicSettings.Renderer;
- var rendererPath = Platform.ResolvePath(".", "OpenRA.Platforms." + rendererName + ".dll");
+ var rendererPath = Platform.ResolvePath(Path.Combine(".", "OpenRA.Platforms." + rendererName + ".dll"));
Device = CreateDevice(Assembly.LoadFile(rendererPath), resolution.Width, resolution.Height, graphicSettings.Mode);
diff --git a/OpenRA.Game/Sound/Sound.cs b/OpenRA.Game/Sound/Sound.cs
index 7f49409871..c78e03b00b 100644
--- a/OpenRA.Game/Sound/Sound.cs
+++ b/OpenRA.Game/Sound/Sound.cs
@@ -33,7 +33,7 @@ namespace OpenRA
public Sound(string engineName)
{
- var enginePath = Platform.ResolvePath(".", "OpenRA.Platforms." + engineName + ".dll");
+ var enginePath = Platform.ResolvePath(Path.Combine(".", "OpenRA.Platforms." + engineName + ".dll"));
soundEngine = CreateDevice(Assembly.LoadFile(enginePath));
}