From b483b63bf2d82327580c6e5f0c784a7fae7db897 Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Thu, 14 Nov 2024 15:34:56 -0800 Subject: [PATCH] GameInventoryItem matches StructSize from CS --- Dalamud/Game/Inventory/GameInventoryItem.cs | 20 +++++--------------- lib/FFXIVClientStructs | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Dalamud/Game/Inventory/GameInventoryItem.cs b/Dalamud/Game/Inventory/GameInventoryItem.cs index 145ddf841..fb27346e0 100644 --- a/Dalamud/Game/Inventory/GameInventoryItem.cs +++ b/Dalamud/Game/Inventory/GameInventoryItem.cs @@ -9,7 +9,7 @@ namespace Dalamud.Game.Inventory; /// /// Dalamud wrapper around a ClientStructs InventoryItem. /// -[StructLayout(LayoutKind.Explicit, Size = StructSizeInBytes)] +[StructLayout(LayoutKind.Explicit, Size = InventoryItem.StructSize)] public unsafe struct GameInventoryItem : IEquatable { /// @@ -17,22 +17,12 @@ public unsafe struct GameInventoryItem : IEquatable /// [FieldOffset(0)] internal readonly InventoryItem InternalItem; - - private const int StructSizeInBytes = 0x48; - + /// /// The view of the backing data, in . /// [FieldOffset(0)] - private fixed ulong dataUInt64[StructSizeInBytes / 0x8]; - - static GameInventoryItem() - { - Debug.Assert( - sizeof(InventoryItem) == StructSizeInBytes, - $"Definition of {nameof(InventoryItem)} has been changed. " + - $"Update {nameof(StructSizeInBytes)} to {sizeof(InventoryItem)} to accommodate for the size change."); - } + private fixed ulong dataUInt64[InventoryItem.StructSize / 0x8]; /// /// Initializes a new instance of the struct. @@ -157,7 +147,7 @@ public unsafe struct GameInventoryItem : IEquatable /// true if the current object is equal to the parameter; otherwise, false. public readonly bool Equals(in GameInventoryItem other) { - for (var i = 0; i < StructSizeInBytes / 8; i++) + for (var i = 0; i < InventoryItem.StructSize / 8; i++) { if (this.dataUInt64[i] != other.dataUInt64[i]) return false; @@ -173,7 +163,7 @@ public unsafe struct GameInventoryItem : IEquatable public override int GetHashCode() { var k = 0x5a8447b91aff51b4UL; - for (var i = 0; i < StructSizeInBytes / 8; i++) + for (var i = 0; i < InventoryItem.StructSize / 8; i++) k ^= this.dataUInt64[i]; return unchecked((int)(k ^ (k >> 32))); } diff --git a/lib/FFXIVClientStructs b/lib/FFXIVClientStructs index 6cc4f1c12..81ea903b7 160000 --- a/lib/FFXIVClientStructs +++ b/lib/FFXIVClientStructs @@ -1 +1 @@ -Subproject commit 6cc4f1c12c37785101a262cceac249753db3b1f5 +Subproject commit 81ea903b7dc90bd07a38703738fa7f84b1ed0775