コード例 #1
0
ファイル: SAV4BR.cs プロジェクト: wbsr9876/PKHeX
        public SAV4BR(byte[] data = null)
        {
            Data       = data == null ? new byte[SaveUtil.SIZE_G4BR] : (byte[])data.Clone();
            BAK        = (byte[])Data.Clone();
            Exportable = !Data.SequenceEqual(new byte[Data.Length]);

            if (SaveUtil.getIsG4BRSAV(Data) != GameVersion.BATREV)
            {
                return;
            }

            Data = DecryptPBRSaveData(data);

            // Detect active save
            SaveCount = Math.Max(BigEndian.ToUInt32(Data, 0x1C004C), BigEndian.ToUInt32(Data, 0x4C));
            if (BigEndian.ToUInt32(Data, 0x1C004C) > BigEndian.ToUInt32(Data, 0x4C))
            {
                byte[] tempData = new byte[0x1C0000];
                Array.Copy(Data, 0, tempData, 0, 0x1C0000);
                Array.Copy(Data, 0x1C0000, Data, 0, 0x1C0000);
                tempData.CopyTo(Data, 0x1C0000);
            }

            SaveSlots = new List <int>();
            SaveNames = new string[SAVE_COUNT];
            for (int i = 0; i < SAVE_COUNT; i++)
            {
                if (BitConverter.ToUInt16(Data, 0x390 + 0x6FF00 * i) != 0)
                {
                    SaveSlots.Add(i);
                    SaveNames[i] = Encoding.BigEndianUnicode.GetString(Data, 0x390 + 0x6FF00 * i, 0x10);
                }
            }

            CurrentSlot = SaveSlots.First();

            Personal  = PersonalTable.DP;
            HeldItems = Legal.HeldItems_DP;

            if (!Exportable)
            {
                resetBoxes();
            }
        }