From d6203e1dd1a394532127aca38c9b9d9be1926ae3 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Tue, 31 Dec 2024 09:03:21 +0100 Subject: [PATCH] ClientMsg code optimization --- Messages.cs | 6 ++++++ Participant.cs | 1 + 2 files changed, 7 insertions(+) diff --git a/Messages.cs b/Messages.cs index cd56d8c..940eae9 100644 --- a/Messages.cs +++ b/Messages.cs @@ -75,6 +75,12 @@ namespace Passer.Control.Core { return true; } + public static byte Serialized(byte[] buffer, byte networkId) { + byte ix = 0; + buffer[ix++] = ClientMsg.Id; + buffer[ix++] = networkId; + return ix; + } public static bool SendTo(Participant participant, byte networkId) { if (participant == null) return false; diff --git a/Participant.cs b/Participant.cs index be90013..147b05f 100644 --- a/Participant.cs +++ b/Participant.cs @@ -61,6 +61,7 @@ namespace Passer.Control.Core public virtual void Update(float currentTime) { if (currentTime > this.nextPublishMe) { + this.PublishBuffer(ClientMsg.Serialized(this.buffer, this.networkId)); ClientMsg.Publish(this, this.networkId); this.nextPublishMe = currentTime + Participant.publishInterval; }