PKHeX/PKHeX.Core/Saves/Substructures/Gen6/Contest6.cs
Kurt ad0c9b147d SAV6AO: Fix dexnav get/set
Was looking in the wrong segment of save data. Now points to the correct span (pokedex).

Extract a few more save blocks and interactions.
Basically try to get rid of any remaining `SAV.Data` references. Still a few left, but aren't broken.

Closes #4259
2024-05-01 22:58:47 -05:00

26 lines
768 B
C#

using System;
using static System.Buffers.Binary.BinaryPrimitives;
namespace PKHeX.Core;
public sealed class Contest6(SAV6AO sav, Memory<byte> raw) : SaveBlock<SAV6AO>(sav, raw)
{
public const int CountBlock = 12;
public const uint MaxBlock = 999;
public uint GetBlockCount(int index)
{
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual((uint)index, (uint)CountBlock);
return ReadUInt32LittleEndian(Data[(index * 4)..]);
}
public void SetBlockCount(int index, uint value)
{
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual((uint)index, (uint)CountBlock);
if (value > MaxBlock)
value = MaxBlock;
WriteUInt32LittleEndian(Data[(index * 4)..], value);
}
// 0x48.. ???
}