Use byte span for BinLinker check

Need to change ConstantExpected to Length when NET8 comes out next month
This commit is contained in:
Kurt 2023-10-14 19:25:39 -07:00
parent b3bbc044ca
commit 0da8c33c52
46 changed files with 117 additions and 107 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using static System.Buffers.Binary.BinaryPrimitives;
namespace PKHeX.Core;
@ -40,14 +41,14 @@ public readonly ref struct BinLinkerAccessor
/// </summary>
/// <param name="data">Data reference</param>
/// <param name="identifier">Expected identifier (debug verification only)</param>
public static BinLinkerAccessor Get(ReadOnlySpan<byte> data, string identifier)
public static BinLinkerAccessor Get(ReadOnlySpan<byte> data, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan<byte> identifier)
{
SanityCheckIdentifier(data, identifier);
return new BinLinkerAccessor(data);
}
[Conditional("DEBUG")]
private static void SanityCheckIdentifier(ReadOnlySpan<byte> data, string identifier)
private static void SanityCheckIdentifier(ReadOnlySpan<byte> data, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan<byte> identifier)
{
Debug.Assert(data.Length > 4);
Debug.Assert(identifier[0] == data[0] && identifier[1] == data[1]);

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace PKHeX.Core;
@ -8,8 +9,8 @@ namespace PKHeX.Core;
/// </summary>
internal static class EncounterUtil
{
internal static ReadOnlySpan<byte> Get(string resource) => Util.GetBinaryResource($"encounter_{resource}.pkl");
internal static BinLinkerAccessor Get(string resource, string ident) => BinLinkerAccessor.Get(Get(resource), ident);
internal static ReadOnlySpan<byte> Get([ConstantExpected] string resource) => Util.GetBinaryResource($"encounter_{resource}.pkl");
internal static BinLinkerAccessor Get([ConstantExpected] string resource, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan<byte> ident) => BinLinkerAccessor.Get(Get(resource), ident);
internal static T? GetMinByLevel<T>(ReadOnlySpan<EvoCriteria> chain, IEnumerable<T> possible) where T : class, IEncounterTemplate
{

View file

@ -8,10 +8,10 @@ namespace PKHeX.Core;
/// </summary>
internal static class Encounters1
{
internal static readonly EncounterArea1[] SlotsRD = EncounterArea1.GetAreas(Get("red", "g1"), RD);
internal static readonly EncounterArea1[] SlotsGN = EncounterArea1.GetAreas(Get("blue", "g1"), GN);
internal static readonly EncounterArea1[] SlotsYW = EncounterArea1.GetAreas(Get("yellow", "g1"), YW);
internal static readonly EncounterArea1[] SlotsBU = EncounterArea1.GetAreas(Get("blue_jp", "g1"), BU);
internal static readonly EncounterArea1[] SlotsRD = EncounterArea1.GetAreas(Get("red", "g1"u8), RD);
internal static readonly EncounterArea1[] SlotsGN = EncounterArea1.GetAreas(Get("blue", "g1"u8), GN);
internal static readonly EncounterArea1[] SlotsYW = EncounterArea1.GetAreas(Get("yellow", "g1"u8), YW);
internal static readonly EncounterArea1[] SlotsBU = EncounterArea1.GetAreas(Get("blue_jp", "g1"u8), BU);
private const string tradeRBY = "traderby";
private static readonly string[][] TradeNames = Util.GetLanguageStrings7(tradeRBY);

View file

@ -8,9 +8,9 @@ namespace PKHeX.Core;
/// </summary>
internal static class Encounters2
{
internal static readonly EncounterArea2[] SlotsGD = EncounterArea2.GetAreas(Get("gold", "g2"), GD);
internal static readonly EncounterArea2[] SlotsSI = EncounterArea2.GetAreas(Get("silver", "g2"), SI);
internal static readonly EncounterArea2[] SlotsC = EncounterArea2.GetAreas(Get("crystal", "g2"), C);
internal static readonly EncounterArea2[] SlotsGD = EncounterArea2.GetAreas(Get("gold", "g2"u8), GD);
internal static readonly EncounterArea2[] SlotsSI = EncounterArea2.GetAreas(Get("silver", "g2"u8), SI);
internal static readonly EncounterArea2[] SlotsC = EncounterArea2.GetAreas(Get("crystal", "g2"u8), C);
private const string tradeGSC = "tradegsc";
private static readonly string[][] TradeNames = Util.GetLanguageStrings8(tradeGSC);

View file

@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using static PKHeX.Core.EncounterUtil;
using static PKHeX.Core.GameVersion;
using static PKHeX.Core.AbilityPermission;
@ -10,10 +11,10 @@ namespace PKHeX.Core;
/// </summary>
internal static class Encounters3FRLG
{
internal static readonly EncounterArea3[] SlotsFR = GetRegular("fr", "fr", FR);
internal static readonly EncounterArea3[] SlotsLG = GetRegular("lg", "lg", LG);
internal static readonly EncounterArea3[] SlotsFR = GetRegular("fr", "fr"u8, FR);
internal static readonly EncounterArea3[] SlotsLG = GetRegular("lg", "lg"u8, LG);
private static EncounterArea3[] GetRegular(string resource, string ident, GameVersion game) => EncounterArea3.GetAreas(Get(resource, ident), game);
private static EncounterArea3[] GetRegular([ConstantExpected] string resource, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan<byte> ident, GameVersion game) => EncounterArea3.GetAreas(Get(resource, ident), game);
private const string tradeFRLG = "tradefrlg";
private static readonly string[][] TradeNames = Util.GetLanguageStrings7(tradeFRLG);

View file

@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using static PKHeX.Core.EncounterUtil;
using static PKHeX.Core.GameVersion;
using static PKHeX.Core.AbilityPermission;
@ -10,13 +11,15 @@ namespace PKHeX.Core;
/// </summary>
internal static class Encounters3RSE
{
private static readonly EncounterArea3[] SlotsSwarmRSE = GetSwarm("rse_swarm", "rs", RSE);
internal static readonly EncounterArea3[] SlotsR = ArrayUtil.ConcatAll(GetRegular("r", "ru", R), SlotsSwarmRSE);
internal static readonly EncounterArea3[] SlotsS = ArrayUtil.ConcatAll(GetRegular("s", "sa", S), SlotsSwarmRSE);
internal static readonly EncounterArea3[] SlotsE = ArrayUtil.ConcatAll(GetRegular("e", "em", E), SlotsSwarmRSE);
private static readonly EncounterArea3[] SlotsSwarmRSE = GetSwarm("rse_swarm", "rs"u8, RSE);
internal static readonly EncounterArea3[] SlotsR = ArrayUtil.ConcatAll(GetRegular("r", "ru"u8, R), SlotsSwarmRSE);
internal static readonly EncounterArea3[] SlotsS = ArrayUtil.ConcatAll(GetRegular("s", "sa"u8, S), SlotsSwarmRSE);
internal static readonly EncounterArea3[] SlotsE = ArrayUtil.ConcatAll(GetRegular("e", "em"u8, E), SlotsSwarmRSE);
private static EncounterArea3[] GetRegular(string resource, string ident, GameVersion game) => EncounterArea3.GetAreas(Get(resource, ident), game);
private static EncounterArea3[] GetSwarm(string resource, string ident, GameVersion game) => EncounterArea3.GetAreasSwarm(Get(resource, ident), game);
private static EncounterArea3[] GetRegular([ConstantExpected] string resource, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan<byte> ident, GameVersion game)
=> EncounterArea3.GetAreas(Get(resource, ident), game);
private static EncounterArea3[] GetSwarm([ConstantExpected] string resource, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan<byte> ident, GameVersion game)
=> EncounterArea3.GetAreasSwarm(Get(resource, ident), game);
private static readonly string[] TrainersPikachu = { string.Empty, "コロシアム", "COLOS", "COLOSSEUM", "ARENA", "COLOSSEUM", string.Empty, "CLAUDIO" };
private static readonly string[] TrainersCelebi = { string.Empty, "アゲト", "AGATE", "SAMARAGD", "SOFO", "EMERITAE", string.Empty, "ÁGATA" };

View file

@ -10,9 +10,9 @@ namespace PKHeX.Core;
/// </summary>
internal static class Encounters4DPPt
{
internal static readonly EncounterArea4[] SlotsD = EncounterArea4.GetAreas(Get("d", "da"), D);
internal static readonly EncounterArea4[] SlotsP = EncounterArea4.GetAreas(Get("p", "pe"), P);
internal static readonly EncounterArea4[] SlotsPt = EncounterArea4.GetAreas(Get("pt", "pt"), Pt);
internal static readonly EncounterArea4[] SlotsD = EncounterArea4.GetAreas(Get("d", "da"u8), D);
internal static readonly EncounterArea4[] SlotsP = EncounterArea4.GetAreas(Get("p", "pe"u8), P);
internal static readonly EncounterArea4[] SlotsPt = EncounterArea4.GetAreas(Get("pt", "pt"u8), Pt);
private const string tradeDPPt = "tradedppt";
private static readonly string[][] TradeNames = Util.GetLanguageStrings8(tradeDPPt);

View file

@ -10,8 +10,8 @@ namespace PKHeX.Core;
/// </summary>
internal static class Encounters4HGSS
{
internal static readonly EncounterArea4[] SlotsHG = EncounterArea4.GetAreas(Get("hg", "hg"), HG);
internal static readonly EncounterArea4[] SlotsSS = EncounterArea4.GetAreas(Get("ss", "ss"), SS);
internal static readonly EncounterArea4[] SlotsHG = EncounterArea4.GetAreas(Get("hg", "hg"u8), HG);
internal static readonly EncounterArea4[] SlotsSS = EncounterArea4.GetAreas(Get("ss", "ss"u8), SS);
internal static readonly EncounterStatic4Pokewalker[] Encounter_PokeWalker = EncounterStatic4Pokewalker.GetAll(Util.GetBinaryResource("encounter_walker4.pkl"));

View file

@ -9,8 +9,8 @@ namespace PKHeX.Core;
/// </summary>
public static class Encounters5B2W2
{
internal static readonly EncounterArea5[] SlotsB2 = EncounterArea5.GetAreas(Get("b2", "52"), B2);
internal static readonly EncounterArea5[] SlotsW2 = EncounterArea5.GetAreas(Get("w2", "52"), W2);
internal static readonly EncounterArea5[] SlotsB2 = EncounterArea5.GetAreas(Get("b2", "52"u8), B2);
internal static readonly EncounterArea5[] SlotsW2 = EncounterArea5.GetAreas(Get("w2", "52"u8), W2);
private const string tradeB2W2 = "tradeb2w2";
private static readonly string[][] TradeNames = Util.GetLanguageStrings8(tradeB2W2);

View file

@ -9,8 +9,8 @@ namespace PKHeX.Core;
/// </summary>
public static class Encounters5BW
{
internal static readonly EncounterArea5[] SlotsB = EncounterArea5.GetAreas(Get("b", "51"), B);
internal static readonly EncounterArea5[] SlotsW = EncounterArea5.GetAreas(Get("w", "51"), W);
internal static readonly EncounterArea5[] SlotsB = EncounterArea5.GetAreas(Get("b", "51"u8), B);
internal static readonly EncounterArea5[] SlotsW = EncounterArea5.GetAreas(Get("w", "51"u8), W);
private const string tradeBW = "tradebw";
private static readonly string[][] TradeNames = Util.GetLanguageStrings8(tradeBW);

View file

@ -9,8 +9,8 @@ namespace PKHeX.Core;
/// </summary>
internal static class Encounters6AO
{
internal static readonly EncounterArea6AO[] SlotsA = EncounterArea6AO.GetAreas(Get("as", "ao"), AS);
internal static readonly EncounterArea6AO[] SlotsO = EncounterArea6AO.GetAreas(Get("or", "ao"), OR);
internal static readonly EncounterArea6AO[] SlotsA = EncounterArea6AO.GetAreas(Get("as", "ao"u8), AS);
internal static readonly EncounterArea6AO[] SlotsO = EncounterArea6AO.GetAreas(Get("or", "ao"u8), OR);
private const string tradeAO = "tradeao";
private static readonly string[][] TradeNames = Util.GetLanguageStrings8(tradeAO);

View file

@ -10,8 +10,8 @@ namespace PKHeX.Core;
internal static class Encounters6XY
{
private static readonly EncounterArea6XY FriendSafari = new();
internal static readonly EncounterArea6XY[] SlotsX = EncounterArea6XY.GetAreas(Get("x", "xy"), X, FriendSafari);
internal static readonly EncounterArea6XY[] SlotsY = EncounterArea6XY.GetAreas(Get("y", "xy"), Y, FriendSafari);
internal static readonly EncounterArea6XY[] SlotsX = EncounterArea6XY.GetAreas(Get("x", "xy"u8), X, FriendSafari);
internal static readonly EncounterArea6XY[] SlotsY = EncounterArea6XY.GetAreas(Get("y", "xy"u8), Y, FriendSafari);
private const string tradeXY = "tradexy";
private static readonly string[][] TradeNames = Util.GetLanguageStrings8(tradeXY);

View file

@ -5,8 +5,8 @@ namespace PKHeX.Core;
internal static class Encounters7GG
{
internal static readonly EncounterArea7b[] SlotsGP = EncounterArea7b.GetAreas(Get("gp", "gg"), GP);
internal static readonly EncounterArea7b[] SlotsGE = EncounterArea7b.GetAreas(Get("ge", "gg"), GE);
internal static readonly EncounterArea7b[] SlotsGP = EncounterArea7b.GetAreas(Get("gp", "gg"u8), GP);
internal static readonly EncounterArea7b[] SlotsGE = EncounterArea7b.GetAreas(Get("ge", "gg"u8), GE);
internal static readonly EncounterStatic7b[] Encounter_GG =
{

View file

@ -9,8 +9,8 @@ namespace PKHeX.Core;
/// </summary>
internal static class Encounters7SM
{
internal static readonly EncounterArea7[] SlotsSN = EncounterArea7.GetAreas(Get("sn", "sm"), SN);
internal static readonly EncounterArea7[] SlotsMN = EncounterArea7.GetAreas(Get("mn", "sm"), MN);
internal static readonly EncounterArea7[] SlotsSN = EncounterArea7.GetAreas(Get("sn", "sm"u8), SN);
internal static readonly EncounterArea7[] SlotsMN = EncounterArea7.GetAreas(Get("mn", "sm"u8), MN);
private const string tradeSM = "tradesm";
private static readonly string[][] TradeNames = Util.GetLanguageStrings10(tradeSM);

View file

@ -9,8 +9,8 @@ namespace PKHeX.Core;
/// </summary>
internal static class Encounters7USUM
{
internal static readonly EncounterArea7[] SlotsUS = EncounterArea7.GetAreas(Get("us", "uu"), US);
internal static readonly EncounterArea7[] SlotsUM = EncounterArea7.GetAreas(Get("um", "uu"), UM);
internal static readonly EncounterArea7[] SlotsUS = EncounterArea7.GetAreas(Get("us", "uu"u8), US);
internal static readonly EncounterArea7[] SlotsUM = EncounterArea7.GetAreas(Get("um", "uu"u8), UM);
private const string tradeUSUM = "tradeusum";
private static readonly string[][] TradeNames = Util.GetLanguageStrings10(tradeUSUM);

View file

@ -11,10 +11,10 @@ namespace PKHeX.Core;
/// </summary>
internal static class Encounters8
{
public static readonly EncounterArea8[] SlotsSW_Symbol = EncounterArea8.GetAreas(Get("sw_symbol", "sw"), SW, true);
public static readonly EncounterArea8[] SlotsSH_Symbol = EncounterArea8.GetAreas(Get("sh_symbol", "sh"), SH, true);
public static readonly EncounterArea8[] SlotsSW_Hidden = EncounterArea8.GetAreas(Get("sw_hidden", "sw"), SW);
public static readonly EncounterArea8[] SlotsSH_Hidden = EncounterArea8.GetAreas(Get("sh_hidden", "sh"), SH);
public static readonly EncounterArea8[] SlotsSW_Symbol = EncounterArea8.GetAreas(Get("sw_symbol", "sw"u8), SW, true);
public static readonly EncounterArea8[] SlotsSH_Symbol = EncounterArea8.GetAreas(Get("sh_symbol", "sh"u8), SH, true);
public static readonly EncounterArea8[] SlotsSW_Hidden = EncounterArea8.GetAreas(Get("sw_hidden", "sw"u8), SW);
public static readonly EncounterArea8[] SlotsSH_Hidden = EncounterArea8.GetAreas(Get("sh_hidden", "sh"u8), SH);
public static readonly EncounterStatic8[] StaticSWSH =
{

View file

@ -6,7 +6,7 @@ namespace PKHeX.Core;
internal static class Encounters8a
{
internal static readonly EncounterArea8a[] SlotsLA = EncounterArea8a.GetAreas(Get("la", "la"));
internal static readonly EncounterArea8a[] SlotsLA = EncounterArea8a.GetAreas(Get("la", "la"u8));
private const byte M = 127; // Middle Height/Weight
private const byte A = 255; // Max Height/Weight for Alphas

View file

@ -7,10 +7,10 @@ namespace PKHeX.Core;
internal static class Encounters8b
{
private static readonly EncounterArea8b[] SlotsBD_OW = EncounterArea8b.GetAreas(Get("bd", "bs"), BD);
private static readonly EncounterArea8b[] SlotsSP_OW = EncounterArea8b.GetAreas(Get("sp", "bs"), SP);
private static readonly EncounterArea8b[] SlotsBD_UG = EncounterArea8b.GetAreas(Get("bd_underground", "bs"), BD);
private static readonly EncounterArea8b[] SlotsSP_UG = EncounterArea8b.GetAreas(Get("sp_underground", "bs"), SP);
private static readonly EncounterArea8b[] SlotsBD_OW = EncounterArea8b.GetAreas(Get("bd", "bs"u8), BD);
private static readonly EncounterArea8b[] SlotsSP_OW = EncounterArea8b.GetAreas(Get("sp", "bs"u8), SP);
private static readonly EncounterArea8b[] SlotsBD_UG = EncounterArea8b.GetAreas(Get("bd_underground", "bs"u8), BD);
private static readonly EncounterArea8b[] SlotsSP_UG = EncounterArea8b.GetAreas(Get("sp_underground", "bs"u8), SP);
internal static readonly EncounterArea8b[] SlotsBD = ArrayUtil.ConcatAll(SlotsBD_OW, SlotsBD_UG);
internal static readonly EncounterArea8b[] SlotsSP = ArrayUtil.ConcatAll(SlotsSP_OW, SlotsSP_UG);

View file

@ -10,7 +10,7 @@ namespace PKHeX.Core;
/// </summary>
internal static class Encounters9
{
internal static readonly EncounterArea9[] Slots = EncounterArea9.GetAreas(Get("wild_paldea", "sv"), SV);
internal static readonly EncounterArea9[] Slots = EncounterArea9.GetAreas(Get("wild_paldea", "sv"u8), SV);
internal static readonly EncounterStatic9[] Encounter_SV =
{

View file

@ -1,3 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
namespace PKHeX.Core;
/// <summary>
@ -8,24 +11,24 @@ internal static class EncountersGO
{
internal const int MAX_LEVEL = 50;
internal static readonly EncounterArea7g[] SlotsGO_GG = EncounterArea7g.GetArea(EncounterUtil.Get("go_lgpe", "go"));
internal static readonly EncounterArea8g[] SlotsGO = EncounterArea8g.GetArea(EncounterUtil.Get("go_home", "go"));
internal static readonly EncounterArea7g[] SlotsGO_GG = EncounterArea7g.GetArea(EncounterUtil.Get("go_lgpe", "go"u8));
internal static readonly EncounterArea8g[] SlotsGO = EncounterArea8g.GetArea(EncounterUtil.Get("go_home", "go"u8));
}
#else
public static class EncountersGO
{
internal const int MAX_LEVEL = 50;
internal static EncounterArea7g[] SlotsGO_GG = EncounterArea7g.GetArea(Get("go_lgpe", "go"));
internal static EncounterArea8g[] SlotsGO = EncounterArea8g.GetArea(Get("go_home", "go"));
internal static EncounterArea7g[] SlotsGO_GG = EncounterArea7g.GetArea(Get("go_lgpe", "go"u8));
internal static EncounterArea8g[] SlotsGO = EncounterArea8g.GetArea(Get("go_home", "go"u8));
public static void Reload()
{
SlotsGO_GG = EncounterArea7g.GetArea(Get("go_lgpe", "go"));
SlotsGO = EncounterArea8g.GetArea(Get("go_home", "go"));
SlotsGO_GG = EncounterArea7g.GetArea(Get("go_lgpe", "go"u8));
SlotsGO = EncounterArea8g.GetArea(Get("go_home", "go"u8));
}
private static BinLinkerAccessor Get(string resource, string ident)
private static BinLinkerAccessor Get([ConstantExpected] string resource, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan<byte> ident)
{
var name = $"encounter_{resource}.pkl";
var data = System.IO.File.Exists(name) ? System.IO.File.ReadAllBytes(name) : Util.GetBinaryResource(name);

View file

@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
namespace PKHeX.Core;
@ -11,21 +12,21 @@ namespace PKHeX.Core;
public sealed class EvolutionTree : EvolutionNetwork
{
public const int MaxEvolutions = 3;
public static readonly EvolutionTree Evolves1 = GetViaSpecies (PersonalTable.Y, EvolutionSet.GetArray(GetReader("g1")));
public static readonly EvolutionTree Evolves2 = GetViaSpecies (PersonalTable.C, EvolutionSet.GetArray(GetReader("g2")));
public static readonly EvolutionTree Evolves3 = GetViaSpecies (PersonalTable.RS, EvolutionSet.GetArray(GetReader("g3")));
public static readonly EvolutionTree Evolves4 = GetViaSpecies (PersonalTable.DP, EvolutionSet.GetArray(GetReader("g4")));
public static readonly EvolutionTree Evolves5 = GetViaSpecies (PersonalTable.BW, EvolutionSet.GetArray(GetReader("g5")));
public static readonly EvolutionTree Evolves6 = GetViaSpecies (PersonalTable.AO, EvolutionSet.GetArray(GetReader("g6")));
public static readonly EvolutionTree Evolves7 = GetViaPersonal(PersonalTable.USUM, EvolutionSet.GetArray(GetReader("uu")));
public static readonly EvolutionTree Evolves7b = GetViaPersonal(PersonalTable.GG, EvolutionSet.GetArray(GetReader("gg")));
public static readonly EvolutionTree Evolves8 = GetViaPersonal(PersonalTable.SWSH, EvolutionSet.GetArray(GetReader("ss")));
public static readonly EvolutionTree Evolves8a = GetViaPersonal(PersonalTable.LA, EvolutionSet.GetArray(GetReader("la"), 0));
public static readonly EvolutionTree Evolves8b = GetViaPersonal(PersonalTable.BDSP, EvolutionSet.GetArray(GetReader("bs")));
public static readonly EvolutionTree Evolves9 = GetViaPersonal(PersonalTable.SV, EvolutionSet.GetArray(GetReader("sv")));
public static readonly EvolutionTree Evolves1 = GetViaSpecies (PersonalTable.Y, EvolutionSet.GetArray(GetReader("g1", "g1"u8)));
public static readonly EvolutionTree Evolves2 = GetViaSpecies (PersonalTable.C, EvolutionSet.GetArray(GetReader("g2", "g2"u8)));
public static readonly EvolutionTree Evolves3 = GetViaSpecies (PersonalTable.RS, EvolutionSet.GetArray(GetReader("g3", "g3"u8)));
public static readonly EvolutionTree Evolves4 = GetViaSpecies (PersonalTable.DP, EvolutionSet.GetArray(GetReader("g4", "g4"u8)));
public static readonly EvolutionTree Evolves5 = GetViaSpecies (PersonalTable.BW, EvolutionSet.GetArray(GetReader("g5", "g5"u8)));
public static readonly EvolutionTree Evolves6 = GetViaSpecies (PersonalTable.AO, EvolutionSet.GetArray(GetReader("g6", "g6"u8)));
public static readonly EvolutionTree Evolves7 = GetViaPersonal(PersonalTable.USUM, EvolutionSet.GetArray(GetReader("uu", "uu"u8)));
public static readonly EvolutionTree Evolves7b = GetViaPersonal(PersonalTable.GG, EvolutionSet.GetArray(GetReader("gg", "gg"u8)));
public static readonly EvolutionTree Evolves8 = GetViaPersonal(PersonalTable.SWSH, EvolutionSet.GetArray(GetReader("ss", "ss"u8)));
public static readonly EvolutionTree Evolves8a = GetViaPersonal(PersonalTable.LA, EvolutionSet.GetArray(GetReader("la", "la"u8), 0));
public static readonly EvolutionTree Evolves8b = GetViaPersonal(PersonalTable.BDSP, EvolutionSet.GetArray(GetReader("bs", "bs"u8)));
public static readonly EvolutionTree Evolves9 = GetViaPersonal(PersonalTable.SV, EvolutionSet.GetArray(GetReader("sv", "sv"u8)));
private static ReadOnlySpan<byte> GetResource(string resource) => Util.GetBinaryResource($"evos_{resource}.pkl");
private static BinLinkerAccessor GetReader(string resource) => BinLinkerAccessor.Get(GetResource(resource), resource);
private static ReadOnlySpan<byte> GetResource([ConstantExpected] string resource) => Util.GetBinaryResource($"evos_{resource}.pkl");
private static BinLinkerAccessor GetReader([ConstantExpected] string resource, [ConstantExpected(Min = 2, Max = 2)] ReadOnlySpan<byte> identifier) => BinLinkerAccessor.Get(GetResource(resource), identifier);
private EvolutionTree(IEvolutionForward forward, IEvolutionReverse reverse) : base(forward, reverse) { }
private static EvolutionTree GetViaSpecies(IPersonalTable t, EvolutionMethod[][] entries)

View file

@ -19,7 +19,7 @@ public readonly record struct MoveLearnInfo(LearnMethod Method, LearnEnvironment
Summarize(sb, localized);
}
private void Summarize(StringBuilder sb, string localizedMethod)
private void Summarize(StringBuilder sb, ReadOnlySpan<char> localizedMethod)
{
if (Environment.IsSpecified())
sb.Append(Environment).Append('-');

View file

@ -12,7 +12,7 @@ public sealed class LearnSource3E : LearnSource3, ILearnSource<PersonalInfo3>, I
{
public static readonly LearnSource3E Instance = new();
private static readonly PersonalTable3 Personal = PersonalTable.E;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_e.pkl"), "em"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_e.pkl"), "em"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_3;
private const LearnEnvironment Game = E;
private const int Generation = 3;

View file

@ -12,7 +12,7 @@ public sealed class LearnSource3FR : LearnSource3, ILearnSource<PersonalInfo3>,
{
public static readonly LearnSource3FR Instance = new();
private static readonly PersonalTable3 Personal = PersonalTable.FR;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_fr.pkl"), "fr"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_fr.pkl"), "fr"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_3;
private const LearnEnvironment Game = FR;
private const int Generation = 3;

View file

@ -12,7 +12,7 @@ public sealed class LearnSource3LG : LearnSource3, ILearnSource<PersonalInfo3>,
{
public static readonly LearnSource3LG Instance = new();
private static readonly PersonalTable3 Personal = PersonalTable.LG;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_lg.pkl"), "lg"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_lg.pkl"), "lg"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_3;
private const LearnEnvironment Game = LG;
private const int Generation = 3;

View file

@ -12,7 +12,7 @@ public sealed class LearnSource3RS : LearnSource3, ILearnSource<PersonalInfo3>,
{
public static readonly LearnSource3RS Instance = new();
private static readonly PersonalTable3 Personal = PersonalTable.RS;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_rs.pkl"), "rs"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_rs.pkl"), "rs"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_3;
private const LearnEnvironment Game = RS;
private const int Generation = 3;

View file

@ -12,7 +12,7 @@ public sealed class LearnSource4DP : LearnSource4, ILearnSource<PersonalInfo4>,
{
public static readonly LearnSource4DP Instance = new();
private static readonly PersonalTable4 Personal = PersonalTable.DP;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_dp.pkl"), "dp"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_dp.pkl"), "dp"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_4;
private const LearnEnvironment Game = DP;
private const int Generation = 4;

View file

@ -13,8 +13,8 @@ public sealed class LearnSource4HGSS : ILearnSource<PersonalInfo4>, IEggSource
{
public static readonly LearnSource4HGSS Instance = new();
private static readonly PersonalTable4 Personal = PersonalTable.HGSS;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_hgss.pkl"), "hs"));
private static readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_hgss.pkl"), "hs"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_hgss.pkl"), "hs"u8));
private static readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_hgss.pkl"), "hs"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_4;
private const LearnEnvironment Game = HGSS;
private const int Generation = 4;

View file

@ -12,7 +12,7 @@ public sealed class LearnSource4Pt : LearnSource4, ILearnSource<PersonalInfo4>,
{
public static readonly LearnSource4Pt Instance = new();
private static readonly PersonalTable4 Personal = PersonalTable.Pt;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_pt.pkl"), "pt"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_pt.pkl"), "pt"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_4;
private const LearnEnvironment Game = Pt;
private const int Generation = 4;

View file

@ -12,7 +12,7 @@ public sealed class LearnSource5B2W2 : LearnSource5, ILearnSource<PersonalInfo5B
{
public static readonly LearnSource5B2W2 Instance = new();
private static readonly PersonalTable5B2W2 Personal = PersonalTable.B2W2;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_b2w2.pkl"), "52"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_b2w2.pkl"), "52"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_5;
private const LearnEnvironment Game = B2W2;

View file

@ -12,7 +12,7 @@ public sealed class LearnSource5BW : LearnSource5, ILearnSource<PersonalInfo5BW>
{
public static readonly LearnSource5BW Instance = new();
private static readonly PersonalTable5BW Personal = PersonalTable.BW;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_bw.pkl"), "51"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_bw.pkl"), "51"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_5;
private const LearnEnvironment Game = BW;

View file

@ -12,8 +12,8 @@ public sealed class LearnSource6AO : ILearnSource<PersonalInfo6AO>, IEggSource
{
public static readonly LearnSource6AO Instance = new();
private static readonly PersonalTable6AO Personal = PersonalTable.AO;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_ao.pkl"), "ao"));
private static readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_ao.pkl"), "ao"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_ao.pkl"), "ao"u8));
private static readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_ao.pkl"), "ao"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_6;
private const LearnEnvironment Game = ORAS;

View file

@ -12,8 +12,8 @@ public sealed class LearnSource6XY : ILearnSource<PersonalInfo6XY>, IEggSource
{
public static readonly LearnSource6XY Instance = new();
private static readonly PersonalTable6XY Personal = PersonalTable.XY;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_xy.pkl"), "xy"));
private static readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_xy.pkl"), "xy"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_xy.pkl"), "xy"u8));
private static readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_xy.pkl"), "xy"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_6;
private const LearnEnvironment Game = XY;

View file

@ -12,7 +12,7 @@ public sealed class LearnSource7GG : ILearnSource<PersonalInfo7GG>
{
public static readonly LearnSource7GG Instance = new();
private static readonly PersonalTable7GG Personal = PersonalTable.GG;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_gg.pkl"), "gg"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_gg.pkl"), "gg"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_7b;
private const LearnEnvironment Game = GG;
private const int ReminderBonus = 100; // Move reminder allows re-learning ALL level up moves regardless of level.

View file

@ -13,8 +13,8 @@ public sealed class LearnSource7SM : ILearnSource<PersonalInfo7>, IEggSource
{
public static readonly LearnSource7SM Instance = new();
private static readonly PersonalTable7 Personal = PersonalTable.SM;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_sm.pkl"), "sm"));
private static readonly EggMoves7[] EggMoves = EggMoves7.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_sm.pkl"), "sm"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_sm.pkl"), "sm"u8));
private static readonly EggMoves7[] EggMoves = EggMoves7.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_sm.pkl"), "sm"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_7;
private const LearnEnvironment Game = SM;
private const int ReminderBonus = 100; // Move reminder allows re-learning ALL level up moves regardless of level.

View file

@ -13,8 +13,8 @@ public sealed class LearnSource7USUM : ILearnSource<PersonalInfo7>, IEggSource
{
public static readonly LearnSource7USUM Instance = new();
private static readonly PersonalTable7 Personal = PersonalTable.USUM;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_uu.pkl"), "uu"));
private static readonly EggMoves7[] EggMoves = EggMoves7.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_uu.pkl"), "uu"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_uu.pkl"), "uu"u8));
private static readonly EggMoves7[] EggMoves = EggMoves7.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_uu.pkl"), "uu"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_7_USUM;
private const LearnEnvironment Game = USUM;
private const int ReminderBonus = 100; // Move reminder allows re-learning ALL level up moves regardless of level.

View file

@ -12,8 +12,8 @@ public sealed class LearnSource8BDSP : ILearnSource<PersonalInfo8BDSP>, IEggSour
{
public static readonly LearnSource8BDSP Instance = new();
private static readonly PersonalTable8BDSP Personal = PersonalTable.BDSP;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_bdsp.pkl"), "bs"));
private static readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_bdsp.pkl"), "bs"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_bdsp.pkl"), "bs"u8));
private static readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_bdsp.pkl"), "bs"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_8b;
private const LearnEnvironment Game = BDSP;

View file

@ -12,8 +12,8 @@ public sealed class LearnSource8LA : ILearnSource<PersonalInfo8LA>, IHomeSource
{
public static readonly LearnSource8LA Instance = new();
private static readonly PersonalTable8LA Personal = PersonalTable.LA;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_la.pkl"), "la"));
private static readonly Learnset[] Mastery = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("mastery_la.pkl"), "la"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_la.pkl"), "la"u8));
private static readonly Learnset[] Mastery = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("mastery_la.pkl"), "la"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_8a;
private const LearnEnvironment Game = PLA;

View file

@ -12,8 +12,8 @@ public sealed class LearnSource8SWSH : ILearnSource<PersonalInfo8SWSH>, IEggSour
{
public static readonly LearnSource8SWSH Instance = new();
private static readonly PersonalTable8SWSH Personal = PersonalTable.SWSH;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_swsh.pkl"), "ss"));
private static readonly EggMoves7[] EggMoves = EggMoves7.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_swsh.pkl"), "ss"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_swsh.pkl"), "ss"u8));
private static readonly EggMoves7[] EggMoves = EggMoves7.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_swsh.pkl"), "ss"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_8_R2;
private const LearnEnvironment Game = SWSH;

View file

@ -12,9 +12,9 @@ public sealed class LearnSource9SV : ILearnSource<PersonalInfo9SV>, IEggSource,
{
public static readonly LearnSource9SV Instance = new();
private static readonly PersonalTable9SV Personal = PersonalTable.SV;
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_sv.pkl"), "sv"));
private static readonly ushort[][] EggMoves = EggMoves9.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_sv.pkl"), "sv"));
private static readonly ushort[][] Reminder = EggMoves9.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("reminder_sv.pkl"), "sv"));
private static readonly Learnset[] Learnsets = LearnsetReader.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("lvlmove_sv.pkl"), "sv"u8));
private static readonly ushort[][] EggMoves = EggMoves9.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_sv.pkl"), "sv"u8));
private static readonly ushort[][] Reminder = EggMoves9.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("reminder_sv.pkl"), "sv"u8));
private const int MaxSpecies = Legal.MaxSpeciesID_9;
private const LearnEnvironment Game = SV;

View file

@ -4,7 +4,7 @@ namespace PKHeX.Core;
public abstract class LearnSource3
{
private protected readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_rs.pkl"), "rs")); // same for all Gen3 games
private protected readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_rs.pkl"), "rs"u8)); // same for all Gen3 games
internal static ReadOnlySpan<ushort> TM_3 => new ushort[]
{

View file

@ -4,7 +4,7 @@ namespace PKHeX.Core;
public abstract class LearnSource4
{
private protected static readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_dppt.pkl"), "dp"));
private protected static readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_dppt.pkl"), "dp"u8));
/// <summary>
/// Gets the preferred list of HM moves to disallow on transfer from <see cref="PK4"/> to <see cref="PK5"/>.

View file

@ -4,7 +4,7 @@ namespace PKHeX.Core;
public abstract class LearnSource5
{
private protected readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_bw.pkl"), "bw"));
private protected readonly EggMoves6[] EggMoves = EggMoves6.GetArray(BinLinkerAccessor.Get(Util.GetBinaryResource("eggmove_bw.pkl"), "bw"u8));
internal static ReadOnlySpan<ushort> TMHM_BW => new ushort[]
{

View file

@ -131,8 +131,8 @@ public static class PersonalTable
private static void PopulateGen3Tutors()
{
// Update Gen3 data with Emerald's data, FR/LG is a subset of Emerald's compatibility.
var machine = BinLinkerAccessor.Get(Util.GetBinaryResource("hmtm_g3.pkl"), "g3");
var tutors = BinLinkerAccessor.Get(Util.GetBinaryResource("tutors_g3.pkl"), "g3");
var machine = BinLinkerAccessor.Get(Util.GetBinaryResource("hmtm_g3.pkl"), "g3"u8);
var tutors = BinLinkerAccessor.Get(Util.GetBinaryResource("tutors_g3.pkl"), "g3"u8);
E.LoadTables(machine, tutors);
FR.CopyTables(E);
LG.CopyTables(E);
@ -141,7 +141,7 @@ public static class PersonalTable
private static void PopulateGen4Tutors()
{
var tutors = BinLinkerAccessor.Get(Util.GetBinaryResource("tutors_g4.pkl"), "g4");
var tutors = BinLinkerAccessor.Get(Util.GetBinaryResource("tutors_g4.pkl"), "g4"u8);
HGSS.LoadTables(tutors);
}
}

View file

@ -134,7 +134,7 @@ public static class PokedexConstants8a
88, 279, 89, 280, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
};
public static readonly PokedexResearchTask8a[][] ResearchTasks = DeserializeResearchTasks(BinLinkerAccessor.Get(Util.GetBinaryResource("researchtask_la.pkl"), "la"));
public static readonly PokedexResearchTask8a[][] ResearchTasks = DeserializeResearchTasks(BinLinkerAccessor.Get(Util.GetBinaryResource("researchtask_la.pkl"), "la"u8));
private static PokedexResearchTask8a[][] DeserializeResearchTasks(BinLinkerAccessor accessor)
{

View file

@ -4,7 +4,7 @@ using static System.Buffers.Binary.BinaryPrimitives;
namespace PKHeX.Core;
/// <summary>
/// Logic for recognizing .dsv save files from DeSmuME.
/// Logic for recognizing .dsv save files from BizHawk.
/// </summary>
public sealed class SaveHandlerBizHawk : ISaveHandler
{