From 888915b53b86f1b370e5914679e71b9547e12e87 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 20 Nov 2020 17:44:53 +0000 Subject: [PATCH] Use Platform.GameDir explicitly in hardcoded paths. --- OpenRA.Game/Game.cs | 2 +- OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs | 2 +- OpenRA.Mods.Common/UtilityCommands/DumpSequenceSheetsCommand.cs | 2 +- OpenRA.Mods.Common/UtilityCommands/ExtractMapRules.cs | 2 +- OpenRA.Mods.Common/UtilityCommands/GetMapHashCommand.cs | 2 +- OpenRA.Mods.Common/UtilityCommands/RefreshMapCommand.cs | 2 +- OpenRA.Mods.Common/UtilityCommands/ResizeMapCommand.cs | 2 +- OpenRA.Mods.Common/UtilityCommands/UpdateMapCommand.cs | 2 +- OpenRA.Mods.Common/UtilityCommands/Utilities.cs | 2 +- OpenRA.Server/Program.cs | 2 +- OpenRA.Utility/Program.cs | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index dcbe764045..131649c5bd 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -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(".", "mods") }; + new[] { Path.Combine(Platform.GameDir, "mods") }; Mods = new InstalledMods(modSearchPaths, explicitModPaths); Console.WriteLine("Internal mods:"); diff --git a/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs index 6be1151799..6798130a06 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(".").OpenPackage(args[1], modData.ModFiles))); + maps.Add(new Map(modData, new Folder(Platform.GameDir).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 ac2af3a4a2..23f2f7379c 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(".").OpenPackage(args[2], modData.ModFiles); + var mapPackage = new Folder(Platform.GameDir).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 74f89a96e7..720bff8f5e 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(".").OpenPackage(args[1], modData.ModFiles)); + var map = new Map(modData, new Folder(Platform.GameDir).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 cf67fc4484..820b38427b 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(".").OpenPackage(args[1], utility.ModData.ModFiles)) + using (var package = new Folder(Platform.GameDir).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 98525817c3..a784e208b7 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(".").OpenPackage(args[1], modData.ModFiles)) + using (var package = new Folder(Platform.GameDir).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 49bc8ec7c8..1846f3d6ac 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(".").OpenPackage(args[1], modData.ModFiles)); + map = new Map(modData, new Folder(Platform.GameDir).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 25db7eee15..8a3c45b017 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(".").OpenPackage(args[1], modData.ModFiles) as IReadWritePackage; + var package = new Folder(Platform.GameDir).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 310e85f041..1d78151606 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(".").OpenPackage(mapPath, modData.ModFiles)); + map = new Map(modData, new Folder(Platform.GameDir).OpenPackage(mapPath, modData.ModFiles)); } catch (InvalidDataException ex) { diff --git a/OpenRA.Server/Program.cs b/OpenRA.Server/Program.cs index 07445e9718..b2840761df 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(".", "mods") }; + new[] { Path.Combine(Platform.GameDir, "mods") }; var mods = new InstalledMods(modSearchPaths, explicitModPaths); diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index e48fa69cc6..40cdd191ea 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(".", "mods") }; + new[] { Path.Combine(Platform.GameDir, "mods") }; if (args.Length == 0) {