Another exploit fix (#114)
* Revert "Critical fix(#106)" This reverts commit b8eeed39e7f544efd9d7a4ae6f45f529afe21145. * Але оп --------- Co-authored-by: Mona Hmiza <> # Conflicts: # Content.Server/DeviceNetwork/Systems/DeviceNetworkSystem.cs
This commit is contained in:
@@ -95,10 +95,7 @@ namespace Content.Server.DeviceLinking.Systems
|
|||||||
data[DeviceNetworkConstants.LogicState] = SignalState.Low;
|
data[DeviceNetworkConstants.LogicState] = SignalState.Low;
|
||||||
_signalSystem.InvokePort(uid, door.OutOpen, data);
|
_signalSystem.InvokePort(uid, door.OutOpen, data);
|
||||||
}
|
}
|
||||||
else if (args.State == DoorState.Open
|
else if (args.State is DoorState.Open or DoorState.Emagging)
|
||||||
|| args.State == DoorState.Opening
|
|
||||||
|| args.State == DoorState.Closing
|
|
||||||
|| args.State == DoorState.Emagging)
|
|
||||||
{
|
{
|
||||||
data[DeviceNetworkConstants.LogicState] = SignalState.High;
|
data[DeviceNetworkConstants.LogicState] = SignalState.High;
|
||||||
_signalSystem.InvokePort(uid, door.OutOpen, data);
|
_signalSystem.InvokePort(uid, door.OutOpen, data);
|
||||||
|
|||||||
@@ -6,9 +6,7 @@ using Robust.Shared.Random;
|
|||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Content.Shared.Doors.Components;
|
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Robust.Shared.Timing;
|
|
||||||
|
|
||||||
namespace Content.Server.DeviceNetwork.Systems
|
namespace Content.Server.DeviceNetwork.Systems
|
||||||
{
|
{
|
||||||
@@ -39,11 +37,6 @@ namespace Content.Server.DeviceNetwork.Systems
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private Queue<DeviceNetworkPacketEvent> _nextQueue = null!;
|
private Queue<DeviceNetworkPacketEvent> _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()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<DeviceNetworkComponent, MapInitEvent>(OnMapInit);
|
SubscribeLocalEvent<DeviceNetworkComponent, MapInitEvent>(OnMapInit);
|
||||||
@@ -59,20 +52,6 @@ namespace Content.Server.DeviceNetwork.Systems
|
|||||||
|
|
||||||
while (_activeQueue.TryDequeue(out var packet))
|
while (_activeQueue.TryDequeue(out var packet))
|
||||||
{
|
{
|
||||||
//WD edit
|
|
||||||
if (TryComp<DoorComponent>(packet.Sender, out _))
|
|
||||||
{
|
|
||||||
if (_lastPacket == TimeSpan.Zero)
|
|
||||||
_lastPacket = _gameTiming.CurTime;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_gameTiming.CurTime - _lastPacket < _packetDelay)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_lastPacket = _gameTiming.CurTime;
|
|
||||||
//WD edit
|
|
||||||
SendPacket(packet);
|
SendPacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,7 +215,8 @@ namespace Content.Server.DeviceNetwork.Systems
|
|||||||
if (!Resolve(uid, ref device, false))
|
if (!Resolve(uid, ref device, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (device.ReceiveFrequency == frequency) return;
|
if (device.ReceiveFrequency == frequency)
|
||||||
|
return;
|
||||||
|
|
||||||
var deviceNet = GetNetwork(device.DeviceNetId);
|
var deviceNet = GetNetwork(device.DeviceNetId);
|
||||||
deviceNet.Remove(device);
|
deviceNet.Remove(device);
|
||||||
@@ -255,7 +235,8 @@ namespace Content.Server.DeviceNetwork.Systems
|
|||||||
if (!Resolve(uid, ref device, false))
|
if (!Resolve(uid, ref device, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (device.ReceiveAll == receiveAll) return;
|
if (device.ReceiveAll == receiveAll)
|
||||||
|
return;
|
||||||
|
|
||||||
var deviceNet = GetNetwork(device.DeviceNetId);
|
var deviceNet = GetNetwork(device.DeviceNetId);
|
||||||
deviceNet.Remove(device);
|
deviceNet.Remove(device);
|
||||||
@@ -268,7 +249,8 @@ namespace Content.Server.DeviceNetwork.Systems
|
|||||||
if (!Resolve(uid, ref device, false))
|
if (!Resolve(uid, ref device, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (device.Address == address && device.CustomAddress) return;
|
if (device.Address == address && device.CustomAddress)
|
||||||
|
return;
|
||||||
|
|
||||||
var deviceNet = GetNetwork(device.DeviceNetId);
|
var deviceNet = GetNetwork(device.DeviceNetId);
|
||||||
deviceNet.Remove(device);
|
deviceNet.Remove(device);
|
||||||
@@ -291,8 +273,10 @@ namespace Content.Server.DeviceNetwork.Systems
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Try to find a device on a network using its address.
|
/// Try to find a device on a network using its address.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool TryGetDevice(int netId, string address, [NotNullWhen(true)] out DeviceNetworkComponent? device) =>
|
private bool TryGetDevice(int netId, string address, [NotNullWhen(true)] out DeviceNetworkComponent? device)
|
||||||
GetNetwork(netId).Devices.TryGetValue(address, out device);
|
{
|
||||||
|
return GetNetwork(netId).Devices.TryGetValue(address, out device);
|
||||||
|
}
|
||||||
|
|
||||||
private void SendPacket(DeviceNetworkPacketEvent packet)
|
private void SendPacket(DeviceNetworkPacketEvent packet)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user