From face69d4693d7a92a912956bcc346b6c835dce63 Mon Sep 17 00:00:00 2001 From: Kermalis <29823718+Kermalis@users.noreply.github.com> Date: Wed, 18 Mar 2020 03:25:02 -0400 Subject: [PATCH] Fix Emerald decorations (#2788) --- PKHeX.Core/Saves/SAV3.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/PKHeX.Core/Saves/SAV3.cs b/PKHeX.Core/Saves/SAV3.cs index bc8ab10e1..9c74ed58e 100644 --- a/PKHeX.Core/Saves/SAV3.cs +++ b/PKHeX.Core/Saves/SAV3.cs @@ -156,6 +156,7 @@ private void Initialize() OFS_PouchBerry = BlockOfs[1] + 0x0740; EventFlag = BlockOfs[2] + 0x2A0; EventConst = EventFlag + (EventFlagMax / 8); + OFS_Decorations = BlockOfs[3] + 0x7A0; DaycareOffset = BlockOfs[4] + 0x11C; break; case GameVersion.E: @@ -167,6 +168,7 @@ private void Initialize() OFS_PouchBerry = BlockOfs[1] + 0x0790; EventFlag = BlockOfs[2] + 0x2F0; EventConst = EventFlag + (EventFlagMax / 8); + OFS_Decorations = BlockOfs[3] + 0x834; DaycareOffset = BlockOfs[4] + 0x1B0; break; case GameVersion.FRLG: @@ -618,7 +620,7 @@ public uint BerryPowder private static ushort[] LegalTMHMs => Legal.Pouch_TMHM_RS; private static ushort[] LegalBerries => Legal.Pouch_Berries_RS; - private int OFS_PCItem, OFS_PouchHeldItem, OFS_PouchKeyItem, OFS_PouchBalls, OFS_PouchTMHM, OFS_PouchBerry; + private int OFS_PCItem, OFS_PouchHeldItem, OFS_PouchKeyItem, OFS_PouchBalls, OFS_PouchTMHM, OFS_PouchBerry, OFS_Decorations; public override InventoryPouch[] Inventory { @@ -1028,8 +1030,18 @@ public bool ResetPersonal(GameVersion g) public DecorationInventory3 Decorations { - get => Data.Slice(GetBlockOffset(3) + 0x7A0, DecorationInventory3.SIZE).ToStructure(); - set => SetData(value.ToBytes(), GetBlockOffset(3) + 0x7A0); + get + { + if (Version == GameVersion.FRLG) + throw new Exception(); + return Data.Slice(OFS_Decorations, DecorationInventory3.SIZE).ToStructure(); + } + set + { + if (Version == GameVersion.FRLG) + throw new Exception(); + SetData(value.ToBytes(), OFS_Decorations); + } } } }