diff --git a/Dalamud/Game/Inventory/GameInventory.cs b/Dalamud/Game/Inventory/GameInventory.cs index 27f14bf79..5c8ed27b0 100644 --- a/Dalamud/Game/Inventory/GameInventory.cs +++ b/Dalamud/Game/Inventory/GameInventory.cs @@ -120,9 +120,7 @@ internal class GameInventory : IInternalDisposableService continue; // Assumption: newItems is sorted by slots, and the last item has the highest slot number. - var oldItems = this.inventoryItems[i] ??= new GameInventoryItem[newItems[^1].InternalItem.Slot + 1]; - if (this.inventoryItems[i] == null) - oldItems.Initialize(); + var oldItems = this.inventoryItems[i] ??= this.CreateItemsArray(newItems[^1].InternalItem.Slot + 1); foreach (ref readonly var newItem in newItems) { @@ -314,6 +312,13 @@ internal class GameInventory : IInternalDisposableService this.mergedEvents.Clear(); } + private GameInventoryItem[] CreateItemsArray(int length) + { + var items = new GameInventoryItem[length]; + items.Initialize(); + return items; + } + private unsafe void RaptureAtkModuleUpdateDetour(RaptureAtkModule* ram, float f1) { this.inventoriesMightBeChanged |= ram->AgentUpdateFlag != 0;