Fix tabletop network spam (#5652)

This commit is contained in:
Leon Friedrich
2021-12-05 13:32:13 +13:00
committed by GitHub
parent a17369db3a
commit 8a236cdba8

View File

@@ -18,6 +18,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Timing;
using DrawDepth = Content.Shared.DrawDepth.DrawDepth; using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
namespace Content.Client.Tabletop namespace Content.Client.Tabletop
@@ -28,6 +29,7 @@ namespace Content.Client.Tabletop
[Dependency] private readonly IInputManager _inputManager = default!; [Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IUserInterfaceManager _uiManger = default!; [Dependency] private readonly IUserInterfaceManager _uiManger = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
// Time in seconds to wait until sending the location of a dragged entity to the server again // Time in seconds to wait until sending the location of a dragged entity to the server again
private const float Delay = 1f / 10; // 10 Hz private const float Delay = 1f / 10; // 10 Hz
@@ -50,6 +52,10 @@ namespace Content.Client.Tabletop
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
// don't send network messages when doing prediction.
if (!_gameTiming.IsFirstTimePredicted)
return;
// If there is no player entity, return // If there is no player entity, return
if (_playerManager.LocalPlayer is not { ControlledEntity: { Uid: var playerEntity } }) return; if (_playerManager.LocalPlayer is not { ControlledEntity: { Uid: var playerEntity } }) return;