Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ SmartGetHashCode()

static unsafe int Microsoft.Xna.Framework.Helpers.SmartGetHashCode ( object obj)
inlinestatic

Definition at line 43 of file Helpers.cs.

44 {
45 GCHandle gCHandle = GCHandle.Alloc(obj, GCHandleType.Pinned);
46 try
47 {
48 int num = Marshal.SizeOf(obj);
49 int num2 = 0;
50 int num3 = 0;
51 int* ptr = (int*)gCHandle.AddrOfPinnedObject().ToPointer();
52 while (num2 + 4 <= num)
53 {
54 num3 ^= *ptr;
55 num2 += 4;
56 ptr++;
57 }
58 return (num3 == 0) ? int.MaxValue : num3;
59 }
60 finally
61 {
62 gCHandle.Free();
63 }
64 }
static int SizeOf(object structure)
Definition Marshal.cs:697
unsafe void * ToPointer()
Definition IntPtr.cs:210
static GCHandle Alloc(object? value)
Definition GCHandle.cs:81

References System.Runtime.InteropServices.GCHandle.AddrOfPinnedObject(), System.Runtime.InteropServices.GCHandle.Alloc(), System.Runtime.InteropServices.GCHandle.Free(), System.obj, System.Runtime.InteropServices.Marshal.SizeOf(), and System.IntPtr.ToPointer().

Referenced by Microsoft.Xna.Framework.Graphics.VertexElement.GetHashCode(), Microsoft.Xna.Framework.Graphics.VertexPositionColor.GetHashCode(), Microsoft.Xna.Framework.Graphics.VertexPositionColorTexture.GetHashCode(), Microsoft.Xna.Framework.Graphics.VertexPositionNormalTexture.GetHashCode(), and Microsoft.Xna.Framework.Graphics.VertexPositionTexture.GetHashCode().