Exemplo n.º 1
0
        public SAV4BR(byte[] data = null)
        {
            Data       = data ?? new byte[SaveUtil.SIZE_G4BR];
            BAK        = (byte[])Data.Clone();
            Exportable = !Data.All(z => z == 0);

            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[0];

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

            if (!Exportable)
            {
                ClearBoxes();
            }
        }
Exemplo n.º 2
0
        public SAV4BR(byte[] data = null)
        {
            Data       = data ?? new byte[SaveUtil.SIZE_G4BR];
            BAK        = (byte[])Data.Clone();
            Exportable = !IsRangeEmpty(0, 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);
            }

            for (int i = 0; i < SAVE_COUNT; i++)
            {
                if (!IsOTNamePresent(i))
                {
                    continue;
                }
                SaveSlots.Add(i);
                SaveNames.Add(GetOTName(i).Trim());
            }

            CurrentSlot = SaveSlots[0];

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

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