Rework IReadWritePackage interface.

This commit is contained in:
Paul Chote
2016-02-24 22:28:47 +00:00
parent bee3eb2c0a
commit 617113fa86
10 changed files with 68 additions and 97 deletions

View File

@@ -14,6 +14,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using OpenRA.FileSystem;
using OpenRA.Graphics;
using OpenRA.Mods.Common.FileFormats;
using OpenRA.Mods.Common.Traits;
@@ -95,7 +96,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
Map.FixOpenAreas(Rules);
var dest = Path.GetFileNameWithoutExtension(args[1]) + ".oramap";
var package = modData.ModFiles.CreatePackage(dest);
var package = new ZipFile(modData.ModFiles, dest, true);
Map.Save(package);
Console.WriteLine(dest + " saved.");
}

View File

@@ -785,17 +785,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
yaml.Nodes.First(n => n.Key == "MapFormat").Value = new MiniYaml(Map.SupportedMapFormat.ToString());
var entries = new Dictionary<string, byte[]>();
entries.Add("map.yaml", Encoding.UTF8.GetBytes(yaml.Nodes.WriteToString()));
foreach (var file in package.Contents)
{
if (file == "map.yaml")
continue;
entries.Add(file, package.GetStream(file).ReadAllBytes());
}
package.Write(entries);
package.Update("map.yaml", Encoding.UTF8.GetBytes(yaml.Nodes.WriteToString()));
}
}
}