diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index be717453f5..c34181cb09 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -62,7 +62,7 @@ namespace OpenRA.Editor Game.modData = new ModData(currentMod); // load the map - var map = new Map(new Folder(mapname)); + var map = new Map(new Folder(mapname, 0)); // upgrade maps that have no player definitions. editor doesnt care, // but this breaks the game pretty badly. diff --git a/OpenRA.Editor/MapSelect.cs b/OpenRA.Editor/MapSelect.cs index c0284b3dda..7d024c9953 100644 --- a/OpenRA.Editor/MapSelect.cs +++ b/OpenRA.Editor/MapSelect.cs @@ -39,7 +39,7 @@ namespace OpenRA.Editor if (MapList.SelectedItems.Count == 1) { txtNew.Text = MapList.SelectedItems[0].Text; - var map = new Map(new Folder(Path.Combine(MapFolderPath, MapList.SelectedItems[0].Text))); + var map = new Map(new Folder(Path.Combine(MapFolderPath, MapList.SelectedItems[0].Text), 0)); txtTitle.Text = map.Title; txtAuthor.Text = map.Author; txtTheater.Text = map.Theater; diff --git a/OpenRA.FileFormats/CompressedPackage.cs b/OpenRA.FileFormats/CompressedPackage.cs index fa04960878..0dbba955dc 100644 --- a/OpenRA.FileFormats/CompressedPackage.cs +++ b/OpenRA.FileFormats/CompressedPackage.cs @@ -21,9 +21,11 @@ namespace OpenRA.FileFormats readonly uint[] hashes; readonly Stream s; readonly ZipPackage pkg; + int priority; - public CompressedPackage(string filename) + public CompressedPackage(string filename, int priority) { + this.priority = priority; s = FileSystem.Open(filename); pkg = (ZipPackage)ZipPackage.Open(s, FileMode.Open); hashes = pkg.GetParts() @@ -45,7 +47,7 @@ namespace OpenRA.FileFormats public int Priority { - get { return 1; } + get { return 500 + priority; } } } } diff --git a/OpenRA.FileFormats/FileSystem.cs b/OpenRA.FileFormats/FileSystem.cs index 5ab7e8d5f6..e3767c2a16 100644 --- a/OpenRA.FileFormats/FileSystem.cs +++ b/OpenRA.FileFormats/FileSystem.cs @@ -34,14 +34,16 @@ namespace OpenRA.FileFormats } } + static int order = 0; + static IFolder OpenPackage(string filename) { if (filename.EndsWith(".mix")) - return new Package(filename); + return new Package(filename, order++); else if (filename.EndsWith(".zip")) - return new CompressedPackage(filename); + return new CompressedPackage(filename, order++); else - return new Folder(filename); + return new Folder(filename, order++); } public static void Mount(string name) @@ -76,7 +78,7 @@ namespace OpenRA.FileFormats { var folder = index[PackageEntry.HashFilename(filename)] .Where(x => x.Exists(filename)) - .OrderByDescending(x => x.Priority) + .OrderBy(x => x.Priority) .FirstOrDefault(); if (folder != null) diff --git a/OpenRA.FileFormats/Folder.cs b/OpenRA.FileFormats/Folder.cs index 9666d86808..09a83da257 100644 --- a/OpenRA.FileFormats/Folder.cs +++ b/OpenRA.FileFormats/Folder.cs @@ -17,7 +17,9 @@ namespace OpenRA.FileFormats { readonly string path; - public Folder(string path) { this.path = path; } + int priority; + + public Folder(string path, int priority) { this.path = path; this.priority = priority; } public Stream GetContent(string filename) { @@ -39,7 +41,7 @@ namespace OpenRA.FileFormats public int Priority { - get { return 100; } + get { return priority; } } } } diff --git a/OpenRA.FileFormats/Package.cs b/OpenRA.FileFormats/Package.cs index 3ff551d4b3..ef70195f37 100644 --- a/OpenRA.FileFormats/Package.cs +++ b/OpenRA.FileFormats/Package.cs @@ -29,9 +29,11 @@ namespace OpenRA.FileFormats readonly bool isRmix, isEncrypted; readonly long dataStart; readonly Stream s; + int priority; - public Package(string filename) + public Package(string filename, int priority) { + this.priority = priority; s = FileSystem.Open(filename); BinaryReader reader = new BinaryReader(s); @@ -154,7 +156,7 @@ namespace OpenRA.FileFormats public int Priority { - get { return 0; } + get { return 1000 + priority; } } } diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index 4fccdaf239..592bdf979a 100755 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -184,7 +184,7 @@ namespace OpenRA public void Save(string filepath) { // Todo: save to a zip file in the support dir by default - Package = new Folder(filepath); + Package = new Folder(filepath, 0); MapFormat = 3; var root = new List(); diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index 277fbf5833..7942b77cab 100755 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -50,7 +50,7 @@ namespace OpenRA .Where(p => Directory.Exists(p)) .SelectMany(p => Directory.GetDirectories(p)).ToList(); - return paths.Select(p => new MapStub(new Folder(p))).ToDictionary(m => m.Uid); + return paths.Select(p => new MapStub(new Folder(p, 0))).ToDictionary(m => m.Uid); } string cachedTheatre = null;