From 0404b94f86be8e7e2a24a42956a8ff817ced1531 Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 21 Feb 2022 18:11:35 -0800 Subject: [PATCH] Add support for BDSP 1.2.0 save files --- PKHeX.Core/Saves/SAV8BS.cs | 10 ++++++++-- PKHeX.Core/Saves/Substructures/Gen8/BS/Gem8Version.cs | 7 +++++++ PKHeX.Core/Saves/Util/SaveUtil.cs | 5 +++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/PKHeX.Core/Saves/SAV8BS.cs b/PKHeX.Core/Saves/SAV8BS.cs index 6236723f9..a59628f7f 100644 --- a/PKHeX.Core/Saves/SAV8BS.cs +++ b/PKHeX.Core/Saves/SAV8BS.cs @@ -77,10 +77,15 @@ namespace PKHeX.Core // MT_DATA mtData; -- 0x400 bytes // DENDOU_SAVE_ADD -- language tracking of members (hall of fame?); ADD_POKE_MEMBER[30], ADD_POKE[6] - Initialize(); + // v1.2 additions + // ReBuffnameData reBuffNameDat -- RE_DENDOU_RECORD[], RE_DENDOU_RECORD is an RE_DENDOU_POKEMON_DATA_INSIDE[] with nicknames + // PLAYREPORT_DATA playReportData sizeof(0xF8) + // PLAYREPORT_DATA playReportDataRef sizeof(0xF8) + + Initialize(); } - public SAV8BS() : this(new byte[SaveUtil.SIZE_G8BDSP_1], false) => SaveRevision = (int)Gem8Version.V1_1; + public SAV8BS() : this(new byte[SaveUtil.SIZE_G8BDSP_2], false) => SaveRevision = (int)Gem8Version.V1_2; private void Initialize() { @@ -118,6 +123,7 @@ namespace PKHeX.Core public override int MaxAbilityID => Legal.MaxAbilityID_8b; public bool HasFirstSaveFileExpansion => (Gem8Version)SaveRevision >= Gem8Version.V1_1; + public bool HasSecondSaveFileExpansion => (Gem8Version)SaveRevision >= Gem8Version.V1_2; public int SaveRevision { diff --git a/PKHeX.Core/Saves/Substructures/Gen8/BS/Gem8Version.cs b/PKHeX.Core/Saves/Substructures/Gen8/BS/Gem8Version.cs index f2f43cb27..f6be054bf 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/BS/Gem8Version.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/BS/Gem8Version.cs @@ -19,6 +19,12 @@ namespace PKHeX.Core /// /// V1_1 = 0x2C, // 44 + + /// + /// February patch. + /// + /// + V1_2 = 0x32, // 50 } public static class Gem8VersionExtensions @@ -31,6 +37,7 @@ namespace PKHeX.Core { V1_0 => "-1.0.0", // Launch Revision V1_1 => "-1.1.0", // 1.1.0 + V1_2 => "-1.2.0", // 1.2.0 _ => throw new ArgumentOutOfRangeException(nameof(version)), }; } diff --git a/PKHeX.Core/Saves/Util/SaveUtil.cs b/PKHeX.Core/Saves/Util/SaveUtil.cs index eab42634b..87e32db07 100644 --- a/PKHeX.Core/Saves/Util/SaveUtil.cs +++ b/PKHeX.Core/Saves/Util/SaveUtil.cs @@ -19,6 +19,7 @@ namespace PKHeX.Core public const int SIZE_G8BDSP = 0xE9828; public const int SIZE_G8BDSP_1 = 0xEDC20; + public const int SIZE_G8BDSP_2 = 0xEED8C; public const int SIZE_G8SWSH = 0x1716B3; // 1.0 public const int SIZE_G8SWSH_1 = 0x17195E; // 1.0 -> 1.1 @@ -99,7 +100,7 @@ namespace PKHeX.Core private static readonly HashSet Sizes = new(SizesGen2.Concat(SizesSWSH)) { - SIZE_G8LA, SIZE_G8BDSP, SIZE_G8BDSP_1, + SIZE_G8LA, SIZE_G8BDSP, SIZE_G8BDSP_1, SIZE_G8BDSP_2, // SizesSWSH covers gen8 sizes since there's so many SIZE_G7SM, SIZE_G7USUM, SIZE_G7GG, SIZE_G6XY, SIZE_G6ORAS, SIZE_G6ORASDEMO, @@ -501,7 +502,7 @@ namespace PKHeX.Core private static GameVersion GetIsG8SAV_BDSP(ReadOnlySpan data) { - if (data.Length is not SIZE_G8BDSP && data.Length is not SIZE_G8BDSP_1) + if (data.Length is not (SIZE_G8BDSP or SIZE_G8BDSP_1 or SIZE_G8BDSP_2)) return Invalid; return BDSP;