From 69cd79c6b5725b28bb0c858a30fcb3728ce9ceb0 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 27 Jun 2018 18:52:02 -0700 Subject: [PATCH] Simplify GetUnownForm method yeah lets not fetch a throwaway byte array to remove the need to rightshift use the GetRandomPID fetch. --- PKHeX.Core/PKM/Util/PKX.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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); } ///