public void SerializeCleanExbin() { IEnumerable <string> maps = Directory.EnumerateFiles(pathToYsiExtract, "MapData*.exbin"); int levelCount = 0; foreach (string map in maps) { NintendoLand.DataFormats.MapData mapData = NintendoLand.DataFormats.MapData.Load(map); List <byte> serializedData = new List <byte>(); mapData.SerializeExbin(ref serializedData, 16 + 4 + 18 + // header TileTypes.RotatingObjectHeader.BYTES_PER_CONTAINER + // rotating objects header (NintendoLand.DataFormats.MapData.ROWS_TOTAL * NintendoLand.DataFormats.MapData.COLUMNS_TOTAL * (1 + NintendoLand.DataFormats.MapData.CELL_TILE_PADDING)) // payload of actual cells ); // magic number is the max length of a default MapData.exbin-file #if DEBUG // Write inspectable files during debug builds to allow diffing of generated output and regular files in external tools File.WriteAllText(map + ".gen", string.Empty); File.WriteAllBytes(map + ".gen", serializedData.ToArray()); #endif CollectionAssert.AreEqual( File.ReadAllBytes(map), serializedData ); levelCount++; } Assert.AreEqual(61, levelCount, "Default game files require exactly 50 levels + 10 used levels + tutorial level"); }
public void SerializeDirtyExbin() { IEnumerable <string> maps = Directory.EnumerateFiles(pathToYsiExtract, "MapData*.exbin"); foreach (string map in maps) { NintendoLand.DataFormats.MapData mapData = NintendoLand.DataFormats.MapData.Load(map); List <byte> serializedData = new List <byte>(); mapData.SetItem(0, 0, TileTypes.Registrar.GetTypeByMemoryIdentifier('G')); mapData.SerializeExbin(ref serializedData, 16 + 4 + 18 + // header TileTypes.RotatingObjectHeader.BYTES_PER_CONTAINER + // rotating objects header (NintendoLand.DataFormats.MapData.ROWS_TOTAL * NintendoLand.DataFormats.MapData.COLUMNS_TOTAL * (1 + NintendoLand.DataFormats.MapData.CELL_TILE_PADDING)) // payload of actual cells ); // magic number is the max length of a default MapData.exbin-file CollectionAssert.AreNotEqual( File.ReadAllBytes(map), serializedData ); } }