mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-03-21 17:48:28 -05:00
Add sanity check for enc gender request
If you set criteria to Male, and request to generate a Nidoran-F wild encounter, ofc the program will loop forever. Oftentimes, users won't be looking at the criteria tab, and can stumble upon this accidentally. Prevent the freeze entirely by just sanity checking and discarding the user's input if it is impossible.
This commit is contained in:
parent
f382291de4
commit
b6eb0745a3
|
|
@ -85,6 +85,15 @@ public static byte GetGenderRatio(ushort species)
|
|||
return NG;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the species (base form) is a single gender.
|
||||
/// </summary>
|
||||
public static bool IsSingleGender(ushort species)
|
||||
{
|
||||
var ratio = GetGenderRatio(species);
|
||||
return ratio is OM or OF or NG;
|
||||
}
|
||||
|
||||
private static ReadOnlySpan<byte> GenderRatios =>
|
||||
[
|
||||
NG, VM, VM, VM, VM, VM, VM, VM, VM, VM, HH, HH, HH, HH, HH, HH, HH, HH, HH, HH, HH, HH, HH, HH, HH, HH, HH, HH, HH, OF, OF, OF, OM, OM, OM, MF, MF, MF, MF, MF,
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ private EncounterCriteria GetCriteria(IEncounterTemplate enc, EncounterDatabaseS
|
|||
}
|
||||
|
||||
var criteria = _criteriaValue;
|
||||
if (!isInChain)
|
||||
if (!isInChain || EntityGender.IsSingleGender(enc.Species))
|
||||
criteria = criteria with { Gender = Gender.Random }; // Genderless tabs and a gendered enc -> let's play safe.
|
||||
return criteria;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user