Remove PKX.LCRNG method

Duplicate with RNG.LCRNG
reuse cryptarray for gen5 mysterygift r/w
This commit is contained in:
Kurt 2019-03-16 16:25:25 -07:00
parent fc10fd3d60
commit ebc7c6ae29
3 changed files with 10 additions and 13 deletions

View file

@ -204,8 +204,8 @@ namespace PKHeX.Core
// 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 @@ namespace PKHeX.Core
{
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());

View file

@ -60,9 +60,6 @@ namespace PKHeX.Core
/// <returns>A <see cref="bool"/> indicating whether or not the length is valid for a <see cref="PKM"/>.</returns>
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);
/// <summary>
/// Species name lists indexed by the <see cref="PKM.Language"/> value.
/// </summary>
@ -439,6 +436,9 @@ namespace PKHeX.Core
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)
{

View file

@ -289,8 +289,7 @@ namespace PKHeX.Core
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 @@ namespace PKHeX.Core
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);