From 3a72699e30bc2ab1d8aaf7eb927c7fc510fe0d8a Mon Sep 17 00:00:00 2001 From: Goodlyay Date: Tue, 27 Feb 2024 22:13:06 -0800 Subject: [PATCH] Remove debug messages Allow plugins to read if position is being ignored --- MCGalaxy/Network/ClassicProtocol.cs | 7 ------- MCGalaxy/Network/Utils/PingList.cs | 8 ++++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/MCGalaxy/Network/ClassicProtocol.cs b/MCGalaxy/Network/ClassicProtocol.cs index 7f1fbeab4..d6483dde9 100644 --- a/MCGalaxy/Network/ClassicProtocol.cs +++ b/MCGalaxy/Network/ClassicProtocol.cs @@ -265,13 +265,7 @@ namespace MCGalaxy.Network // Client-> server ping, immediately send reply. Send(Packet.TwoWayPing(false, data)); } else { - - bool debugIgnoredCached = Ping.IgnorePosition; Ping.UnIgnorePosition(data); - if (debugIgnoredCached == true && !Ping.IgnorePosition) { - player.Message("Position no longer being ignored, received {0}", data); - } - // Server -> client ping, set time received for reply. Ping.Update(data); } @@ -387,7 +381,6 @@ namespace MCGalaxy.Network if (!hasTwoWayPing || id != Entities.SelfID) { return; } ushort data = Ping.NextTwoWayPingData(true); SendTwoWayPing(data); - player.Message("Now ignoring your position until {0}", data); } public override void SendRemoveEntity(byte id) { diff --git a/MCGalaxy/Network/Utils/PingList.cs b/MCGalaxy/Network/Utils/PingList.cs index 614a0845c..4032069d9 100644 --- a/MCGalaxy/Network/Utils/PingList.cs +++ b/MCGalaxy/Network/Utils/PingList.cs @@ -38,14 +38,14 @@ namespace MCGalaxy.Network long ignorePositionData = -1; - internal bool IgnorePosition { + public bool IgnorePosition { get { return Interlocked.Read(ref ignorePositionData) >= 0; } } - public void UnIgnorePosition(ushort data) { + internal void UnIgnorePosition(ushort data) { Interlocked.CompareExchange(ref ignorePositionData, -1, data); } - public ushort NextTwoWayPingData(bool waitingForMovementAcknowledged = false) { + public ushort NextTwoWayPingData(bool startIgnoringPosition = false) { int pingValue = Interlocked.Increment(ref pingCounter); int pingHead = (Interlocked.Increment(ref nextPingHead) - 1) % 10; @@ -53,7 +53,7 @@ namespace MCGalaxy.Network Entries[pingHead].TimeRecv = default(DateTime); Entries[pingHead].TimeSent = DateTime.UtcNow; - if (waitingForMovementAcknowledged) Interlocked.Exchange(ref ignorePositionData, pingValue); + if (startIgnoringPosition) Interlocked.Exchange(ref ignorePositionData, pingValue); return (ushort)pingValue; }