From 298dc344cfc388f31ae67206e7c65dff883a4b53 Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 18 Sep 2017 16:06:31 -0700 Subject: [PATCH] Fix gen3 emerald badge setter Closes #1452 the bitwise or treated it as an int, which wrote 4 bytes instead of 2, thus overwriting 16 flyto flags Thanks @sora10pls & @Tk77185! --- PKHeX.Core/Saves/SAV3.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PKHeX.Core/Saves/SAV3.cs b/PKHeX.Core/Saves/SAV3.cs index 22c63a51f..4b51e4968 100644 --- a/PKHeX.Core/Saves/SAV3.cs +++ b/PKHeX.Core/Saves/SAV3.cs @@ -326,7 +326,8 @@ public int Badges switch (Version) { case GameVersion.E: - BitConverter.GetBytes(BitConverter.ToUInt16(Data, BlockOfs[2] + 0x3FC) & ~(0xFF << 7) | (value << 7)).CopyTo(Data, BlockOfs[2] + 0x3FC); + var val = BitConverter.ToUInt16(Data, BlockOfs[2] + 0x3FC) & ~(0xFF << 7) | (value << 7); + BitConverter.GetBytes((ushort)val).CopyTo(Data, BlockOfs[2] + 0x3FC); break; case GameVersion.FRLG: Data[BlockOfs[2] + 0x64] = (byte)value; break; default: return; // RS