Skip to content

Commit

Permalink
Rename Platform.GameDir to Platform.EngineDir.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote authored and teinarss committed Nov 24, 2020
1 parent 72f1f06 commit 1cc1f93
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions OpenRA.Game/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -354,7 +354,7 @@ static void Initialize(Arguments args)
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:");
Expand Down
8 changes: 4 additions & 4 deletions OpenRA.Game/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -169,7 +169,7 @@ public static void OverrideSupportDir(string path)
userSupportPath = path;
}

public static string GameDir
public static string EngineDir
{
get
{
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Game/Scripting/ScriptContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/UtilityCommands/ExtractMapRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/UtilityCommands/GetMapHashCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/UtilityCommands/RefreshMapCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/UtilityCommands/ResizeMapCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/UtilityCommands/UpdateMapCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.Common/UtilityCommands/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Mods.Common/Widgets/Logic/AssetBrowserLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Platforms.Default/Shader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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" :
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void Main(string[] args)
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);

Expand Down
10 changes: 5 additions & 5 deletions OpenRA.Test/OpenRA.Game/PlatformTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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"));
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Utility/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static void Main(string[] args)
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)
{
Expand Down
2 changes: 1 addition & 1 deletion lua/scriptwrapper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 1cc1f93

Please sign in to comment.