Update go pickles, add fr bdsp chatot goof

Nintendo + ILCA = no nicknames allowed ;)
While we're here, streamline Gen4/5 evo pickles too -- trim out unused bytes, no longer need to scan for array length (perf). Adjust method IDs for gen4 so we can use the same code for gen4 & gen5.
This commit is contained in:
Kurt
2023-07-09 19:59:37 -07:00
parent 26cabd022b
commit 7fb5dc2fde
8 changed files with 16 additions and 93 deletions

View File

@@ -1,66 +0,0 @@
using System;
using static System.Buffers.Binary.BinaryPrimitives;
namespace PKHeX.Core;
/// <summary>
/// Generation 4 Evolution Branch Entries
/// </summary>
public static class EvolutionSet4
{
private static EvolutionMethod GetMethod(ReadOnlySpan<byte> data)
{
var method = data[0]; // other byte unnecessary
var arg = ReadUInt16LittleEndian(data[2..]);
var species = ReadUInt16LittleEndian(data[4..]);
if (method == 0)
throw new ArgumentOutOfRangeException(nameof(method));
// To have the same structure as gen 6
// Gen 4 Method 6 is Gen 6 Method 7, G4 7 = G6 8, and so on
if (method > 6)
method++;
var lvl = EvolutionSet6.IsMethodWithArg(method) ? 0 : arg;
var type = (EvolutionType)method;
var lvlup = type.IsLevelUpRequired() ? (byte)1 : (byte)0;
return new EvolutionMethod(type, species, Argument: arg, Level: (byte)lvl, LevelUp: lvlup);
}
private const int bpe = 6; // bytes per evolution entry
private const int entries = 7; // amount of entries per species
private const int size = (entries * bpe) + 2; // bytes per species entry, + 2 alignment bytes
public static EvolutionMethod[][] GetArray(ReadOnlySpan<byte> data)
{
var result = new EvolutionMethod[data.Length / size][];
for (int i = 0, offset = 0; i < result.Length; i++, offset += size)
result[i] = GetEntry(data.Slice(offset, size));
return result;
}
private static EvolutionMethod[] GetEntry(ReadOnlySpan<byte> data)
{
int count = ScanCountEvolutions(data);
if (count == 0)
return Array.Empty<EvolutionMethod>();
var result = new EvolutionMethod[count];
for (int i = 0, offset = 0; i < result.Length; i++, offset += bpe)
result[i] = GetMethod(data.Slice(offset, bpe));
return result;
}
private static int ScanCountEvolutions(ReadOnlySpan<byte> data)
{
for (int count = 0; count < entries; count++)
{
var methodOffset = count * bpe;
var method = data[methodOffset];
if (method == 0)
return count;
}
return entries;
}
}

View File

@@ -13,10 +13,6 @@ private static EvolutionMethod GetMethod(ReadOnlySpan<byte> data)
var method = data[0]; // other byte unnecessary
var arg = ReadUInt16LittleEndian(data[2..]);
var species = ReadUInt16LittleEndian(data[4..]);
if (method == 0)
throw new ArgumentOutOfRangeException(nameof(method));
var lvl = EvolutionSet6.IsMethodWithArg(method) ? 0 : arg;
var type = (EvolutionType)method;
var lvlup = type.IsLevelUpRequired() ? (byte)1 : (byte)0;
@@ -24,38 +20,23 @@ private static EvolutionMethod GetMethod(ReadOnlySpan<byte> data)
}
private const int bpe = 6; // bytes per evolution entry
private const int entries = 7; // amount of entries per species
private const int size = entries * bpe; // bytes per species entry
public static EvolutionMethod[][] GetArray(ReadOnlySpan<byte> data)
public static EvolutionMethod[][] GetArray(BinLinkerAccessor data)
{
var result = new EvolutionMethod[data.Length / size][];
for (int i = 0, offset = 0; i < result.Length; i++, offset += size)
result[i] = GetEntry(data.Slice(offset, size));
var result = new EvolutionMethod[data.Length][];
for (int i = 0; i < result.Length; i++)
result[i] = GetEntry(data[i]);
return result;
}
private static EvolutionMethod[] GetEntry(ReadOnlySpan<byte> data)
{
var count = ScanCountEvolutions(data);
if (count == 0)
if (data.Length == 0)
return Array.Empty<EvolutionMethod>();
var result = new EvolutionMethod[count];
var result = new EvolutionMethod[data.Length / bpe];
for (int i = 0, offset = 0; i < result.Length; i++, offset += bpe)
result[i] = GetMethod(data.Slice(offset, bpe));
return result;
}
private static int ScanCountEvolutions(ReadOnlySpan<byte> data)
{
for (int count = 0; count < entries; count++)
{
var methodOffset = count * bpe;
var method = data[methodOffset];
if (method == 0)
return count;
}
return entries;
}
}

View File

@@ -14,8 +14,8 @@ public sealed class EvolutionTree : EvolutionNetwork
public static readonly EvolutionTree Evolves1 = GetViaSpecies (PersonalTable.Y, EvolutionSet1.GetArray(GetResource("rby"), 151));
public static readonly EvolutionTree Evolves2 = GetViaSpecies (PersonalTable.C, EvolutionSet1.GetArray(GetResource("gsc"), 251));
public static readonly EvolutionTree Evolves3 = GetViaSpecies (PersonalTable.RS, EvolutionSet3.GetArray(GetResource("g3")));
public static readonly EvolutionTree Evolves4 = GetViaSpecies (PersonalTable.DP, EvolutionSet4.GetArray(GetResource("g4")));
public static readonly EvolutionTree Evolves5 = GetViaSpecies (PersonalTable.BW, EvolutionSet5.GetArray(GetResource("g5")));
public static readonly EvolutionTree Evolves4 = GetViaSpecies (PersonalTable.DP, EvolutionSet5.GetArray(GetReader("g4")));
public static readonly EvolutionTree Evolves5 = GetViaSpecies (PersonalTable.BW, EvolutionSet5.GetArray(GetReader("g5")));
public static readonly EvolutionTree Evolves6 = GetViaSpecies (PersonalTable.AO, EvolutionSet6.GetArray(GetReader("ao")));
public static readonly EvolutionTree Evolves7 = GetViaPersonal(PersonalTable.USUM, EvolutionSet7.GetArray(GetReader("uu")));
public static readonly EvolutionTree Evolves7b = GetViaPersonal(PersonalTable.GG, EvolutionSet7.GetArray(GetReader("gg")));

View File

@@ -412,6 +412,14 @@ private static void VerifyTrade8b(LegalityAnalysis data, EncounterTrade8b t)
if (lang == 0) // err
data.AddLine(GetInvalid(string.Format(LOTLanguage, $"{Japanese}/{German}", $"{(LanguageID)pk.Language}"), CheckIdentifier.Language));
}
if (t.Species == (int)Species.Chatot && pk.Language == (int)French)
{
// NgWord disallows the French nickname (Pijouk) and resets it back to default (Pijako).
// Let it be anything (Nicknamed or not) and just verify the OT.
VerifyTradeOTOnly(data, t);
return;
}
VerifyTrade(data, t, lang);
}