mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 22:40:22 +00:00
47071b41f3
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.
42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using System;
|
|
using static System.Buffers.Binary.BinaryPrimitives;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
/// <summary>
|
|
/// Honey Tree in Sinnoh (Gen4)
|
|
/// </summary>
|
|
public sealed class HoneyTreeValue
|
|
{
|
|
public const int Size = 8;
|
|
|
|
public readonly byte[] Data;
|
|
|
|
public uint Time { get => ReadUInt32LittleEndian(Data.AsSpan(0)); set => WriteUInt32LittleEndian(Data.AsSpan(0), value); }
|
|
public int Slot { get => Data[4]; set => Data[4] = (byte)value; }
|
|
public int SubTable { get => Data[5]; set => Data[5] = (byte)value; } // offset by 1 with respect to Group
|
|
public int Group { get => Data[6]; set { Data[6] = (byte)value; SubTable = Math.Max(0, Group - 1); } }
|
|
public int Shake { get => Data[7]; set => Data[7] = (byte)value; }
|
|
|
|
public HoneyTreeValue(byte[] data)
|
|
{
|
|
Data = data;
|
|
}
|
|
|
|
public static readonly int[][] TableDP =
|
|
{
|
|
new[] {000, 000, 000, 000, 000, 000},
|
|
new[] {265, 266, 415, 412, 420, 190},
|
|
new[] {415, 412, 420, 190, 214, 265},
|
|
new[] {446, 446, 446, 446, 446, 446},
|
|
};
|
|
|
|
public static readonly int[][] TablePt =
|
|
{
|
|
TableDP[0],
|
|
new[] {415, 265, 412, 420, 190, 190},
|
|
new[] {412, 420, 415, 190, 190, 214},
|
|
TableDP[3],
|
|
};
|
|
}
|
|
}
|