Merge pull request #8 from Seeker1437/feature/item-uniqueness
Separate HQ/NQ items during aggregation
This commit is contained in:
@@ -60,12 +60,17 @@ public static unsafe class InventoryState
|
|||||||
|
|
||||||
private const uint UserCategoryKeyFlag = 0x8000_0000;
|
private const uint UserCategoryKeyFlag = 0x8000_0000;
|
||||||
|
|
||||||
|
private const ulong AggregatedKeyTag = 1UL << 63;
|
||||||
|
|
||||||
private static uint MakeUserCategoryKey(int order)
|
private static uint MakeUserCategoryKey(int order)
|
||||||
=> UserCategoryKeyFlag | (uint)(order & 0x7FFF_FFFF);
|
=> UserCategoryKeyFlag | (uint)(order & 0x7FFF_FFFF);
|
||||||
|
|
||||||
private static bool IsUserCategoryKey(uint key)
|
private static bool IsUserCategoryKey(uint key)
|
||||||
=> (key & UserCategoryKeyFlag) != 0;
|
=> (key & UserCategoryKeyFlag) != 0;
|
||||||
|
|
||||||
|
private static ulong MakeAggregatedItemKey(uint itemId, bool isHighQuality)
|
||||||
|
=> AggregatedKeyTag | ((ulong)itemId << 1) | (isHighQuality ? 1UL : 0UL);
|
||||||
|
|
||||||
public static bool Contains(this IReadOnlyCollection<InventoryType> inventoryTypes, GameInventoryType type)
|
public static bool Contains(this IReadOnlyCollection<InventoryType> inventoryTypes, GameInventoryType type)
|
||||||
=> inventoryTypes.Contains((InventoryType)type);
|
=> inventoryTypes.Contains((InventoryType)type);
|
||||||
|
|
||||||
@@ -128,9 +133,10 @@ public static unsafe class InventoryState
|
|||||||
nonEmptySlots++;
|
nonEmptySlots++;
|
||||||
|
|
||||||
int quantity = item.Quantity;
|
int quantity = item.Quantity;
|
||||||
|
bool isHq = (item.Flags & InventoryItem.ItemFlags.HighQuality) != 0;
|
||||||
|
|
||||||
ulong key = stackMode == InventoryStackMode.AggregateByItemId
|
ulong key = stackMode == InventoryStackMode.AggregateByItemId
|
||||||
? id
|
? MakeAggregatedItemKey(id, isHq)
|
||||||
: MakeNaturalSlotKey(inventoryType, slot);
|
: MakeNaturalSlotKey(inventoryType, slot);
|
||||||
|
|
||||||
Services.Logger.DebugOnly($"Slot {inventoryType}[{slot}] ItemId={id} Qty={quantity} Key=0x{key:X16}");
|
Services.Logger.DebugOnly($"Slot {inventoryType}[{slot}] ItemId={id} Qty={quantity} Key=0x{key:X16}");
|
||||||
|
|||||||
Reference in New Issue
Block a user