Add more annotations

Fix typo in swsh block name
This commit is contained in:
Kurt 2023-12-07 00:07:55 -08:00
parent 61ab70f6bf
commit ef68886554
7 changed files with 25 additions and 22 deletions

View file

@ -17,7 +17,7 @@ public abstract class HomeOptional1
public const int HeaderSize = 3; // u8 format, u16 length(data[u8])
protected abstract HomeGameDataFormat Format { get; }
protected HomeOptional1(ushort size) => Buffer = new byte[size];
protected HomeOptional1([ConstantExpected] ushort size) => Buffer = new byte[size];
protected HomeOptional1(Memory<byte> buffer) => Buffer = buffer;
protected void EnsureSize([ConstantExpected] int size)

View file

@ -220,7 +220,7 @@ public sealed class SaveBlockAccessor8SWSH : SCBlockAccessor, ISaveBlock8Main
public const uint KPlayRecordsQuest = 0xBF24DDAE; // FSYS_PLAY_POKEMON_QUEST
// Dojo event flags (bool)
public const uint KDojoHairSylistAvailable = 0xE02A722C;
public const uint KDojoHairStylistAvailable = 0xE02A722C;
public const uint KDojoBrokenRotomiDisappeared = 0x60E04225;
public const uint KDojoRotomiDisappeared = 0x82E071A0;
public const uint KDojoTableDisappeared = 0x3D83DC85;

View file

@ -226,16 +226,8 @@ public abstract class SAV3 : SaveFile, ILangDeviantSave, IEventFlag37
return;
// Hall of Fame Checksums
{
var sector = Data.AsSpan(0x1C000, SIZE_SECTOR);
ushort chk = Checksums.CheckSum32(sector[..SIZE_SECTOR_USED]);
WriteUInt16LittleEndian(sector[0xFF4..], chk);
}
{
var sector = Data.AsSpan(0x1D000, SIZE_SECTOR);
ushort chk = Checksums.CheckSum32(sector[..SIZE_SECTOR_USED]);
WriteUInt16LittleEndian(sector[0xFF4..], chk);
}
SetSectoryValidExtra(0x1C000);
SetSectoryValidExtra(0x1D000);
}
public sealed override bool ChecksumsValid
@ -259,9 +251,16 @@ public abstract class SAV3 : SaveFile, ILangDeviantSave, IEventFlag37
}
}
private bool IsSectorValidExtra(int ofs)
private void SetSectoryValidExtra(int offset)
{
var sector = Data.AsSpan(ofs, SIZE_SECTOR);
var sector = Data.AsSpan(offset, SIZE_SECTOR);
var expect = Checksums.CheckSum32(sector[..SIZE_SECTOR_USED]);
WriteUInt16LittleEndian(sector[0xFF4..], expect);
}
private bool IsSectorValidExtra(int offset)
{
var sector = Data.AsSpan(offset, SIZE_SECTOR);
var expect = Checksums.CheckSum32(sector[..SIZE_SECTOR_USED]);
var actual = ReadUInt16LittleEndian(sector[0xFF4..]);
return expect == actual;

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using static System.Buffers.Binary.BinaryPrimitives;
namespace PKHeX.Core;
@ -13,8 +14,8 @@ public abstract class SAV6 : SAV_BEEF, ITrainerStatRecord, ISaveBlock6Core, IReg
protected internal override string ShortSummary => $"{OT} ({Version}) - {Played.LastSavedTime}";
public override string Extension => string.Empty;
protected SAV6(byte[] data, int biOffset) : base(data, biOffset) { }
protected SAV6(int size, int biOffset) : base(size, biOffset) { }
protected SAV6(byte[] data, [ConstantExpected] int biOffset) : base(data, biOffset) { }
protected SAV6([ConstantExpected] int size, [ConstantExpected] int biOffset) : base(size, biOffset) { }
// Configuration
protected override int SIZE_STORED => PokeCrypto.SIZE_6STORED;

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using static System.Buffers.Binary.BinaryPrimitives;
namespace PKHeX.Core;
@ -19,11 +20,11 @@ public abstract class SAV7 : SAV_BEEF, ITrainerStatRecord, ISaveBlock7Main, IReg
return gen <= 7 && f[1] != 'b'; // ignore PB7
});
protected SAV7(byte[] data, int biOffset) : base(data, biOffset)
protected SAV7(byte[] data, [ConstantExpected] int biOffset) : base(data, biOffset)
{
}
protected SAV7(int size, int biOffset) : base(size, biOffset)
protected SAV7([ConstantExpected] int size, [ConstantExpected] int biOffset) : base(size, biOffset)
{
}

View file

@ -1,5 +1,6 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using static System.Buffers.Binary.BinaryPrimitives;
@ -11,12 +12,12 @@ namespace PKHeX.Core;
/// <remarks>Shared logic is used by Gen6 and Gen7 save files.</remarks>
public abstract class SAV_BEEF : SaveFile, ISecureValueStorage
{
protected SAV_BEEF(byte[] data, int biOffset) : base(data)
protected SAV_BEEF(byte[] data, [ConstantExpected] int biOffset) : base(data)
{
BlockInfoOffset = biOffset;
}
protected SAV_BEEF(int size, int biOffset) : base(size)
protected SAV_BEEF([ConstantExpected] int size, [ConstantExpected] int biOffset) : base(size)
{
BlockInfoOffset = biOffset;
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace PKHeX.Core;
@ -22,7 +23,7 @@ public abstract class SaveFile : ITrainerInfo, IGameValueLimit, IBoxDetailWallpa
Metadata = new SaveFileMetadata(this);
}
protected SaveFile(int size = 0) : this(size == 0 ? [] : new byte[size], false) { }
protected SaveFile([ConstantExpected] int size = 0) : this(size == 0 ? [] : new byte[size], false) { }
protected internal abstract string ShortSummary { get; }
public abstract string Extension { get; }