From c229d5cef4c223b201daff13c3bb8c97665dff85 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 23 Mar 2018 23:06:51 -0700 Subject: [PATCH] Add RS & FRLG mail offsets was only emerald prior Thansk @Bl4ckSh4rk ! https://projectpokemon.org/home/forums/topic/44433-bug-rubysapphire-mailbox/?do=findComment&comment=228885 --- PKHeX.Core/Saves/Substructures/Mail/Mail3.cs | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/PKHeX.Core/Saves/Substructures/Mail/Mail3.cs b/PKHeX.Core/Saves/Substructures/Mail/Mail3.cs index 863c8fde5..185990d00 100644 --- a/PKHeX.Core/Saves/Substructures/Mail/Mail3.cs +++ b/PKHeX.Core/Saves/Substructures/Mail/Mail3.cs @@ -9,9 +9,30 @@ public class Mail3 : Mail public Mail3(SAV3 sav, int index) { - DataOffset = index * SIZE + sav.GetBlockOffset(3) + 0xCE0; + GetMailBlockOffset(sav.Version, index, out int block, out int offset); + DataOffset = index * SIZE + sav.GetBlockOffset(block) + offset; Data = sav.GetData(DataOffset, SIZE); } + + private static void GetMailBlockOffset(GameVersion game, int index, out int block, out int offset) + { + block = 3; + if (game == GameVersion.E) + offset = 0xCE0; + else if (GameVersion.RS.Contains(game)) + offset = 0xC4C; + else // FRLG + { + if (index >= 12) + { + block = 4; + offset = 0; + } + else + offset = 0xDD0; + } + } + public Mail3() { Data = new byte[SIZE];