Add early exit for not-enough-species

#204 item 4
This commit is contained in:
Kurt
2017-10-08 11:23:20 -07:00
parent 5d16898597
commit ff18098808

View File

@@ -83,7 +83,16 @@ public int GetRandomSpecies(int oldSpecies)
loopctr = 0; // altering calculations to prevent infinite loops
int newSpecies;
while (!GetNewSpecies(oldSpecies, oldpkm, out newSpecies))
{
if (loopctr > 0x0001_0000)
{
PersonalInfo pkm = SpeciesStat[newSpecies];
if (IsSpeciesBSTBad(oldpkm, pkm) && loopctr > 0x0001_1000) // keep trying for at minimum BST
continue;
return newSpecies; // failed to find any match based on criteria, return random species that may or may not match criteria
}
loopctr++;
}
return newSpecies;
}