2
0
Fork 0
mirror of https://github.com/kwsch/PKHeX synced 2025-01-30 21:23:30 +00:00

Handle self-form pointer

Logic is much more clear now.
This commit is contained in:
Kurt 2024-01-04 00:00:34 -08:00
parent b15211ce1b
commit 528d927a85

View file

@ -137,14 +137,19 @@ internal static class EggMovesExtensions
if (species > baseIndex)
return [];
if (form == 0)
if (form == 0 || baseIndex == species) // no form data if pointing to self
return entry.Moves;
// Jump to the associated form's entry within the table.
return table.GetFormEntry(form, baseIndex);
}
private static ReadOnlySpan<ushort> GetFormEntry(this EggMoves7[] table, byte form, ushort baseIndex)
{
var index = form - 1u + baseIndex;
if (index >= table.Length)
return [];
entry = table[index];
var entry = table[index];
// Double-check that the entry is still associated to the species.
if (entry.FormTableIndex != baseIndex)