Fix poketch write

1123c24b0c
had addressed the loading, however, it did not address the saving

update pkx to not create a new array every time IsPKM is called
(possibly a lot)
This commit is contained in:
Kurt 2018-05-13 20:35:09 -07:00
parent 857919bd28
commit 3ee6070b98
2 changed files with 14 additions and 15 deletions

View File

@ -41,24 +41,23 @@ public static class PKX
internal const int SIZE_6STORED = 0xE8;
internal const int SIZE_6BLOCK = 56;
private static readonly HashSet<int> Sizes = new HashSet<int>
{
SIZE_1JLIST, SIZE_1ULIST,
SIZE_2ULIST, SIZE_2JLIST,
SIZE_3STORED, SIZE_3PARTY,
SIZE_3CSTORED, SIZE_3XSTORED,
SIZE_4STORED, SIZE_4PARTY,
SIZE_5PARTY,
SIZE_6STORED, SIZE_6PARTY
};
/// <summary>
/// Determines if the given length is valid for a <see cref="PKM"/>.
/// </summary>
/// <param name="len">Data length of the file/array.</param>
/// <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)
{
return new[]
{
SIZE_1JLIST, SIZE_1ULIST,
SIZE_2ULIST, SIZE_2JLIST,
SIZE_3STORED, SIZE_3PARTY,
SIZE_3CSTORED, SIZE_3XSTORED,
SIZE_4STORED, SIZE_4PARTY,
SIZE_5PARTY,
SIZE_6STORED, SIZE_6PARTY
}.Contains((int)len);
}
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);

View File

@ -217,9 +217,9 @@ private void ReadPoketch()
private void SavePoketch()
{
byte count = 0;
for (int i = 0; i < CLB_Poketch.Items.Count; i++)
for (int i = 1; i < CLB_Poketch.Items.Count; i++)
{
if (CLB_Poketch.GetItemChecked(i))
if (CLB_Poketch.GetItemChecked(i-1))
{
count++;
if (!oldPoketchVal[i])