2
0
Fork 0
mirror of https://github.com/kwsch/PKHeX synced 2025-03-09 09:47:29 +00:00

Change signature to set stackalloc ivs

This commit is contained in:
Kurt 2022-04-08 20:43:31 -07:00
parent d40bfa63c7
commit 274b613487
2 changed files with 15 additions and 8 deletions
PKHeX.Core/Saves/Substructures/Gen3
PKHeX.WinForms/Subforms/Save Editors/Gen3

View file

@ -76,12 +76,19 @@ namespace PKHeX.Core
public int[] IVs public int[] IVs
{ {
get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD };
set set => SetIVs(value);
{ }
if (value.Length != 6) return;
IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2]; public void SetIVs(ReadOnlySpan<int> value)
IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5]; {
} if (value.Length != 6)
return;
IV_HP = value[0];
IV_ATK = value[1];
IV_DEF = value[2];
IV_SPE = value[3];
IV_SPA = value[4];
IV_SPD = value[5];
} }
/// <summary> /// <summary>

View file

@ -38,14 +38,14 @@ namespace PKHeX.WinForms
private void SaveData() private void SaveData()
{ {
int[] IVs = new int[6]; Span<int> IVs = stackalloc int[6];
var iv = new[] { TB_HPIV, TB_ATKIV, TB_DEFIV, TB_SPEIV, TB_SPAIV, TB_SPDIV }; var iv = new[] { TB_HPIV, TB_ATKIV, TB_DEFIV, TB_SPEIV, TB_SPAIV, TB_SPDIV };
for (int i = 0; i < iv.Length; i++) for (int i = 0; i < iv.Length; i++)
IVs[i] = Util.ToInt32(iv[i].Text); IVs[i] = Util.ToInt32(iv[i].Text);
Reader.PID = Util.GetHexValue(TB_PID.Text); Reader.PID = Util.GetHexValue(TB_PID.Text);
Reader.Species = WinFormsUtil.GetIndex(CB_Species); Reader.Species = WinFormsUtil.GetIndex(CB_Species);
Reader.IVs = IVs; Reader.SetIVs(IVs);
Reader.Active = CHK_Active.Checked; Reader.Active = CHK_Active.Checked;
Reader.CurrentLevel = (int)NUD_Level.Value; Reader.CurrentLevel = (int)NUD_Level.Value;
} }