From fc4ba1df3558eef22680218adc8edf0dbb3713ef Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 21 Jun 2020 18:16:18 -0500 Subject: [PATCH] Bounds check ability requested no longer exception's on RefreshAbility(negative number) --- PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs | 2 +- PKHeX.Core/PKM/PKM.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs b/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs index 517765bad..976ca3ac6 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/EncounterCriteria.cs @@ -85,7 +85,7 @@ public int GetGender(int gender, PersonalInfo pkPersonalInfo) public int GetAbility(int abilityType, PersonalInfo pkPersonalInfo) { - if (abilityType < 3) + if ((uint)abilityType < 3) return abilityType; var abils = pkPersonalInfo.Abilities; diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index 2a4c6e0b6..7b1637501 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -756,7 +756,7 @@ public void RefreshAbility(int n) { AbilityNumber = 1 << n; int[] abilities = PersonalInfo.Abilities; - if (n < abilities.Length) + if ((uint)n < abilities.Length) { if (abilities[n] == abilities[0]) n = 0;