Simplify Shiny SID creation

calculates a passing SID and applies random bits to not be too
predictable
no need to bruteforce
This commit is contained in:
Kurt 2017-06-03 08:58:30 -07:00
parent 5b699a4771
commit 32deb3879a
3 changed files with 3 additions and 6 deletions

View file

@ -772,7 +772,8 @@ namespace PKHeX.Core
public void setShinySID()
{
if (IsShiny) return;
do SID = Util.rnd16(); while (!IsShiny);
var xor = TID ^ (PID >> 16) ^ (PID & 0xFFFF);
SID = (int)((xor & 0xFFF8) | (Util.rnd32() & 7));
}
/// <summary>
/// Applies a PID to the <see cref="PKM"/> according to the specified <see cref="Gender"/>.

View file

@ -9,10 +9,6 @@ namespace PKHeX.Core
{
return (uint)rand.Next(1 << 30) << 2 | (uint)rand.Next(1 << 2);
}
internal static ushort rnd16()
{
return (ushort)rand.Next(ushort.MaxValue);
}
public static void Shuffle<T>(T[] array)
{
int n = array.Length;

View file

@ -1487,7 +1487,7 @@ namespace PKHeX.WinForms.Controls
if (pkm.Format > 2)
{
if(PID)
if (PID)
{
pkm.setShinyPID();
TB_PID.Text = pkm.PID.ToString("X8");