mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-25 03:43:16 +00:00
fc754b346b
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces) Updates all the files, one less level of indentation. Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
32 lines
751 B
C#
32 lines
751 B
C#
using System;
|
|
using static System.Buffers.Binary.BinaryPrimitives;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
public abstract class Gen3MysteryData
|
|
{
|
|
public readonly byte[] Data;
|
|
|
|
protected Gen3MysteryData(byte[] data) => Data = data;
|
|
|
|
public uint Checksum
|
|
{
|
|
get => ReadUInt32LittleEndian(Data.AsSpan(0));
|
|
set => WriteUInt32LittleEndian(Data.AsSpan(0), value);
|
|
}
|
|
|
|
public bool IsChecksumValid() => Checksum == GetChecksum(Data);
|
|
public void FixChecksum() => Checksum = GetChecksum(Data);
|
|
|
|
private static uint GetChecksum(ReadOnlySpan<byte> data)
|
|
{
|
|
uint sum = 0;
|
|
for (var i = 4; i < data.Length; i++)
|
|
{
|
|
var b = data[i];
|
|
sum += b;
|
|
}
|
|
|
|
return sum;
|
|
}
|
|
}
|