Add Check for Bad Ability Length

Prevents System.ArgumentOutOfRangeException: StartIndex cannot be less
than zero.
This commit is contained in:
ReignOfComputer 2017-02-05 23:23:02 +08:00
parent 930d1d12c9
commit 2de7da80b0
4 changed files with 23 additions and 7 deletions

View file

@ -142,7 +142,11 @@ namespace PKHeX.WinForms
pk4.SID = Util.ToInt32(TB_SID.Text);
pk4.EXP = Util.ToUInt32(TB_EXP.Text);
pk4.PID = Util.getHEXval(TB_PID.Text);
pk4.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
if (CB_Ability.Text.Length >= 4)
{
pk4.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
}
pk4.FatefulEncounter = CHK_Fateful.Checked;
pk4.Gender = PKX.getGender(Label_Gender.Text);

View file

@ -247,8 +247,11 @@ namespace PKHeX.WinForms
}
else
{
pk5.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk5.HiddenAbility = CB_Ability.SelectedIndex > 1; // not 0 or 1
if (CB_Ability.Text.Length >= 4)
{
pk5.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk5.HiddenAbility = CB_Ability.SelectedIndex > 1; // not 0 or 1
}
}
// Fix Moves if a slot is empty

View file

@ -184,8 +184,13 @@ namespace PKHeX.WinForms
pk6.TID = Util.ToInt32(TB_TID.Text);
pk6.SID = Util.ToInt32(TB_SID.Text);
pk6.EXP = Util.ToUInt32(TB_EXP.Text);
pk6.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk6.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text); // Number
if (CB_Ability.Text.Length >= 4)
{
pk6.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk6.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text); // Number
}
// pkx[0x16], pkx[0x17] are handled by the Medals UI (Hits & Training Bag)
pk6.PID = Util.getHEXval(TB_PID.Text);
pk6.Nature = (byte)WinFormsUtil.getIndex(CB_Nature);

View file

@ -184,8 +184,12 @@ namespace PKHeX.WinForms
pk7.TID = Util.ToInt32(TB_TID.Text);
pk7.SID = Util.ToInt32(TB_SID.Text);
pk7.EXP = Util.ToUInt32(TB_EXP.Text);
pk7.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk7.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text); // Number
{
pk7.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk7.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text); // Number
}
// pkx[0x16], pkx[0x17] are handled by the Medals UI (Hits & Training Bag)
pk7.PID = Util.getHEXval(TB_PID.Text);
pk7.Nature = (byte)WinFormsUtil.getIndex(CB_Nature);