From 3b344bd5c3d0b064bedfbb03eedf3dc6b9172f04 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 16 Mar 2021 18:49:27 -0700 Subject: [PATCH] Add batrev as a blank sav option via code --- PKHeX.Core/Saves/SAV4BR.cs | 8 ++++++-- PKHeX.Core/Saves/Util/SaveUtil.cs | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/PKHeX.Core/Saves/SAV4BR.cs b/PKHeX.Core/Saves/SAV4BR.cs index 6a02ac20b..15584aa21 100644 --- a/PKHeX.Core/Saves/SAV4BR.cs +++ b/PKHeX.Core/Saves/SAV4BR.cs @@ -31,9 +31,12 @@ private void InitializeData(byte[] data) 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)) + var first = BigEndian.ToUInt32(Data, 0x00004C); + var second = BigEndian.ToUInt32(Data, 0x1C004C); + SaveCount = Math.Max(second, first); + if (second > first) { + // swap halves byte[] tempData = new byte[0x1C0000]; Array.Copy(Data, 0, tempData, 0, 0x1C0000); Array.Copy(Data, 0x1C0000, Data, 0, 0x1C0000); @@ -57,6 +60,7 @@ private void InitializeData(byte[] data) CurrentSlot = _currentSlot; } + /// Amount of times the primary save has been saved private uint SaveCount; protected override byte[] GetFinalData() diff --git a/PKHeX.Core/Saves/Util/SaveUtil.cs b/PKHeX.Core/Saves/Util/SaveUtil.cs index 11e0738a8..9c04f02bb 100644 --- a/PKHeX.Core/Saves/Util/SaveUtil.cs +++ b/PKHeX.Core/Saves/Util/SaveUtil.cs @@ -727,6 +727,7 @@ public static SaveFile GetBlankSAV(GameVersion game, string trainerName, Languag D or P or DP => new SAV4DP(), Pt or DPPt => new SAV4Pt(), HG or SS or HGSS => new SAV4HGSS(), + BATREV => new SAV4BR(), B or W or BW => new SAV5BW(), B2 or W2 or B2W2 => new SAV5B2W2(),