From f35d60369daf41a4fcd987ef8b31bd384b9536ba Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Fri, 6 Dec 2024 17:38:17 +0100 Subject: [PATCH] Further improvements --- LowLevelMessages.cs | 2 +- Messages.cs | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/LowLevelMessages.cs b/LowLevelMessages.cs index f279dbc..43f3eeb 100644 --- a/LowLevelMessages.cs +++ b/LowLevelMessages.cs @@ -3,9 +3,9 @@ using Passer; public class LowLevelMessages { public static void SendSpherical(byte[] buffer, ref uint ix, Spherical v) { - SendFloat16(buffer, ref ix, new float16(v.distance)); SendAngle8(buffer, ref ix, v.horizontal); SendAngle8(buffer, ref ix, v.vertical); + SendFloat16(buffer, ref ix, new float16(v.distance)); } public static Spherical ReceiveSpherical(byte[] data, ref uint ix) { diff --git a/Messages.cs b/Messages.cs index b9c7e2b..f23e497 100644 --- a/Messages.cs +++ b/Messages.cs @@ -231,6 +231,7 @@ namespace Passer.Control { } #endregion Investigate + #region Thing public class ThingMsg : IMessage { @@ -288,13 +289,13 @@ namespace Passer.Control { public NameMsg(byte[] data) : base(data) { } public override byte[] Serialize() { - byte[] data = new byte[length + this.name.Length]; - data[0] = NameMsg.Id; - data[1] = this.thingId; - data[2] = (byte)this.name.Length; + byte[] buffer = new byte[length + this.name.Length]; + buffer[0] = NameMsg.Id; + buffer[1] = this.thingId; + buffer[2] = (byte)this.name.Length; for (int ix = 0; ix < this.name.Length; ix++) - data[3 + ix] = (byte)this.name[ix]; - return data; + buffer[3 + ix] = (byte)this.name[ix]; + return buffer; } public override void Deserialize(byte[] data) { uint ix = 0; @@ -304,7 +305,7 @@ namespace Passer.Control { } public static bool Send(Client client, byte thingId, string name) { - NameMsg msg = new NameMsg(thingId, name); + NameMsg msg = new(thingId, name); return SendMsg(client, msg); } public static async Task Receive(Stream dataStream, Client client, byte packetSize) {