public override bool IsValidAlgorithm( out string message ) { if ( IsEgg && IsValidEggLocation() ) { message = "Valid Egg"; return true; } if ( IsHatched && uint plow = ( PID & 0xFFFF ) << 0x10; uint phigh = (uint)(PID & ~0xFFFF) >> 0x10; bool valid = false; PokePRNG rand = new PokePRNG(); for ( uint j = 0;j < 0x10000; j++ ) { rand.Seed = plow + j; if ( ( rand.NextNum() >> 0x10 ) == phigh ) // A-B { int C = (int)rand.SetNext().HighBits & 0x7FFF; int D = (int)rand.SetNext().HighBits & 0x7FFF; if ( Utility.IsIVMatch( iv1, iv2, C, D ) ) { valid = true; message = "NDS (A-B-C-D)"; if ( RequiresSyncCheck ) { m_ValidSync = IsValidNature( plow + j, PID % 25 ) ); if ( m_ValidSync ) break; } } } } if ( !valid && (HomeTown == 10 || HomeTown == 11) && IsShiny() && IsGrassWild() && Location != 48 ) //Check for chaining! ~ Not in Eterna Forest { PokePRNG rand = new PokePRNG(); uint iv1 = IV1; uint iv2 = IV2; uint highbits = iv1 << 0x10; for ( uint k = 0;k < 2; k++ ) { for( uint i = 0; i < 0x10000; i++ ) { uint seed = ( k << 31 ) + highbits + i; rand.Seed = seed; if ( ( ( rand.Next() >> 0x10 ) & 0x7FFF ) == iv2 ) { for( int j = 0; j < 16; j++ ) rand.PrevNum(); uint natseed = rand.Seed; uint pid = ShinyPID( rand ); if ( realpid == pid ) { valid = true; message = "Chain Shiny"; m_RequiresSyncCheck = false; } } } } } if ( !valid ) message = "Invalid"; return valid; }
public static bool ChainedPID( uint iv1, uint iv2, uint tid, uint sid, uint realpid ) { PokePRNG rand = new PokePRNG(0); uint highbits = iv1 << 0x10; for ( uint k = 0;k < 2; k++ ) { for( uint i = 0; i < 0x10000; i++ ) { uint seed = ( k << 31 ) + highbits + i; rand.Seed = seed; if ( ( ( rand.Next() >> 0x10 ) & 0x7FFF ) == iv2 ) { //Console.WriteLine( "Seed Found: {0:X}", seed ); for( int j = 0; j < 16; j++ ) rand.PrevNum(); uint natseed = rand.Seed; //Console.WriteLine( "Modified Seed: {0:X}", rand.Seed ); uint pid = ShinyPID( tid, sid, rand ); //Console.WriteLine( "Found PID: {0:X}", pid ); if ( realpid == pid ) { bool validnature = ValidNature( natseed, realpid % 25 ); Console.Write( "Chained Sync: " ); if ( validnature ) { PushColor( ConsoleColor.DarkGreen ); Console.WriteLine( "Valid" ); } else { PushColor( ConsoleColor.Red ); Console.WriteLine( "Invalid" ); } PopColor(); return true; } } } } return false; }