Ejemplo n.º 1
0
Archivo: SAV6.cs Proyecto: kwsch/PKHeX
        private void getBlockInfo()
        {
            BlockInfoOffset = Data.Length - 0x200 + 0x10;
            if (BitConverter.ToUInt32(Data, BlockInfoOffset) != SaveUtil.BEEF)
                BlockInfoOffset -= 0x200; // No savegames have more than 0x3D blocks, maybe in the future?
            int count = (Data.Length - BlockInfoOffset - 0x8) / 8;
            BlockInfoOffset += 4;

            Blocks = new BlockInfo[count];
            int CurrentPosition = 0;
            for (int i = 0; i < Blocks.Length; i++)
            {
                Blocks[i] = new BlockInfo
                {
                    Offset = CurrentPosition,
                    Length = BitConverter.ToInt32(Data, BlockInfoOffset + 0 + 8 * i),
                    ID = BitConverter.ToUInt16(Data, BlockInfoOffset + 4 + 8 * i),
                    Checksum = BitConverter.ToUInt16(Data, BlockInfoOffset + 6 + 8 * i)
                };

                // Expand out to nearest 0x200
                CurrentPosition += Blocks[i].Length % 0x200 == 0 ? Blocks[i].Length : 0x200 - Blocks[i].Length % 0x200 + Blocks[i].Length;

                if ((Blocks[i].ID != 0) || i == 0) continue;
                count = i;
                break;
            }
            // Fix Final Array Lengths
            Array.Resize(ref Blocks, count);
        }
Ejemplo n.º 2
0
 public static string GetChecksumInfo(this IReadOnlyList <BlockInfo> blocks, byte[] data) => BlockInfo.GetChecksumInfo(blocks, data);
Ejemplo n.º 3
0
 public static void SetChecksums(this IEnumerable <BlockInfo> blocks, byte[] data) => BlockInfo.SetChecksums(blocks, data);
Ejemplo n.º 4
0
 public static bool GetChecksumsValid(this IEnumerable <BlockInfo> blocks, byte[] data) => BlockInfo.GetChecksumsValid(blocks, data);