diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 131649c5bd66..bd2d40d59aa1 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -285,7 +285,7 @@ static void Initialize(Arguments args) // Load the engine version as early as possible so it can be written to exception logs try { - EngineVersion = File.ReadAllText(Path.Combine(Platform.GameDir, "VERSION")).Trim(); + EngineVersion = File.ReadAllText(Path.Combine(Platform.EngineDir, "VERSION")).Trim(); } catch { } @@ -324,7 +324,7 @@ static void Initialize(Arguments args) Settings.Game.Platform = p; try { - var rendererPath = Path.Combine(Platform.GameDir, "OpenRA.Platforms." + p + ".dll"); + var rendererPath = Path.Combine(Platform.EngineDir, "OpenRA.Platforms." + p + ".dll"); var assembly = Assembly.LoadFile(rendererPath); var platformType = assembly.GetTypes().SingleOrDefault(t => typeof(IPlatform).IsAssignableFrom(t)); @@ -354,7 +354,7 @@ static void Initialize(Arguments args) var modSearchArg = args.GetValue("Engine.ModSearchPaths", null); var modSearchPaths = modSearchArg != null ? FieldLoader.GetValue("Engine.ModsPath", modSearchArg) : - new[] { Path.Combine(Platform.GameDir, "mods") }; + new[] { Path.Combine(Platform.EngineDir, "mods") }; Mods = new InstalledMods(modSearchPaths, explicitModPaths); Console.WriteLine("Internal mods:"); diff --git a/OpenRA.Game/Platform.cs b/OpenRA.Game/Platform.cs index f5504ee4dbe1..a8ed276f394c 100644 --- a/OpenRA.Game/Platform.cs +++ b/OpenRA.Game/Platform.cs @@ -136,7 +136,7 @@ static void InitializeSupportDir() } // Use a local directory in the game root if it exists (shared with the system support dir) - var localSupportDir = Path.Combine(GameDir, "Support"); + var localSupportDir = Path.Combine(EngineDir, "Support"); if (Directory.Exists(localSupportDir)) userSupportPath = systemSupportPath = localSupportDir + Path.DirectorySeparatorChar; @@ -169,7 +169,7 @@ public static void OverrideSupportDir(string path) userSupportPath = path; } - public static string GameDir + public static string EngineDir { get { @@ -194,10 +194,10 @@ public static string ResolvePath(string path) // Paths starting with . are relative to the game dir if (path == ".") - return GameDir; + return EngineDir; if (path.StartsWith("./", StringComparison.Ordinal) || path.StartsWith(".\\", StringComparison.Ordinal)) - path = GameDir + path.Substring(2); + path = EngineDir + path.Substring(2); return path; } diff --git a/OpenRA.Game/Scripting/ScriptContext.cs b/OpenRA.Game/Scripting/ScriptContext.cs index 9457e490e1d8..5d9ba4820b6c 100644 --- a/OpenRA.Game/Scripting/ScriptContext.cs +++ b/OpenRA.Game/Scripting/ScriptContext.cs @@ -161,8 +161,8 @@ public ScriptContext(World world, WorldRenderer worldRenderer, .ToArray(); PlayerCommands = FilterCommands(world.Map.Rules.Actors["player"], knownPlayerCommands); - runtime.Globals["GameDir"] = Platform.GameDir; - runtime.DoBuffer(File.Open(Path.Combine(Platform.GameDir, "lua", "scriptwrapper.lua"), FileMode.Open, FileAccess.Read).ReadAllText(), "scriptwrapper.lua").Dispose(); + runtime.Globals["EngineDir"] = Platform.EngineDir; + runtime.DoBuffer(File.Open(Path.Combine(Platform.EngineDir, "lua", "scriptwrapper.lua"), FileMode.Open, FileAccess.Read).ReadAllText(), "scriptwrapper.lua").Dispose(); tick = (LuaFunction)runtime.Globals["Tick"]; // Register globals diff --git a/OpenRA.Mods.Common/UtilityCommands/CheckRuntimeAssembliesCommand.cs b/OpenRA.Mods.Common/UtilityCommands/CheckRuntimeAssembliesCommand.cs index 55858057df93..65e788e1b88f 100644 --- a/OpenRA.Mods.Common/UtilityCommands/CheckRuntimeAssembliesCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/CheckRuntimeAssembliesCommand.cs @@ -36,7 +36,7 @@ void IUtilityCommand.Run(Utility utility, string[] args) .ToArray(); // Load the renderer assembly so we can check its dependencies - Assembly.LoadFile(Path.Combine(Platform.GameDir, "OpenRA.Platforms.Default.dll")); + Assembly.LoadFile(Path.Combine(Platform.EngineDir, "OpenRA.Platforms.Default.dll")); var missing = new List(); foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) diff --git a/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs index 6798130a06b2..495e24fa4df4 100644 --- a/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs +++ b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs @@ -81,7 +81,7 @@ void IUtilityCommand.Run(Utility utility, string[] args) maps = modData.MapCache.EnumerateMapsWithoutCaching().ToList(); } else - maps.Add(new Map(modData, new Folder(Platform.GameDir).OpenPackage(args[1], modData.ModFiles))); + maps.Add(new Map(modData, new Folder(Platform.EngineDir).OpenPackage(args[1], modData.ModFiles))); foreach (var testMap in maps) { diff --git a/OpenRA.Mods.Common/UtilityCommands/DumpSequenceSheetsCommand.cs b/OpenRA.Mods.Common/UtilityCommands/DumpSequenceSheetsCommand.cs index 23f2f7379c0a..b62d70d2b740 100644 --- a/OpenRA.Mods.Common/UtilityCommands/DumpSequenceSheetsCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/DumpSequenceSheetsCommand.cs @@ -35,7 +35,7 @@ void IUtilityCommand.Run(Utility utility, string[] args) var palette = new ImmutablePalette(args[1], new int[0]); SequenceProvider sequences = null; - var mapPackage = new Folder(Platform.GameDir).OpenPackage(args[2], modData.ModFiles); + var mapPackage = new Folder(Platform.EngineDir).OpenPackage(args[2], modData.ModFiles); if (mapPackage != null) sequences = new Map(modData, mapPackage).Rules.Sequences; else if (!modData.DefaultSequences.TryGetValue(args[2], out sequences)) diff --git a/OpenRA.Mods.Common/UtilityCommands/ExtractMapRules.cs b/OpenRA.Mods.Common/UtilityCommands/ExtractMapRules.cs index 720bff8f5e3f..8493c30be849 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ExtractMapRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ExtractMapRules.cs @@ -52,7 +52,7 @@ void IUtilityCommand.Run(Utility utility, string[] args) { var modData = Game.ModData = utility.ModData; - var map = new Map(modData, new Folder(Platform.GameDir).OpenPackage(args[1], modData.ModFiles)); + var map = new Map(modData, new Folder(Platform.EngineDir).OpenPackage(args[1], modData.ModFiles)); MergeAndPrint(map, "Rules", map.RuleDefinitions); MergeAndPrint(map, "Sequences", map.SequenceDefinitions); MergeAndPrint(map, "ModelSequences", map.ModelSequenceDefinitions); diff --git a/OpenRA.Mods.Common/UtilityCommands/GetMapHashCommand.cs b/OpenRA.Mods.Common/UtilityCommands/GetMapHashCommand.cs index 820b38427b06..b42e8477a7b7 100644 --- a/OpenRA.Mods.Common/UtilityCommands/GetMapHashCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/GetMapHashCommand.cs @@ -26,7 +26,7 @@ bool IUtilityCommand.ValidateArguments(string[] args) [Desc("MAPFILE", "Generate hash of specified oramap file.")] void IUtilityCommand.Run(Utility utility, string[] args) { - using (var package = new Folder(Platform.GameDir).OpenPackage(args[1], utility.ModData.ModFiles)) + using (var package = new Folder(Platform.EngineDir).OpenPackage(args[1], utility.ModData.ModFiles)) Console.WriteLine(Map.ComputeUID(package)); } } diff --git a/OpenRA.Mods.Common/UtilityCommands/RefreshMapCommand.cs b/OpenRA.Mods.Common/UtilityCommands/RefreshMapCommand.cs index a784e208b7b1..23f6bc9bbee9 100644 --- a/OpenRA.Mods.Common/UtilityCommands/RefreshMapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/RefreshMapCommand.cs @@ -28,7 +28,7 @@ void IUtilityCommand.Run(Utility utility, string[] args) // HACK: The engine code assumes that Game.modData is set. // HACK: We know that maps can only be oramap or folders, which are ReadWrite var modData = Game.ModData = utility.ModData; - using (var package = new Folder(Platform.GameDir).OpenPackage(args[1], modData.ModFiles)) + using (var package = new Folder(Platform.EngineDir).OpenPackage(args[1], modData.ModFiles)) new Map(modData, package).Save((IReadWritePackage)package); } } diff --git a/OpenRA.Mods.Common/UtilityCommands/ResizeMapCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ResizeMapCommand.cs index 1846f3d6ac6b..8f8aed24c4e3 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ResizeMapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ResizeMapCommand.cs @@ -48,7 +48,7 @@ bool IUtilityCommand.ValidateArguments(string[] args) void IUtilityCommand.Run(Utility utility, string[] args) { var modData = Game.ModData = utility.ModData; - map = new Map(modData, new Folder(Platform.GameDir).OpenPackage(args[1], modData.ModFiles)); + map = new Map(modData, new Folder(Platform.EngineDir).OpenPackage(args[1], modData.ModFiles)); Console.WriteLine("Resizing map {0} from {1} to {2},{3}", map.Title, map.MapSize, width, height); map.Resize(width, height); diff --git a/OpenRA.Mods.Common/UtilityCommands/UpdateMapCommand.cs b/OpenRA.Mods.Common/UtilityCommands/UpdateMapCommand.cs index 8a3c45b017c7..ddc828e33082 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpdateMapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpdateMapCommand.cs @@ -36,7 +36,7 @@ void IUtilityCommand.Run(Utility utility, string[] args) var modData = Game.ModData = utility.ModData; // HACK: We know that maps can only be oramap or folders, which are ReadWrite - var package = new Folder(Platform.GameDir).OpenPackage(args[1], modData.ModFiles) as IReadWritePackage; + var package = new Folder(Platform.EngineDir).OpenPackage(args[1], modData.ModFiles) as IReadWritePackage; if (package == null) throw new FileNotFoundException(args[1]); diff --git a/OpenRA.Mods.Common/UtilityCommands/Utilities.cs b/OpenRA.Mods.Common/UtilityCommands/Utilities.cs index 1d7815160688..c8f2cc3ed139 100644 --- a/OpenRA.Mods.Common/UtilityCommands/Utilities.cs +++ b/OpenRA.Mods.Common/UtilityCommands/Utilities.cs @@ -32,7 +32,7 @@ public static MiniYamlNode GetTopLevelNodeByKey(ModData modData, string key, { try { - map = new Map(modData, new Folder(Platform.GameDir).OpenPackage(mapPath, modData.ModFiles)); + map = new Map(modData, new Folder(Platform.EngineDir).OpenPackage(mapPath, modData.ModFiles)); } catch (InvalidDataException ex) { diff --git a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs index df8eb82bb969..8f9295d11178 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs @@ -447,8 +447,8 @@ string GetSourceDisplayName(IReadOnlyPackage source) var compare = Platform.CurrentPlatform == PlatformType.Windows ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; if (name.StartsWith(modData.Manifest.Package.Name, compare)) name = "$" + modData.Manifest.Id + "/" + name.Substring(modData.Manifest.Package.Name.Length + 1); - else if (name.StartsWith(Platform.GameDir, compare)) - name = "./" + name.Substring(Platform.GameDir.Length); + else if (name.StartsWith(Platform.EngineDir, compare)) + name = "./" + name.Substring(Platform.EngineDir.Length); else if (name.StartsWith(Platform.SupportDir, compare)) name = "^" + name.Substring(Platform.SupportDir.Length); } diff --git a/OpenRA.Platforms.Default/Shader.cs b/OpenRA.Platforms.Default/Shader.cs index 0062434af554..0326db182956 100644 --- a/OpenRA.Platforms.Default/Shader.cs +++ b/OpenRA.Platforms.Default/Shader.cs @@ -32,7 +32,7 @@ class Shader : ThreadAffine, IShader protected uint CompileShaderObject(int type, string name) { var ext = type == OpenGL.GL_VERTEX_SHADER ? "vert" : "frag"; - var filename = Path.Combine(Platform.GameDir, "glsl", name + "." + ext); + var filename = Path.Combine(Platform.EngineDir, "glsl", name + "." + ext); var code = File.ReadAllText(filename); var version = OpenGL.Profile == GLProfile.Embedded ? "300 es" : diff --git a/OpenRA.Server/Program.cs b/OpenRA.Server/Program.cs index b2840761dfbb..2378972d0f78 100644 --- a/OpenRA.Server/Program.cs +++ b/OpenRA.Server/Program.cs @@ -54,7 +54,7 @@ static void Main(string[] args) var envModSearchPaths = Environment.GetEnvironmentVariable("MOD_SEARCH_PATHS"); var modSearchPaths = !string.IsNullOrWhiteSpace(envModSearchPaths) ? FieldLoader.GetValue("MOD_SEARCH_PATHS", envModSearchPaths) : - new[] { Path.Combine(Platform.GameDir, "mods") }; + new[] { Path.Combine(Platform.EngineDir, "mods") }; var mods = new InstalledMods(modSearchPaths, explicitModPaths); diff --git a/OpenRA.Test/OpenRA.Game/PlatformTest.cs b/OpenRA.Test/OpenRA.Game/PlatformTest.cs index 4f583b1d5d50..170b1cf14a99 100644 --- a/OpenRA.Test/OpenRA.Game/PlatformTest.cs +++ b/OpenRA.Test/OpenRA.Game/PlatformTest.cs @@ -18,13 +18,13 @@ namespace OpenRA.Test public class PlatformTest { string supportDir; - string gameDir; + string engineDir; [SetUp] public void SetUp() { supportDir = Platform.SupportDir; - gameDir = Platform.GameDir; + engineDir = Platform.EngineDir; } [TestCase(TestName = "Returns literal paths")] @@ -34,13 +34,13 @@ public void ResolvePath() Is.EqualTo(Path.Combine(supportDir, "testpath"))); Assert.That(Platform.ResolvePath(".\\testpath"), - Is.EqualTo(Path.Combine(gameDir, "testpath"))); + Is.EqualTo(Path.Combine(engineDir, "testpath"))); Assert.That(Platform.ResolvePath("./testpath"), - Is.EqualTo(Path.Combine(gameDir, "testpath"))); + Is.EqualTo(Path.Combine(engineDir, "testpath"))); Assert.That(Platform.ResolvePath(Path.Combine(".", "Foo.dll")), - Is.EqualTo(Path.Combine(gameDir, "Foo.dll"))); + Is.EqualTo(Path.Combine(engineDir, "Foo.dll"))); Assert.That(Platform.ResolvePath("testpath"), Is.EqualTo("testpath")); diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index 40cdd191eae6..96a2bd0ea4ad 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -48,7 +48,7 @@ static void Main(string[] args) var envModSearchPaths = Environment.GetEnvironmentVariable("MOD_SEARCH_PATHS"); var modSearchPaths = !string.IsNullOrWhiteSpace(envModSearchPaths) ? FieldLoader.GetValue("MOD_SEARCH_PATHS", envModSearchPaths) : - new[] { Path.Combine(Platform.GameDir, "mods") }; + new[] { Path.Combine(Platform.EngineDir, "mods") }; if (args.Length == 0) { diff --git a/lua/scriptwrapper.lua b/lua/scriptwrapper.lua index c724643c53bf..55474805258a 100644 --- a/lua/scriptwrapper.lua +++ b/lua/scriptwrapper.lua @@ -9,7 +9,7 @@ environment = {} -- Reset package path -package.path = GameDir .. "/lua/?.lua" +package.path = EngineDir .. "/lua/?.lua" -- Note: sandbox has been customized to remove math.random local sandbox = require('sandbox')