diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 131649c5bd..bd2d40d59a 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -285,7 +285,7 @@ namespace OpenRA // 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 @@ namespace OpenRA 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 @@ namespace OpenRA 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 f5504ee4db..a8ed276f39 100644 --- a/OpenRA.Game/Platform.cs +++ b/OpenRA.Game/Platform.cs @@ -136,7 +136,7 @@ namespace OpenRA } // 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 @@ namespace OpenRA userSupportPath = path; } - public static string GameDir + public static string EngineDir { get { @@ -194,10 +194,10 @@ namespace OpenRA // 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 9457e490e1..5d9ba4820b 100644 --- a/OpenRA.Game/Scripting/ScriptContext.cs +++ b/OpenRA.Game/Scripting/ScriptContext.cs @@ -161,8 +161,8 @@ namespace OpenRA.Scripting .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 55858057df..65e788e1b8 100644 --- a/OpenRA.Mods.Common/UtilityCommands/CheckRuntimeAssembliesCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/CheckRuntimeAssembliesCommand.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.UtilityCommands .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 6798130a06..495e24fa4d 100644 --- a/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs +++ b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs @@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.UtilityCommands 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 23f2f7379c..b62d70d2b7 100644 --- a/OpenRA.Mods.Common/UtilityCommands/DumpSequenceSheetsCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/DumpSequenceSheetsCommand.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.UtilityCommands 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 720bff8f5e..8493c30be8 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ExtractMapRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ExtractMapRules.cs @@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.UtilityCommands { 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 820b38427b..b42e8477a7 100644 --- a/OpenRA.Mods.Common/UtilityCommands/GetMapHashCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/GetMapHashCommand.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.UtilityCommands [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 a784e208b7..23f6bc9bbe 100644 --- a/OpenRA.Mods.Common/UtilityCommands/RefreshMapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/RefreshMapCommand.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.UtilityCommands // 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 1846f3d6ac..8f8aed24c4 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ResizeMapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ResizeMapCommand.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.UtilityCommands 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 8a3c45b017..ddc828e330 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpdateMapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpdateMapCommand.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.UtilityCommands 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 1d78151606..c8f2cc3ed1 100644 --- a/OpenRA.Mods.Common/UtilityCommands/Utilities.cs +++ b/OpenRA.Mods.Common/UtilityCommands/Utilities.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.UtilityCommands { 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 df8eb82bb9..8f9295d111 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs @@ -447,8 +447,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic 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 0062434af5..0326db1829 100644 --- a/OpenRA.Platforms.Default/Shader.cs +++ b/OpenRA.Platforms.Default/Shader.cs @@ -32,7 +32,7 @@ namespace OpenRA.Platforms.Default 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 b2840761df..2378972d0f 100644 --- a/OpenRA.Server/Program.cs +++ b/OpenRA.Server/Program.cs @@ -54,7 +54,7 @@ namespace OpenRA.Server 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 4f583b1d5d..170b1cf14a 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 @@ namespace OpenRA.Test 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 40cdd191ea..96a2bd0ea4 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -48,7 +48,7 @@ namespace OpenRA 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 c724643c53..5547480525 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')