From 892250e33b5b0e59dbe0851b918dc14193aa5cfe Mon Sep 17 00:00:00 2001 From: zingballyhoo Date: Sat, 2 Dec 2023 19:27:44 +0000 Subject: [PATCH] fix another couple warnings --- TACTLib/Helpers/UInt16BE.cs | 2 ++ TACTLib/Helpers/UInt24BE.cs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/TACTLib/Helpers/UInt16BE.cs b/TACTLib/Helpers/UInt16BE.cs index 8441033..e43e697 100644 --- a/TACTLib/Helpers/UInt16BE.cs +++ b/TACTLib/Helpers/UInt16BE.cs @@ -1,7 +1,9 @@ using System; using System.Buffers.Binary; +using System.Runtime.InteropServices; namespace TACTLib.Helpers { + [StructLayout(LayoutKind.Sequential)] public struct UInt16BE { private ushort m_data; diff --git a/TACTLib/Helpers/UInt24BE.cs b/TACTLib/Helpers/UInt24BE.cs index d54e565..957ac57 100644 --- a/TACTLib/Helpers/UInt24BE.cs +++ b/TACTLib/Helpers/UInt24BE.cs @@ -1,15 +1,22 @@ -using System.Runtime.CompilerServices; +using System; +using System.Runtime.InteropServices; namespace TACTLib.Helpers { - [InlineArray(3)] + [StructLayout(LayoutKind.Sequential)] public struct UInt24BE { - private byte m_first; + private byte m_a; + private byte m_b; + private byte m_c; public readonly int ToInt() { - return this[2] | (this[1] << 8) | (this[0] << 16); + if (BitConverter.IsLittleEndian) + { + return m_c | (m_b << 8) | (m_a << 16); + } + throw new NotImplementedException(); } } } \ No newline at end of file