diff --git a/Shared/Packet/Packets/PlayerPacket.cs b/Shared/Packet/Packets/PlayerPacket.cs index 8e15aa8..fe93eb8 100644 --- a/Shared/Packet/Packets/PlayerPacket.cs +++ b/Shared/Packet/Packets/PlayerPacket.cs @@ -15,26 +15,25 @@ public struct PlayerPacket : IPacket { [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public float[] AnimationBlendWeights = Array.Empty(); - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ActSize)] - public string Act = ""; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = SubActSize)] - public string SubAct = ""; + public ushort Act; + public ushort SubAct; public PlayerPacket() { Position = default; Rotation = default; + Act = 0; + SubAct = 0; } - public short Size => 0x64; + public short Size => 0x38; public void Serialize(Span data) { int offset = 0; MemoryMarshal.Write(data[..(offset += Marshal.SizeOf())], ref Position); MemoryMarshal.Write(data[offset..(offset += Marshal.SizeOf())], ref Rotation); AnimationBlendWeights.CopyTo(MemoryMarshal.Cast(data[offset..(offset += 4 * 6)])); - Encoding.UTF8.GetBytes(Act).CopyTo(data[offset..(offset += ActSize)]); - Encoding.UTF8.GetBytes(SubAct).CopyTo(data[offset..(offset + SubActSize)]); + MemoryMarshal.Write(data[offset++..++offset], ref Act); + MemoryMarshal.Write(data[offset++..++offset], ref SubAct); } public void Deserialize(Span data) { @@ -42,7 +41,7 @@ public struct PlayerPacket : IPacket { Position = MemoryMarshal.Read(data[..(offset += Marshal.SizeOf())]); Rotation = MemoryMarshal.Read(data[offset..(offset += Marshal.SizeOf())]); AnimationBlendWeights = MemoryMarshal.Cast(data[offset..(offset += 4 * 6)]).ToArray(); - Act = Encoding.UTF8.GetString(data[offset..(offset += ActSize)]).TrimEnd('\0'); - SubAct = Encoding.UTF8.GetString(data[offset..(offset + SubActSize)]).TrimEnd('\0'); + Act = MemoryMarshal.Read(data[offset++..++offset]); + SubAct = MemoryMarshal.Read(data[offset++..++offset]); } } \ No newline at end of file