mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-04-24 23:57:12 -05:00
Fix GetLowestLevel underflow condition
Check end before decrement Closes #3605 thanks @InfoManiac742 !
This commit is contained in:
parent
b2f5bd5bd6
commit
8b0e93b42f
|
|
@ -103,14 +103,17 @@ public static int GetLowestLevel(PKM pk, byte startLevel)
|
|||
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user