PKHeX/PKHeX.Core/Saves/Substructures/Gen3/Gen3MysteryData.cs
Kurt fc754b346b
File scoped namespaces (#3529)
[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`
2022-06-18 11:04:24 -07:00

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;
}
}