Fix GetLowestLevel underflow condition

Check end before decrement

Closes #3605 thanks @InfoManiac742 !
This commit is contained in:
Kurt 2022-10-14 17:05:19 -07:00
parent b2f5bd5bd6
commit 8b0e93b42f

View file

@ -103,14 +103,17 @@ public static class EncounterSuggestion
var table = EvolutionTree.GetEvolutionTree(pk.Context);
int count = 1;
for (byte i = 100; i >= startLevel; i--)
byte i = 100;
while (true)
{
var evos = table.GetValidPreEvolutions(pk, levelMax: i, skipChecks: true, levelMin: startLevel);
if (evos.Length < count) // lost an evolution, prior level was minimum current level
return GetMaxLevelMax(evos) + 1;
count = evos.Length;
if (i == startLevel)
return startLevel;
--i;
}
return startLevel;
}
private static int GetMaxLevelMax(EvoCriteria[] evos)