diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan7.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan7.cs index de00fc09c..1de9d665c 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan7.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan7.cs @@ -197,12 +197,13 @@ public int GetDexFormIndex(int spec, int fc, int f) public IList GetEntryNames(IReadOnlyList Species) { var names = new List(); - for (int i = 1; i <= SAV.MaxSpeciesID; i++) + var max = SAV.MaxSpeciesID; + for (int i = 1; i <= max; i++) names.Add($"{i:000} - {Species[i]}"); // Add Formes - int ctr = SAV.MaxSpeciesID; - for (int spec = 1; spec <= SAV.MaxSpeciesID; spec++) + int ctr = max + 1; + for (int spec = 1; spec <= max; spec++) { int c = SAV.Personal[spec].FormeCount; for (int f = 1; f < c; f++) diff --git a/PKHeX.Core/Saves/Util/DexFormUtil.cs b/PKHeX.Core/Saves/Util/DexFormUtil.cs index 6d86f722e..07a144853 100644 --- a/PKHeX.Core/Saves/Util/DexFormUtil.cs +++ b/PKHeX.Core/Saves/Util/DexFormUtil.cs @@ -97,19 +97,16 @@ public static class DexFormUtil private static int GetDexFormBitIndex(int species, int formct, int start, IReadOnlyList formtable) { int formindex = start; - int f = 0; for (int i = 0; i < formtable.Count; i += 2) { int s = formtable[i]; - f = formtable[i + 1]; + int f = formtable[i + 1]; if (s == species) - break; + return f > formct ? -1 : formindex; formindex += f - 1; } - if (f > formct) - return -1; - return formindex; + return -1; } private static int GetDexFormCount(int species, IReadOnlyList formtable) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs index b00bb7ed8..00f2c8df2 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_PokedexSM.cs @@ -152,8 +152,9 @@ private bool FillLBForms() if (f < 0) return true; // bit index valid - if (f > fspecies - LB_Forms.Items.Count - 1) - LB_Forms.SelectedIndex = fspecies - f - 1; + var findex = fspecies - f - 1; + if (findex < LB_Forms.Items.Count) + LB_Forms.SelectedIndex = findex; else LB_Forms.SelectedIndex = -1; }