From 483998d93081aa9ecb72ee868701a4c3eba0c0a9 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 18 May 2017 22:40:35 -0700 Subject: [PATCH] Change gen4 (egg) met location setter Closes #1135 clear both if zero set value to dp location if a valid dp location, else set faraway place set value to pthgss location if originated from pthgss --- PKHeX.Core/PKM/BK4.cs | 28 ++++++++++------------------ PKHeX.Core/PKM/PK4.cs | 28 ++++++++++------------------ PKHeX.Core/PKM/PKM.cs | 2 +- 3 files changed, 21 insertions(+), 37 deletions(-) diff --git a/PKHeX.Core/PKM/BK4.cs b/PKHeX.Core/PKM/BK4.cs index bedbe0006..21974e885 100644 --- a/PKHeX.Core/PKM/BK4.cs +++ b/PKHeX.Core/PKM/BK4.cs @@ -250,20 +250,16 @@ public override int Egg_Location BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x44); BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x7E); } - else if (PtHGSS) + else if (value < 2000 && value > 111 || value < 3000 && value > 2010) { + // Met location not in DP, set to Faraway Place BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x44); - BigEndian.GetBytes((ushort)0xBBA).CopyTo(Data, 0x7E); // Faraway Place (for DP display) - } - else if ((value < 2000 && value > 111) || (value < 3000 && value > 2010)) - { - // Met location not in DP, set to Mystery Zone (0, illegal) as opposed to Faraway Place - BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x44); - BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x7E); + BigEndian.GetBytes((ushort)0xBBA).CopyTo(Data, 0x7E); } else { - BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x44); + int pthgss = PtHGSS ? value : 0; // only set to PtHGSS loc if encountered in game + BigEndian.GetBytes((ushort)pthgss).CopyTo(Data, 0x44); BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x7E); } } @@ -284,20 +280,16 @@ public override int Met_Location BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x46); BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x80); } - else if (PtHGSS) + else if (value < 2000 && value > 111 || value < 3000 && value > 2010) { + // Met location not in DP, set to Faraway Place BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x46); - BigEndian.GetBytes((ushort)0xBBA).CopyTo(Data, 0x80); // Faraway Place (for DP display) - } - else if ((value < 2000 && value > 111) || (value < 3000 && value > 2010)) - { - // Met location not in DP, set to Mystery Zone (0, illegal) as opposed to Faraway Place - BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x46); - BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x80); + BigEndian.GetBytes((ushort)0xBBA).CopyTo(Data, 0x80); } else { - BigEndian.GetBytes((ushort)0).CopyTo(Data, 0x46); + int pthgss = PtHGSS ? value : 0; // only set to PtHGSS loc if encountered in game + BigEndian.GetBytes((ushort)pthgss).CopyTo(Data, 0x46); BigEndian.GetBytes((ushort)value).CopyTo(Data, 0x80); } } diff --git a/PKHeX.Core/PKM/PK4.cs b/PKHeX.Core/PKM/PK4.cs index cc752694c..a46b0203f 100644 --- a/PKHeX.Core/PKM/PK4.cs +++ b/PKHeX.Core/PKM/PK4.cs @@ -238,20 +238,16 @@ public override int Egg_Location BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x44); BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x7E); } - else if (PtHGSS) + else if (value < 2000 && value > 111 || value < 3000 && value > 2010) { + // Met location not in DP, set to Faraway Place BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x44); - BitConverter.GetBytes((ushort)0xBBA).CopyTo(Data, 0x7E); // Faraway Place (for DP display) - } - else if ((value < 2000 && value > 111) || (value < 3000 && value > 2010)) - { - // Met location not in DP, set to Mystery Zone (0, illegal) as opposed to Faraway Place - BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x44); - BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x7E); + BitConverter.GetBytes((ushort)0xBBA).CopyTo(Data, 0x7E); } else { - BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x44); + int pthgss = PtHGSS ? value : 0; // only set to PtHGSS loc if encountered in game + BitConverter.GetBytes((ushort)pthgss).CopyTo(Data, 0x44); BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x7E); } } @@ -272,20 +268,16 @@ public override int Met_Location BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x46); BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x80); } - else if (PtHGSS) + else if (value < 2000 && value > 111 || value < 3000 && value > 2010) { + // Met location not in DP, set to Faraway Place BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x46); - BitConverter.GetBytes((ushort)0xBBA).CopyTo(Data, 0x80); // Faraway Place (for DP display) - } - else if ((value < 2000 && value > 111) || (value < 3000 && value > 2010)) - { - // Met location not in DP, set to Mystery Zone (0, illegal) as opposed to Faraway Place - BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x46); - BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x80); + BitConverter.GetBytes((ushort)0xBBA).CopyTo(Data, 0x80); } else { - BitConverter.GetBytes((ushort)0).CopyTo(Data, 0x46); + int pthgss = PtHGSS ? value : 0; // only set to PtHGSS loc if encountered in game + BitConverter.GetBytes((ushort)pthgss).CopyTo(Data, 0x46); BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x80); } } diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index 9ca33004f..4210b7556 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -549,7 +549,7 @@ public bool InhabitedGeneration(int Generation, int species = -1) } } - /// do { + /// /// Checks if the PKM has its original met location. /// /// Returns false if the Met Location has been overwritten via generational transfer.