From c4fbc6b88ef215ea55bd83a12ebcf8a9233df177 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:54:33 -0700 Subject: [PATCH] fix: Adds text command to throttle. Fixes throttle itself. (#1743) --- Projects/Server/Network/NetState/NetState.cs | 2 +- Projects/UOContent/Misc/PacketThrottles.cs | 22 +++++++------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Projects/Server/Network/NetState/NetState.cs b/Projects/Server/Network/NetState/NetState.cs index 75bd4d40a..cdee40c20 100755 --- a/Projects/Server/Network/NetState/NetState.cs +++ b/Projects/Server/Network/NetState/NetState.cs @@ -845,7 +845,7 @@ public partial class NetState : IComparable, IValueLinkListNode 0) { IncomingPackets.RegisterThrottler(packetID, &Throttle); + e.Mobile.SendMessage($"Set throttle for packet 0x{packetID:X2} to {delay}ms."); } else if (oldDelay > 0 && delay == 0) { IncomingPackets.RegisterThrottler(packetID, null); + e.Mobile.SendMessage($"Removed throttle for packet 0x{packetID:X2}"); } Delays[packetID] = delay; @@ -130,27 +133,16 @@ namespace Server.Network } } - var configPath = ThrottlesConfiguration; - var path = Path.Join(Core.BaseDirectory, configPath); + var path = Path.Join(Core.BaseDirectory, ThrottlesConfiguration); JsonConfig.Serialize(path, table); } public static bool Throttle(int packetID, NetState ns, out bool drop) { - if (ns.Mobile is not PlayerMobile player || player.AccessLevel >= AccessLevel.Counselor) - { - drop = false; - return true; - } + drop = ns.Mobile is PlayerMobile { AccessLevel: < AccessLevel.Counselor } + && Core.TickCount - ns.GetPacketTime(packetID) < Delays[packetID]; - if (Core.TickCount - ns.GetPacketTime(packetID) < Delays[packetID]) - { - drop = true; - return false; - } - - drop = false; - return true; + return !drop; } } }