From 6d70495cf298e996a1eada21e4fc187c187b985f Mon Sep 17 00:00:00 2001 From: Shawrkie Williams Date: Mon, 22 Dec 2025 13:38:32 -0500 Subject: [PATCH] Separate HQ/NQ items during aggregation --- AetherBags/Inventory/InventoryState.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/AetherBags/Inventory/InventoryState.cs b/AetherBags/Inventory/InventoryState.cs index be76a3a..9a7d49b 100644 --- a/AetherBags/Inventory/InventoryState.cs +++ b/AetherBags/Inventory/InventoryState.cs @@ -60,12 +60,17 @@ public static unsafe class InventoryState private const uint UserCategoryKeyFlag = 0x8000_0000; + private const ulong AggregatedKeyTag = 1UL << 63; + private static uint MakeUserCategoryKey(int order) => UserCategoryKeyFlag | (uint)(order & 0x7FFF_FFFF); private static bool IsUserCategoryKey(uint key) => (key & UserCategoryKeyFlag) != 0; + private static ulong MakeAggregatedItemKey(uint itemId, bool isHighQuality) + => AggregatedKeyTag | ((ulong)itemId << 1) | (isHighQuality ? 1UL : 0UL); + public static bool Contains(this IReadOnlyCollection inventoryTypes, GameInventoryType type) => inventoryTypes.Contains((InventoryType)type); @@ -128,9 +133,10 @@ public static unsafe class InventoryState nonEmptySlots++; int quantity = item.Quantity; + bool isHq = (item.Flags & InventoryItem.ItemFlags.HighQuality) != 0; ulong key = stackMode == InventoryStackMode.AggregateByItemId - ? id + ? MakeAggregatedItemKey(id, isHq) : MakeNaturalSlotKey(inventoryType, slot); Services.Logger.DebugOnly($"Slot {inventoryType}[{slot}] ItemId={id} Qty={quantity} Key=0x{key:X16}");