diff --git a/PKHeX.Core/PKM/Util/PKX.cs b/PKHeX.Core/PKM/Util/PKX.cs index 67e413588..5346fc2f3 100644 --- a/PKHeX.Core/PKM/Util/PKX.cs +++ b/PKHeX.Core/PKM/Util/PKX.cs @@ -577,7 +577,7 @@ public static uint GetRandomPID(int species, int cg, int origin, int nature, int // Gen 3 Unown: Letter/form derived from PID if (g3unown) { - uint pidLetter = ((pid & 0x3000000) >> 18 | (pid & 0x30000) >> 12 | (pid & 0x300) >> 6 | pid & 0x3) % 28; + var pidLetter = GetUnownForm(pid); if (pidLetter != form) continue; } @@ -673,13 +673,13 @@ public static int[] SetHPIVs(int type, int[] ivs) /// /// Gets the Unown Forme ID from PID. /// - /// Personality ID + /// Personality ID /// Should only be used for 3rd Generation origin specimens. /// - public static int GetUnownForm(uint PID) + public static int GetUnownForm(uint pid) { - byte[] data = BitConverter.GetBytes(PID); - return (((data[3] & 3) << 6) + ((data[2] & 3) << 4) + ((data[1] & 3) << 2) + ((data[0] & 3) << 0)) % 28; + var val = (pid & 0x3000000) >> 18 | (pid & 0x30000) >> 12 | (pid & 0x300) >> 6 | pid & 0x3; + return (int)(val % 28); } ///