Rename Platform.GameDir to Platform.EngineDir.
This commit is contained in:
@@ -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<string[]>("Engine.ModsPath", modSearchArg) :
|
||||
new[] { Path.Combine(Platform.GameDir, "mods") };
|
||||
new[] { Path.Combine(Platform.EngineDir, "mods") };
|
||||
|
||||
Mods = new InstalledMods(modSearchPaths, explicitModPaths);
|
||||
Console.WriteLine("Internal mods:");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<string>();
|
||||
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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" :
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Server
|
||||
var envModSearchPaths = Environment.GetEnvironmentVariable("MOD_SEARCH_PATHS");
|
||||
var modSearchPaths = !string.IsNullOrWhiteSpace(envModSearchPaths) ?
|
||||
FieldLoader.GetValue<string[]>("MOD_SEARCH_PATHS", envModSearchPaths) :
|
||||
new[] { Path.Combine(Platform.GameDir, "mods") };
|
||||
new[] { Path.Combine(Platform.EngineDir, "mods") };
|
||||
|
||||
var mods = new InstalledMods(modSearchPaths, explicitModPaths);
|
||||
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA
|
||||
var envModSearchPaths = Environment.GetEnvironmentVariable("MOD_SEARCH_PATHS");
|
||||
var modSearchPaths = !string.IsNullOrWhiteSpace(envModSearchPaths) ?
|
||||
FieldLoader.GetValue<string[]>("MOD_SEARCH_PATHS", envModSearchPaths) :
|
||||
new[] { Path.Combine(Platform.GameDir, "mods") };
|
||||
new[] { Path.Combine(Platform.EngineDir, "mods") };
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user