Fix decal system error (#10346)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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<EntityUid, HashSet<Vector2i>> _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)
|
||||
|
||||
@@ -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<GridInitializeEvent>(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)
|
||||
|
||||
Reference in New Issue
Block a user