diff --git a/Content.Server/Chunking/ChunkingSystem.cs b/Content.Server/Chunking/ChunkingSystem.cs index dc793a3884..0846dc5735 100644 --- a/Content.Server/Chunking/ChunkingSystem.cs +++ b/Content.Server/Chunking/ChunkingSystem.cs @@ -6,6 +6,7 @@ using Robust.Shared.Configuration; using Robust.Shared.Enums; using Robust.Shared.Map; using Robust.Shared.Utility; +using System.Linq; namespace Content.Shared.Chunking; @@ -77,7 +78,12 @@ public sealed class ChunkingSystem : EntitySystem foreach (var viewerUid in viewers) { - var xform = xformQuery.GetComponent(viewerUid); + if (!xformQuery.TryGetComponent(viewerUid, out var xform)) + { + Logger.Error($"Player has deleted viewer entities? Viewers: {string.Join(", ", viewers.Select(x => ToPrettyString(x)))}"); + continue; + } + var pos = _transform.GetWorldPosition(xform, xformQuery); var bounds = _baseViewBounds.Translated(pos).Enlarged(viewEnlargement); diff --git a/Content.Server/Decals/DecalSystem.cs b/Content.Server/Decals/DecalSystem.cs index ff5a00b704..ffbd269f03 100644 --- a/Content.Server/Decals/DecalSystem.cs +++ b/Content.Server/Decals/DecalSystem.cs @@ -18,7 +18,6 @@ namespace Content.Server.Decals [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IAdminManager _adminManager = default!; [Dependency] private readonly ITileDefinitionManager _tileDefMan = default!; - [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly ChunkingSystem _chunking = default!; private readonly Dictionary> _dirtyChunks = new(); @@ -405,7 +404,7 @@ namespace Content.Server.Decals var chunksInRange = _chunking.GetChunksForSession(playerSession, ChunkSize, xformQuery, _chunkIndexPool, _chunkViewerPool); var staleChunks = _chunkViewerPool.Get(); - var previouslySent = _previousSentChunks[playerSession]; + var previouslySent = _previousSentChunks.GetOrNew(playerSession); // Get any chunks not in range anymore // Then, remove them from previousSentChunks (for stuff like grids out of range) diff --git a/Content.Shared/Decals/SharedDecalSystem.cs b/Content.Shared/Decals/SharedDecalSystem.cs index b0facbd052..2141d056ce 100644 --- a/Content.Shared/Decals/SharedDecalSystem.cs +++ b/Content.Shared/Decals/SharedDecalSystem.cs @@ -20,25 +20,11 @@ namespace Content.Shared.Decals public const int ChunkSize = 32; public static Vector2i GetChunkIndices(Vector2 coordinates) => new ((int) Math.Floor(coordinates.X / ChunkSize), (int) Math.Floor(coordinates.Y / ChunkSize)); - private float _viewSize; - public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnGridInitialize); - _configurationManager.OnValueChanged(CVars.NetMaxUpdateRange, OnPvsRangeChanged, true); - } - - public override void Shutdown() - { - base.Shutdown(); - _configurationManager.UnsubValueChanged(CVars.NetMaxUpdateRange, OnPvsRangeChanged); - } - - private void OnPvsRangeChanged(float obj) - { - _viewSize = obj * 2f; } private void OnGridInitialize(GridInitializeEvent msg)