Check block index before calculating

Missing/Duplicate blocks (???) result in -1, so skip them.

https://projectpokemon.org/home/forums/topic/52437-cant-export-unmodified-sav-file/

replace linq with manual allocation
This commit is contained in:
Kurt 2019-04-27 17:19:54 -07:00
parent a220970124
commit 0dc45c00ec

View file

@ -239,7 +239,9 @@ namespace PKHeX.Core
}
SetChecksums();
return Data.Take(Data.Length - SIZE_RESERVED).ToArray();
var result = new byte[Data.Length - SIZE_RESERVED];
Buffer.BlockCopy(Data, 0, result, 0, result.Length);
return result;
}
private readonly int ActiveSAV;
@ -283,7 +285,10 @@ namespace PKHeX.Core
for (int i = 0; i < BLOCK_COUNT; i++)
{
int ofs = ABO + (i * SIZE_BLOCK);
int len = chunkLength[BlockOrder[i]];
var index = BlockOrder[i];
if (index == -1)
continue;
int len = chunkLength[index];
ushort chk = Checksums.CRC32(Data, ofs, len);
BitConverter.GetBytes(chk).CopyTo(Data, ofs + 0xFF6);
}