diff --git a/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5BW.cs b/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5BW.cs index 2809a475c..9ab0abd94 100644 --- a/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5BW.cs +++ b/PKHeX.Core/Legality/Encounters/Data/Gen5/Encounters5BW.cs @@ -121,7 +121,7 @@ public static class Encounters5BW new(354, 37, 538, Gender: 1, Promotion: Banette), new(448, 10, 418, Gender: 0, Promotion: Lucario), new(468, 10, 217, Gender: 0, Promotion: Togekiss), - + // PGL (Both Versions) new (149, 55, 009, Gender: 0, Promotion: Dragonite1), // JPN/KOR ThunderPunch new (149, 55, 245, Gender: 0, Promotion: Dragonite2), // INT ExtremeSpeed diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen5/GlobalLinkPromotion.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen5/GlobalLinkPromotion.cs index f5d7e18b3..295223a7a 100644 --- a/PKHeX.Core/Legality/Encounters/Templates/Gen5/GlobalLinkPromotion.cs +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen5/GlobalLinkPromotion.cs @@ -47,9 +47,10 @@ public enum GlobalLinkPromotionLanguage : byte None, Japanese = 1 << 0, Korean = 1 << 1, + NotInt = Japanese | Korean, + International = 1 << 2, - NotInt = Japanese | Korean, NotKor = Japanese | International, All = Japanese | Korean | International, } diff --git a/PKHeX.Core/Legality/RNG/Algorithms/LCRNG.cs b/PKHeX.Core/Legality/RNG/Algorithms/LCRNG.cs index dbfc731cb..063bdea5c 100644 --- a/PKHeX.Core/Legality/RNG/Algorithms/LCRNG.cs +++ b/PKHeX.Core/Legality/RNG/Algorithms/LCRNG.cs @@ -8,6 +8,13 @@ namespace PKHeX.Core; /// /// Frame advancement for forward and reverse. ///
+/// Standard MSVC (Microsoft Visual C/C++) runtime library implementation, with customized by GameFreak programmers. +/// Historically, the "first" documented RNG implementation of the Pokémon games using a linear congruential generator, hence the eponymous name of this class. +///
+///
+/// https://blog.winter-software.com/2024/06/16/emerald-rng-memes +///
+///
/// https://en.wikipedia.org/wiki/Linear_congruential_generator ///
///
@@ -17,8 +24,8 @@ namespace PKHeX.Core; public static class LCRNG { // Forward and reverse constants - public const uint Mult = 0x41C64E6D; - public const uint Add = 0x00006073; + public const uint Mult = 0x41C64E6D; // Standard ISO C / POSIX implementation multiplier constant + public const uint Add = 0x00006073; // (12345*2)+1, *2+1 via misguided understanding when revising rand() outputs from s16 => u16. public const uint rMult = 0xEEB9EB65; public const uint rAdd = 0x0A3561A1; diff --git a/PKHeX.Core/Legality/RNG/Algorithms/XDRNG.cs b/PKHeX.Core/Legality/RNG/Algorithms/XDRNG.cs index 3a13a9e00..d4278db95 100644 --- a/PKHeX.Core/Legality/RNG/Algorithms/XDRNG.cs +++ b/PKHeX.Core/Legality/RNG/Algorithms/XDRNG.cs @@ -8,6 +8,9 @@ namespace PKHeX.Core; /// /// Frame advancement for forward and reverse. ///
+/// Standard MSVC (Microsoft Visual C/C++) runtime library implementation. +///
+///
/// https://en.wikipedia.org/wiki/Linear_congruential_generator ///
///
@@ -17,8 +20,8 @@ namespace PKHeX.Core; public static class XDRNG { // Forward and reverse constants - public const uint Mult = 0x000343FD; - public const uint Add = 0x00269EC3; + public const uint Mult = 0x000343FD; // 214013 + public const uint Add = 0x00269EC3; // 2531011 public const uint rMult = 0xB9B33155; public const uint rAdd = 0xA170F641; diff --git a/PKHeX.Core/Legality/RNG/Algorithms/XorShift128.cs b/PKHeX.Core/Legality/RNG/Algorithms/XorShift128.cs index 35d6df125..b31918b85 100644 --- a/PKHeX.Core/Legality/RNG/Algorithms/XorShift128.cs +++ b/PKHeX.Core/Legality/RNG/Algorithms/XorShift128.cs @@ -75,14 +75,12 @@ public uint Prev() var t = w ^ z ^ (z >> 19); t ^= t >> 8; t ^= t >> 16; + t ^= t << 11; + t ^= t << 22; w = z; z = y; y = x; - - t ^= t << 11; - t ^= t << 22; - x = t; return w; } diff --git a/Tests/PKHeX.Core.Tests/PKM/PIDIVTests.cs b/Tests/PKHeX.Core.Tests/PKM/PIDIVTests.cs index 6d7d0168d..c643c4112 100644 --- a/Tests/PKHeX.Core.Tests/PKM/PIDIVTests.cs +++ b/Tests/PKHeX.Core.Tests/PKM/PIDIVTests.cs @@ -210,7 +210,7 @@ public void Method1(uint seed, ushort rand0, ushort rand1) int count = LCRNGReversal.GetSeeds(seeds, first, second); count.Should().NotBe(0); - seeds[..count].IndexOf(seed).Should().NotBe(-1); + seeds[..count].Contains(seed).Should().BeTrue(); } [Fact] @@ -231,8 +231,8 @@ public void PIDIVMethod4IVs() // Seeds need to be unrolled twice to account for the 2 PID rolls before IVs. var reg = seeds[..count]; - var index = reg.IndexOf(LCRNG.Next2(0x48FBAA42u)); - index.Should().NotBe(-1); + var expect = LCRNG.Next2(0x48FBAA42u); + reg.Contains(expect).Should().BeTrue(); } [Fact] @@ -247,10 +247,10 @@ public void PIDIVSearchEuclid() Span seeds = stackalloc uint[XDRNG.MaxCountSeedsIV]; var cp = XDRNG.GetSeeds(seeds, rand0 & 0xFFFF0000, rand1 & 0xFFFF0000); var p = seeds[..cp]; - p.IndexOf(seed).Should().NotBe(-1); + p.Contains(seed).Should().BeTrue(); var ci = XDRNG.GetSeedsIVs(seeds, rand0 & 0x7FFF0000, rand1 & 0x7FFF0000); var i = seeds[..ci]; - i.IndexOf(seed).Should().NotBe(-1); + i.Contains(seed).Should().BeTrue(); } }