diff --git a/OpenRA.FileFormats/Filesystem/ZipFile.cs b/OpenRA.FileFormats/Filesystem/ZipFile.cs index d7830ecd40..0cd43ecbee 100644 --- a/OpenRA.FileFormats/Filesystem/ZipFile.cs +++ b/OpenRA.FileFormats/Filesystem/ZipFile.cs @@ -46,7 +46,15 @@ namespace OpenRA.FileFormats public Stream GetContent(string filename) { - return pkg.GetInputStream(pkg.GetEntry(filename)); + var ms = new MemoryStream(); + var z = pkg.GetInputStream(pkg.GetEntry(filename)); + int bufSize = 2048; + byte[] buf = new byte[bufSize]; + while ((bufSize = z.Read(buf, 0, buf.Length)) > 0) + ms.Write(buf, 0, bufSize); + + ms.Seek(0, SeekOrigin.Begin); + return ms; } public IEnumerable AllFileHashes() diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 24368d1824..aabc0c044b 100755 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -251,9 +251,13 @@ namespace OpenRA static string ChooseShellmap() { - return modData.AvailableMaps - .Where(m => m.Value.UseAsShellmap) - .Random(CosmeticRandom).Key; + var shellmaps = modData.AvailableMaps + .Where(m => m.Value.UseAsShellmap); + + if (shellmaps.Count() == 0) + throw new InvalidDataException("No valid shellmaps available"); + + return shellmaps.Random(CosmeticRandom).Key; } static bool quit; diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index 67dfba2d20..55d9473932 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -195,11 +195,12 @@ namespace OpenRA public void Save(string toPath) { + Console.WriteLine("Saving map to path {0}",toPath); // Todo: save to a zip file in the support dir by default MapFormat = 3; var root = new List(); - foreach (var field in new string[] {"Selectable", "MapFormat", "Title", "Description", "Author", "PlayerCount", "Tileset", "MapSize", "TopLeft", "BottomRight"}) + foreach (var field in new string[] {"Selectable", "MapFormat", "Title", "Description", "Author", "PlayerCount", "Tileset", "MapSize", "TopLeft", "BottomRight", "UseAsShellmap"}) { FieldInfo f = this.GetType().GetField(field); if (f.GetValue(this) == null) continue; diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index 88a0d01e74..1a3c9a0d87 100755 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -62,8 +62,16 @@ namespace OpenRA { var paths = mods.SelectMany(p => FindMapsIn("mods/" + p + "/maps/")); - return paths.Select(p => new MapStub(p)) - .ToDictionary(m => m.Uid); + Dictionary ret = new Dictionary(); + foreach (var path in paths) + { + var map = new MapStub(path); + if (ret.ContainsKey(map.Uid)) + System.Console.WriteLine("Ignoring duplicate map: {0}", path); + else + ret.Add(map.Uid, map); + } + return ret; } string cachedTileset = null;