Fix GameInventoryItem array initialization (#2222)

This commit is contained in:
Haselnussbomber 2025-03-28 19:32:23 +01:00 committed by GitHub
parent baf796f5e1
commit 0d9eca1877
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;