update channel generation

Thanks @admiral-fish !
This commit is contained in:
Kurt 2017-07-15 19:59:38 -07:00
parent 2a2f5669e4
commit c61c572f35
2 changed files with 14 additions and 3 deletions

View file

@ -209,7 +209,10 @@ namespace PKHeX.Core
return false;
}
var channel = GetSeedsFromPID(RNG.XDRNG, bot, top ^ 0x8000);
var undo = top ^ 0x8000;
if ((undo > 7 ? 0 : 1) != (bot ^ pk.SID ^ 40122))
top = undo;
var channel = GetSeedsFromPID(RNG.XDRNG, bot, top);
foreach (var seed in channel)
{
var C = RNG.XDRNG.Advance(seed, 3); // held item

View file

@ -71,8 +71,16 @@
var D = rng.Next(C); // Version
var E = rng.Next(D); // OT Gender
pk.SID = (int)(O >> 16);
pk.PID = (A & 0xFFFF0000 | B >> 16) ^ 0x80000000;
var TID = 40122;
var SID = (int)(O >> 16);
var pid1 = A >> 16;
var pid2 = B >> 16;
pk.TID = TID;
pk.SID = SID;
var pid = pid1 << 16 | pid2;
if ((pid2 > 7 ? 0 : 1) != (pid1 ^ SID ^ TID))
pid ^= 0x80000000;
pk.PID = pid;
pk.HeldItem = (int)(C >> 31) + 169; // 0-Ganlon, 1-Salac
pk.Version = (int)(D >> 31) + 1; // 0-Sapphire, 1-Ruby
pk.OT_Gender = (int)(E >> 31);