From ba9d3c95af048cc81be488fb80dca3b5b95c0d15 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 6 Mar 2022 15:33:33 -0800 Subject: [PATCH] Fix bean get/set --- .../Saves/Substructures/Gen7/ResortSave7.cs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/PKHeX.Core/Saves/Substructures/Gen7/ResortSave7.cs b/PKHeX.Core/Saves/Substructures/Gen7/ResortSave7.cs index 4ec3b56b6..072a6e0df 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/ResortSave7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/ResortSave7.cs @@ -33,25 +33,17 @@ public PKM[] ResortPKM } public const int BEANS_MAX = 14; + public Span GetBeans() => Data.AsSpan(Offset + 0x564C, BEANS_MAX); - public int GetPokebeanCount(int bean_id) - { - if ((uint)bean_id > 14) - throw new ArgumentOutOfRangeException(nameof(bean_id)); - return Data[Offset + 0x564C + bean_id]; - } - - public Span GetBeans() => Data.AsSpan(Offset, BEANS_MAX); + public int GetPokebeanCount(int bean_id) => GetBeans()[bean_id]; public void SetPokebeanCount(int bean_id, int count) { - if ((uint)bean_id > 14) - throw new ArgumentOutOfRangeException(nameof(bean_id)); if (count < 0) count = 0; if (count > 255) count = 255; - Data[Offset + 0x564C + bean_id] = (byte)count; + GetBeans()[bean_id] = (byte)count; } } -} \ No newline at end of file +}