mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-27 22:02:17 -05:00
Simplify GetUnownForm method
yeah lets not fetch a throwaway byte array to remove the need to rightshift use the GetRandomPID fetch.
This commit is contained in:
parent
dc3cdd4491
commit
69cd79c6b5
|
|
@ -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)
|
|||
/// <summary>
|
||||
/// Gets the Unown Forme ID from PID.
|
||||
/// </summary>
|
||||
/// <param name="PID">Personality ID</param>
|
||||
/// <param name="pid">Personality ID</param>
|
||||
/// <remarks>Should only be used for 3rd Generation origin specimens.</remarks>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user