mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
GameInventoryItem matches StructSize from CS
This commit is contained in:
parent
7feeae9910
commit
b483b63bf2
2 changed files with 6 additions and 16 deletions
|
|
@ -9,7 +9,7 @@ namespace Dalamud.Game.Inventory;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dalamud wrapper around a ClientStructs InventoryItem.
|
/// Dalamud wrapper around a ClientStructs InventoryItem.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Explicit, Size = StructSizeInBytes)]
|
[StructLayout(LayoutKind.Explicit, Size = InventoryItem.StructSize)]
|
||||||
public unsafe struct GameInventoryItem : IEquatable<GameInventoryItem>
|
public unsafe struct GameInventoryItem : IEquatable<GameInventoryItem>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -18,21 +18,11 @@ public unsafe struct GameInventoryItem : IEquatable<GameInventoryItem>
|
||||||
[FieldOffset(0)]
|
[FieldOffset(0)]
|
||||||
internal readonly InventoryItem InternalItem;
|
internal readonly InventoryItem InternalItem;
|
||||||
|
|
||||||
private const int StructSizeInBytes = 0x48;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The view of the backing data, in <see cref="ulong"/>.
|
/// The view of the backing data, in <see cref="ulong"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[FieldOffset(0)]
|
[FieldOffset(0)]
|
||||||
private fixed ulong dataUInt64[StructSizeInBytes / 0x8];
|
private fixed ulong dataUInt64[InventoryItem.StructSize / 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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GameInventoryItem"/> struct.
|
/// Initializes a new instance of the <see cref="GameInventoryItem"/> struct.
|
||||||
|
|
@ -157,7 +147,7 @@ public unsafe struct GameInventoryItem : IEquatable<GameInventoryItem>
|
||||||
/// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <c>false</c>.</returns>
|
||||||
public readonly bool Equals(in GameInventoryItem other)
|
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])
|
if (this.dataUInt64[i] != other.dataUInt64[i])
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -173,7 +163,7 @@ public unsafe struct GameInventoryItem : IEquatable<GameInventoryItem>
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
var k = 0x5a8447b91aff51b4UL;
|
var k = 0x5a8447b91aff51b4UL;
|
||||||
for (var i = 0; i < StructSizeInBytes / 8; i++)
|
for (var i = 0; i < InventoryItem.StructSize / 8; i++)
|
||||||
k ^= this.dataUInt64[i];
|
k ^= this.dataUInt64[i];
|
||||||
return unchecked((int)(k ^ (k >> 32)));
|
return unchecked((int)(k ^ (k >> 32)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6cc4f1c12c37785101a262cceac249753db3b1f5
|
Subproject commit 81ea903b7dc90bd07a38703738fa7f84b1ed0775
|
||||||
Loading…
Add table
Add a link
Reference in a new issue