From a9ff3aceaa53437e8ca202c8b283a8d6ca2d3b94 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 23 Apr 2017 12:07:45 -0700 Subject: [PATCH] Fix Navel Rock clearing issue Closes #1090 Saving of the Battle Frontier symbols is clearing the flag block2 ofs 0x40C = Navel Rock block2 ofs 0x408 = symbols bitconverter getbytes was fed an Int64 due to bit shifting ints and uints. Forcibly cast to uint to keep only 32 bits -> intended behavior. sneak in RNG readonly --- PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs | 4 +++- PKHeX/Legality/RNG/RNG.cs | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs index ee45ac7ae..29124574a 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs @@ -364,7 +364,9 @@ private void saveBF() iSymbols |= (uint)((Symbols[i] & 3) << i * 2); if (CHK_ActivatePass.Checked) iSymbols |= 1 << 14; - BitConverter.GetBytes(BitConverter.ToUInt32(SAV.Data, ofsSymbols) & ~(0x7FFF << 4) | (iSymbols & 0x7FFF) << 4).CopyTo(SAV.Data, ofsSymbols); + + uint val = (uint)(BitConverter.ToUInt32(SAV.Data, ofsSymbols) & ~(0x7FFF << 4) | (iSymbols & 0x7FFF) << 4); + BitConverter.GetBytes(val).CopyTo(SAV.Data, ofsSymbols); } private void BTN_Symbol_Click(object sender, EventArgs e) { diff --git a/PKHeX/Legality/RNG/RNG.cs b/PKHeX/Legality/RNG/RNG.cs index 171a087fe..83c118858 100644 --- a/PKHeX/Legality/RNG/RNG.cs +++ b/PKHeX/Legality/RNG/RNG.cs @@ -2,9 +2,9 @@ { public class RNG { - public static RNG LCRNG = new RNG(0x41C64E6D, 0x00006073, 0xEEB9EB65, 0x0A3561A1); - public static RNG XDRNG = new RNG(0x000343FD, 0x00269EC3, 0xB9B33155, 0xA170F641); - public static RNG ARNG = new RNG(0x6C078965, 0x00000001, 0x9638806D, 0x69C77F93); + public static readonly RNG LCRNG = new RNG(0x41C64E6D, 0x00006073, 0xEEB9EB65, 0x0A3561A1); + public static readonly RNG XDRNG = new RNG(0x000343FD, 0x00269EC3, 0xB9B33155, 0xA170F641); + public static readonly RNG ARNG = new RNG(0x6C078965, 0x00000001, 0x9638806D, 0x69C77F93); private readonly uint Mult, Add, rMult, rAdd; protected RNG(uint f_mult, uint f_add, uint r_mult, uint r_add)