using System; using System.IO; using System.Linq; using BinXmlConverter.Classes; static int FirstDiff(byte[] a, byte[] b) { int min = Math.Min(a.Length, b.Length); for (int i = 0; i < min; i++) if (a[i] != b[i]) return i; return a.Length == b.Length ? -1 : min; } string basePath = @"C:\GDMO\BDMO\DProject_vs2022\Tool\BinXmlConverter2\bin\Debug\net8.0-windows"; var weatherBin = Path.Combine(basePath, "DATA", "Weather.bin"); var weatherXml = Path.Combine(basePath, "XML", "Weather", "Weather.xml"); var weatherOut = Path.Combine(basePath, "BIN", "Weather.bin"); var weatherGroups = WeatherPackage.ReadFromBinary(weatherBin); WeatherPackage.ExportToXml(weatherXml, weatherGroups); var weatherImported = WeatherPackage.ImportFromXml(weatherXml); WeatherPackage.WriteToBinary(weatherOut, weatherImported); Console.WriteLine($"WeatherCounts=groups:{weatherGroups.Length},weathers:{weatherGroups.Sum(g=>g.Weathers.Length)},elements:{weatherGroups.Sum(g=>g.Weathers.Sum(w=>w.Elements.Length))}"); Console.WriteLine($"WeatherRoundtrip=len:{new FileInfo(weatherBin).Length}/{new FileInfo(weatherOut).Length},firstDiff:{FirstDiff(File.ReadAllBytes(weatherBin), File.ReadAllBytes(weatherOut))}"); var worldBin = Path.Combine(basePath, "DATA", "WorldMap.bin"); var worldXml = Path.Combine(basePath, "XML", "WorldMap", "WorldMap.xml"); var areaXml = Path.Combine(basePath, "XML", "WorldMap", "AreaMap.xml"); var worldOut = Path.Combine(basePath, "BIN", "WorldMap.bin"); var world = WorldMapPackage.ReadFromBinary(worldBin); WorldMapPackage.ExportToXml(worldXml, areaXml, world.Worlds, world.Areas); var worldImported = WorldMapPackage.ImportFromXml(worldXml, areaXml); WorldMapPackage.WriteToBinary(worldOut, worldImported.Worlds, worldImported.Areas); Console.WriteLine($"WorldMapCounts=worlds:{world.Worlds.Length},areas:{world.Areas.Length}"); Console.WriteLine($"WorldMapRoundtrip=len:{new FileInfo(worldBin).Length}/{new FileInfo(worldOut).Length},firstDiff:{FirstDiff(File.ReadAllBytes(worldBin), File.ReadAllBytes(worldOut))}");