Fix Entree Forest saving

Closes #3524
This commit is contained in:
Kurt 2022-06-14 22:30:57 -07:00
parent 2a83bc5fa2
commit 8319bfe003
2 changed files with 7 additions and 8 deletions

View file

@ -210,7 +210,7 @@ namespace PKHeX.Core
public EntreeForest EntreeData
{
get => new(GetData(EntreeForestOffset, 0x850));
get => new(GetData(EntreeForestOffset, EntreeForest.SIZE));
set => SetData(value.Write(), EntreeForestOffset);
}

View file

@ -25,23 +25,22 @@ namespace PKHeX.Core
/// </summary>
private const byte MaxUnlock38Areas = 6;
private const int EncryptionSeedOffset = 0x84C;
private const int EncryptionSeedOffset = SIZE - 4; // 0x84C
public const int SIZE = 0x850;
private readonly byte[] Data;
public EntreeForest(byte[] data)
{
Data = data;
PokeCrypto.CryptArray(data.AsSpan(0, EncryptionSeedOffset), EncryptionSeed);
}
public EntreeForest(byte[] data) => CryptRegion(Data = data);
public byte[] Write()
{
byte[] data = (byte[])Data.Clone();
PokeCrypto.CryptArray(data.AsSpan(0, EncryptionSeedOffset), EncryptionSeedOffset);
CryptRegion(data);
return data;
}
private void CryptRegion(Span<byte> data) => PokeCrypto.CryptArray(data[..EncryptionSeedOffset], EncryptionSeed);
/// <summary>
/// Gets all Entree Slot data.
/// </summary>