From e2bafab3c222f68ef07f39d5e47dabeb5ea159b9 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 4 Feb 2022 22:18:57 -0800 Subject: [PATCH] Clamp pouch inventory per satchel size Closes #3384 --- PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs | 5 ++++- PKHeX.Core/Saves/Substructures/Inventory/InventoryPouch8a.cs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs b/PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs index 5b2f7b74a..39ff92a08 100644 --- a/PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs +++ b/PKHeX.Core/Saves/Substructures/Gen8/LA/MyItem8a.cs @@ -18,7 +18,10 @@ public override IReadOnlyList Inventory get { var access = ((SAV8LA)SAV).Accessor; - var regular = new InventoryPouch8a(InventoryType.Items, Legal.Pouch_Items_LA , 999, 675); + var satchel = (uint)access.GetBlock(SaveBlockAccessor8LA.KSatchelUpgrades).GetValue(); + var regularSize = (int)Math.Min(675, satchel); + + var regular = new InventoryPouch8a(InventoryType.Items, Legal.Pouch_Items_LA , 999, regularSize); var key = new InventoryPouch8a(InventoryType.KeyItems, Legal.Pouch_Key_LA , 1, 100); var stored = new InventoryPouch8a(InventoryType.PCItems, Legal.Pouch_Items_LA , 999, 180); var recipe = new InventoryPouch8a(InventoryType.Treasure, Legal.Pouch_Recipe_LA, 1, 70); diff --git a/PKHeX.Core/Saves/Substructures/Inventory/InventoryPouch8a.cs b/PKHeX.Core/Saves/Substructures/Inventory/InventoryPouch8a.cs index 42683c3b3..285228ac2 100644 --- a/PKHeX.Core/Saves/Substructures/Inventory/InventoryPouch8a.cs +++ b/PKHeX.Core/Saves/Substructures/Inventory/InventoryPouch8a.cs @@ -22,8 +22,8 @@ public override void GetPouch(ReadOnlySpan data) { var items = new InventoryItem8a[MaxSize]; - for (int i = 0; i < data.Length; i += 4) - items[i/4] = GetItem(data, i); + for (int i = 0; i < items.Length; i++) + items[i] = GetItem(data, i << 2); Items = items; }