From f2df7eeb89d2f3cb0528fd5204388f65c383defb Mon Sep 17 00:00:00 2001 From: RavMorgan <48182970+RavMorgan@users.noreply.github.com> Date: Fri, 26 May 2023 03:50:42 +0300 Subject: [PATCH] Another exploit fix (#114) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Revert "Critical fix(#106)" This reverts commit b8eeed39e7f544efd9d7a4ae6f45f529afe21145. * Але оп --------- Co-authored-by: Mona Hmiza <> # Conflicts: # Content.Server/DeviceNetwork/Systems/DeviceNetworkSystem.cs --- .../Systems/DoorSignalControlSystem.cs | 5 +-- .../Systems/DeviceNetworkSystem.cs | 36 ++++++------------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/Content.Server/DeviceLinking/Systems/DoorSignalControlSystem.cs b/Content.Server/DeviceLinking/Systems/DoorSignalControlSystem.cs index 56a754a756..765a440b4b 100644 --- a/Content.Server/DeviceLinking/Systems/DoorSignalControlSystem.cs +++ b/Content.Server/DeviceLinking/Systems/DoorSignalControlSystem.cs @@ -95,10 +95,7 @@ namespace Content.Server.DeviceLinking.Systems data[DeviceNetworkConstants.LogicState] = SignalState.Low; _signalSystem.InvokePort(uid, door.OutOpen, data); } - else if (args.State == DoorState.Open - || args.State == DoorState.Opening - || args.State == DoorState.Closing - || args.State == DoorState.Emagging) + else if (args.State is DoorState.Open or DoorState.Emagging) { data[DeviceNetworkConstants.LogicState] = SignalState.High; _signalSystem.InvokePort(uid, door.OutOpen, data); diff --git a/Content.Server/DeviceNetwork/Systems/DeviceNetworkSystem.cs b/Content.Server/DeviceNetwork/Systems/DeviceNetworkSystem.cs index 8b6fc7d54a..a10993602e 100644 --- a/Content.Server/DeviceNetwork/Systems/DeviceNetworkSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/DeviceNetworkSystem.cs @@ -6,9 +6,7 @@ using Robust.Shared.Random; using System.Buffers; using System.Diagnostics.CodeAnalysis; using System.Numerics; -using Content.Shared.Doors.Components; using Content.Shared.Examine; -using Robust.Shared.Timing; namespace Content.Server.DeviceNetwork.Systems { @@ -39,11 +37,6 @@ namespace Content.Server.DeviceNetwork.Systems /// private Queue _nextQueue = null!; - [Dependency] private readonly IGameTiming _gameTiming = default!; //WD - - private readonly TimeSpan _packetDelay = TimeSpan.FromMilliseconds(500); //WD - private TimeSpan _lastPacket = TimeSpan.Zero; //WD - public override void Initialize() { SubscribeLocalEvent(OnMapInit); @@ -59,20 +52,6 @@ namespace Content.Server.DeviceNetwork.Systems while (_activeQueue.TryDequeue(out var packet)) { - //WD edit - if (TryComp(packet.Sender, out _)) - { - if (_lastPacket == TimeSpan.Zero) - _lastPacket = _gameTiming.CurTime; - else - { - if (_gameTiming.CurTime - _lastPacket < _packetDelay) - return; - } - } - - _lastPacket = _gameTiming.CurTime; - //WD edit SendPacket(packet); } @@ -236,7 +215,8 @@ namespace Content.Server.DeviceNetwork.Systems if (!Resolve(uid, ref device, false)) return; - if (device.ReceiveFrequency == frequency) return; + if (device.ReceiveFrequency == frequency) + return; var deviceNet = GetNetwork(device.DeviceNetId); deviceNet.Remove(device); @@ -255,7 +235,8 @@ namespace Content.Server.DeviceNetwork.Systems if (!Resolve(uid, ref device, false)) return; - if (device.ReceiveAll == receiveAll) return; + if (device.ReceiveAll == receiveAll) + return; var deviceNet = GetNetwork(device.DeviceNetId); deviceNet.Remove(device); @@ -268,7 +249,8 @@ namespace Content.Server.DeviceNetwork.Systems if (!Resolve(uid, ref device, false)) return; - if (device.Address == address && device.CustomAddress) return; + if (device.Address == address && device.CustomAddress) + return; var deviceNet = GetNetwork(device.DeviceNetId); deviceNet.Remove(device); @@ -291,8 +273,10 @@ namespace Content.Server.DeviceNetwork.Systems /// /// Try to find a device on a network using its address. /// - private bool TryGetDevice(int netId, string address, [NotNullWhen(true)] out DeviceNetworkComponent? device) => - GetNetwork(netId).Devices.TryGetValue(address, out device); + private bool TryGetDevice(int netId, string address, [NotNullWhen(true)] out DeviceNetworkComponent? device) + { + return GetNetwork(netId).Devices.TryGetValue(address, out device); + } private void SendPacket(DeviceNetworkPacketEvent packet) {