mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-21 05:09:35 -05:00
Existing `get`/`set` logic is flawed in that it doesn't work on Big Endian operating systems, and it allocates heap objects when it doesn't need to. `System.Buffers.Binary.BinaryPrimitives` in the `System.Memory` NuGet package provides both Little Endian and Big Endian methods to read and write data; all the `get`/`set` operations have been reworked to use this new API. This removes the need for PKHeX's manual `BigEndian` class, as all functions are already covered by the BinaryPrimitives API. The `StringConverter` has now been rewritten to accept a Span to read from & write to, no longer requiring a temporary StringBuilder. Other Fixes included: - The Super Training UI for Gen6 has been reworked according to the latest block structure additions. - Cloning a Stadium2 Save File now works correctly (opening from the Folder browser list). - Checksum & Sanity properties removed from parent PKM class, and is now implemented via interface.
24 lines
816 B
C#
24 lines
816 B
C#
using System;
|
|
using System.ComponentModel;
|
|
using static System.Buffers.Binary.BinaryPrimitives;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// Contest photo and Rank Point storage.
|
|
/// </summary>
|
|
/// <remarks>size 0x720, struct_name CONTEST_DATA</remarks>
|
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
public sealed class Contest8b : SaveBlock
|
|
{
|
|
public const int SIZE_CONTEST_PHOTO = 0x16C;
|
|
public const int PHOTO_MAX = 5;
|
|
|
|
public Contest8b(SAV8BS sav, int offset) : base(sav) => Offset = offset;
|
|
|
|
private const int OFS_RANK = SIZE_CONTEST_PHOTO * PHOTO_MAX; // 0x71C;
|
|
|
|
public uint ContestRankPoint { get => ReadUInt32LittleEndian(Data.AsSpan(Offset + OFS_RANK)); set => WriteUInt32LittleEndian(Data.AsSpan(Offset + OFS_RANK), value); }
|
|
}
|
|
}
|