From 59e409bbd7de3fc4dbe6abb87cbaf8e65c4037c6 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 17 Dec 2023 08:57:56 -0800 Subject: [PATCH] Update pk3.HeldMailID when not holding mail https://projectpokemon.org/home/forums/topic/64361-bugs-when-editing-g3-japanese-version-pokemon/?do=findComment&comment=287038 --- PKHeX.Core/Saves/SAV3.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/PKHeX.Core/Saves/SAV3.cs b/PKHeX.Core/Saves/SAV3.cs index 67c2d27e6..9251c5409 100644 --- a/PKHeX.Core/Saves/SAV3.cs +++ b/PKHeX.Core/Saves/SAV3.cs @@ -298,6 +298,21 @@ public sealed override string ChecksumInfo } } + public static bool IsMail(int itemID) => (uint)(itemID - 121) <= (132 - 121); + + protected override void SetPartyValues(PKM pk, bool isParty) + { + if (pk is not PK3 p3) + return; + + // If no mail ID is set, ensure it is set to 0xFF for party and 0x00 for box format. + // Box format doesn't store this value, but set it anyway for clarity. + if (!IsMail(p3.HeldItem)) + p3.HeldMailID = isParty ? (sbyte)-1 : (sbyte)0; + + base.SetPartyValues(pk, isParty); + } + public abstract uint SecurityKey { get; set; } public sealed override string OT