mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
Fix GetLowestLevel underflow condition
Check end before decrement Closes #3605 thanks @InfoManiac742 !
This commit is contained in:
parent
b2f5bd5bd6
commit
8b0e93b42f
1 changed files with 5 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetMaxLevelMax(EvoCriteria[] evos)
|
||||
|
|
Loading…
Reference in a new issue