diff --git a/PKHeX.Core/MysteryGifts/PGT.cs b/PKHeX.Core/MysteryGifts/PGT.cs
index c77b2f330..181480723 100644
--- a/PKHeX.Core/MysteryGifts/PGT.cs
+++ b/PKHeX.Core/MysteryGifts/PGT.cs
@@ -204,8 +204,8 @@ private void SetPINGA(PK4 pk4, EncounterCriteria criteria)
// Generate IVs
if (pk4.IV32 == 0)
{
- uint iv1 = (PKX.LCRNG(ref seed) >> 16) & 0x7FFF;
- uint iv2 = (PKX.LCRNG(ref seed) >> 16) & 0x7FFF;
+ uint iv1 = ((seed = RNG.LCRNG.Next(seed)) >> 16) & 0x7FFF;
+ uint iv2 = ((_ = RNG.LCRNG.Next(seed)) >> 16) & 0x7FFF;
pk4.IV32 = iv1 | iv2 << 15;
}
}
@@ -229,9 +229,9 @@ private static uint GeneratePID(uint seed, PK4 pk4)
{
do
{
- uint pid1 = PKX.LCRNG(ref seed) >> 16;
- uint pid2 = PKX.LCRNG(ref seed) >> 16;
- pk4.PID = pid1 | (pid2 << 16);
+ uint pid1 = (seed = RNG.LCRNG.Next(seed)) >> 16; // low
+ uint pid2 = (seed = RNG.LCRNG.Next(seed)) & 0xFFFF0000; // hi
+ pk4.PID = pid2 | pid1;
// sanity check gender for non-genderless PID cases
} while (!pk4.IsGenderValid());
diff --git a/PKHeX.Core/PKM/Util/PKX.cs b/PKHeX.Core/PKM/Util/PKX.cs
index ce7deed44..2457a47f5 100644
--- a/PKHeX.Core/PKM/Util/PKX.cs
+++ b/PKHeX.Core/PKM/Util/PKX.cs
@@ -60,9 +60,6 @@ public static class PKX
/// A indicating whether or not the length is valid for a .
public static bool IsPKM(long len) => Sizes.Contains((int)len);
- public static uint LCRNG(uint seed) => RNG.LCRNG.Next(seed);
- public static uint LCRNG(ref uint seed) => seed = RNG.LCRNG.Next(seed);
-
///
/// Species name lists indexed by the value.
///
@@ -439,6 +436,9 @@ public static void CryptArray(byte[] data, uint seed, int start, int end)
while (i < end);
}
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static void CryptArray(byte[] data, uint seed) => CryptArray(data, seed, 0, data.Length);
+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void Crypt(byte[] data, ref uint seed, int i)
{
diff --git a/PKHeX.Core/Saves/SAV5.cs b/PKHeX.Core/Saves/SAV5.cs
index b4b6a814b..ce6c73e09 100644
--- a/PKHeX.Core/Saves/SAV5.cs
+++ b/PKHeX.Core/Saves/SAV5.cs
@@ -289,8 +289,7 @@ public override MysteryGiftAlbum GiftAlbum
uint seed = BitConverter.ToUInt32(Data, wcSeed);
MysteryGiftAlbum Info = new MysteryGiftAlbum { Seed = seed };
byte[] wcData = GetData(WondercardData, 0xA90); // Encrypted, Decrypt
- for (int i = 0; i < wcData.Length; i += 2)
- BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(wcData, i) ^ PKX.LCRNG(ref seed) >> 16)).CopyTo(wcData, i);
+ PKX.CryptArray(wcData, seed);
Info.Flags = new bool[GiftFlagMax];
Info.Gifts = new MysteryGift[GiftCountMax];
@@ -318,9 +317,7 @@ public override MysteryGiftAlbum GiftAlbum
value.Gifts[i].Data.CopyTo(wcData, 0x100 + (i *PGF.Size));
// Decrypted, Encrypt
- uint seed = value.Seed;
- for (int i = 0; i < wcData.Length; i += 2)
- BitConverter.GetBytes((ushort)(BitConverter.ToUInt16(wcData, i) ^ PKX.LCRNG(ref seed) >> 16)).CopyTo(wcData, i);
+ PKX.CryptArray(wcData, value.Seed);
// Write Back
wcData.CopyTo(Data, WondercardData);