Warning fixes (#5275)

* Warning fixes in Robust.Shared

* Robust.Client warning fixes

* Fix test failure

Test failures were due to broken system registrations for the client RobustUnitTest. It was accidentally registering some server systems, which means DebugPhysicsSystem wasn't gettings its dependencies properly.

Fixing this meant pulling half a dozen extra dependencies that client ContainerSystem and TransformSystem are supposed to have, but didn't.
This commit is contained in:
Pieter-Jan Briers
2024-07-10 01:38:32 +02:00
committed by GitHub
parent b82bc258db
commit 7fbcfeaa8f
42 changed files with 245 additions and 203 deletions

View File

@@ -302,7 +302,7 @@ internal partial class AudioManager
}
/// <inheritdoc/>
IBufferedAudioSource? IAudioInternal.CreateBufferedAudioSource(int buffers, bool floatAudio=false)
IBufferedAudioSource? IAudioInternal.CreateBufferedAudioSource(int buffers, bool floatAudio)
{
var source = AL.GenSource();

View File

@@ -46,7 +46,7 @@ public sealed class AudioOverlay : Overlay
var screenHandle = args.ScreenHandle;
var output = new StringBuilder();
var listenerPos = _entManager.GetComponent<TransformComponent>(localPlayer.Value).MapPosition;
var listenerPos = _transform.GetMapCoordinates(_entManager.GetComponent<TransformComponent>(localPlayer.Value));
if (listenerPos.MapId != args.MapId)
return;

View File

@@ -1,24 +1,18 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using OpenTK.Audio.OpenAL;
using OpenTK.Audio.OpenAL.Extensions.Creative.EFX;
using Robust.Client.Graphics;
using Robust.Shared.Audio.Sources;
using Robust.Shared.Maths;
namespace Robust.Client.Audio.Sources;
internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSource
{
private int? SourceHandle = null;
private int[] BufferHandles;
private Dictionary<int, int> BufferMap = new();
private readonly AudioManager _master;
private bool _mono = true;
private bool _float = false;
private int FilterHandle;
public int SampleRate { get; set; } = 44100;
@@ -43,7 +37,7 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
get
{
_checkDisposed();
var state = AL.GetSourceState(SourceHandle!.Value);
var state = AL.GetSourceState(SourceHandle);
_master._checkAlError();
return state == ALSourceState.Playing;
}
@@ -53,7 +47,7 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
{
_checkDisposed();
// IDK why this stackallocs but gonna leave it for now.
AL.SourcePlay(stackalloc int[] {SourceHandle!.Value});
AL.SourcePlay(stackalloc int[] {SourceHandle});
_master._checkAlError();
}
else
@@ -61,7 +55,7 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
if (_isDisposed())
return;
AL.SourceStop(SourceHandle!.Value);
AL.SourceStop(SourceHandle);
_master._checkAlError();
}
}
@@ -74,13 +68,13 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
protected override void Dispose(bool disposing)
{
if (SourceHandle == null)
if (SourceHandle == -1)
return;
if (!_master.IsMainThread())
{
// We can't run this code inside another thread so tell Clyde to clear it up later.
_master.DeleteBufferedSourceOnMainThread(SourceHandle.Value, FilterHandle);
_master.DeleteBufferedSourceOnMainThread(SourceHandle, FilterHandle);
foreach (var handle in BufferHandles)
{
@@ -92,21 +86,21 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
if (FilterHandle != 0)
EFX.DeleteFilter(FilterHandle);
AL.DeleteSource(SourceHandle.Value);
AL.DeleteSource(SourceHandle);
AL.DeleteBuffers(BufferHandles);
_master.RemoveBufferedAudioSource(SourceHandle.Value);
_master.RemoveBufferedAudioSource(SourceHandle);
_master._checkAlError();
}
FilterHandle = 0;
SourceHandle = null;
SourceHandle = -1;
}
public int GetNumberOfBuffersProcessed()
{
_checkDisposed();
// ReSharper disable once PossibleInvalidOperationException
AL.GetSource(SourceHandle!.Value, ALGetSourcei.BuffersProcessed, out var buffersProcessed);
AL.GetSource(SourceHandle, ALGetSourcei.BuffersProcessed, out var buffersProcessed);
return buffersProcessed;
}
@@ -116,7 +110,7 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
var entries = Math.Min(Math.Min(handles.Length, BufferHandles.Length), GetNumberOfBuffersProcessed());
fixed (int* ptr = handles)
{
AL.SourceUnqueueBuffers(SourceHandle!.Value, entries, ptr);
AL.SourceUnqueueBuffers(SourceHandle, entries, ptr);
}
for (var i = 0; i < entries; i++)
@@ -183,7 +177,7 @@ internal sealed class BufferedAudioSource : BaseAudioSource, IBufferedAudioSourc
fixed (int* ptr = realHandles)
// ReSharper disable once PossibleInvalidOperationException
{
AL.SourceQueueBuffers(SourceHandle!.Value, handles.Length, ptr);
AL.SourceQueueBuffers(SourceHandle, handles.Length, ptr);
}
}

View File

@@ -291,9 +291,9 @@ namespace Robust.Client.Console.Commands
}
}
internal sealed class SnapGridGetCell : LocalizedCommands
internal sealed class SnapGridGetCell : LocalizedEntityCommands
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly SharedMapSystem _map = default!;
public override string Command => "sggcell";
@@ -319,9 +319,10 @@ namespace Robust.Client.Console.Commands
return;
}
if (_entManager.TryGetComponent<MapGridComponent>(_entManager.GetEntity(gridNet), out var grid))
var gridEnt = EntityManager.GetEntity(gridNet);
if (EntityManager.TryGetComponent<MapGridComponent>(gridEnt, out var grid))
{
foreach (var entity in grid.GetAnchoredEntities(new Vector2i(
foreach (var entity in _map.GetAnchoredEntities(gridEnt, grid, new Vector2i(
int.Parse(indices.Split(',')[0], CultureInfo.InvariantCulture),
int.Parse(indices.Split(',')[1], CultureInfo.InvariantCulture))))
{
@@ -425,9 +426,9 @@ namespace Robust.Client.Console.Commands
}
}
internal sealed class GridTileCount : LocalizedCommands
internal sealed class GridTileCount : LocalizedEntityCommands
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly SharedMapSystem _map = default!;
public override string Command => "gridtc";
@@ -440,15 +441,15 @@ namespace Robust.Client.Console.Commands
}
if (!NetEntity.TryParse(args[0], out var gridUidNet) ||
!_entManager.TryGetEntity(gridUidNet, out var gridUid))
!EntityManager.TryGetEntity(gridUidNet, out var gridUid))
{
shell.WriteLine($"{args[0]} is not a valid entity UID.");
return;
}
if (_entManager.TryGetComponent<MapGridComponent>(gridUid, out var grid))
if (EntityManager.TryGetComponent<MapGridComponent>(gridUid, out var grid))
{
shell.WriteLine(grid.GetAllTiles().Count().ToString());
shell.WriteLine(_map.GetAllTiles(gridUid.Value, grid).Count().ToString());
}
else
{
@@ -680,12 +681,12 @@ namespace Robust.Client.Console.Commands
}
}
internal sealed class ChunkInfoCommand : LocalizedCommands
internal sealed class ChunkInfoCommand : LocalizedEntityCommands
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IEyeManager _eye = default!;
[Dependency] private readonly IInputManager _input = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
public override string Command => "chunkinfo";
@@ -699,8 +700,8 @@ namespace Robust.Client.Console.Commands
return;
}
var mapSystem = _entManager.System<SharedMapSystem>();
var chunkIndex = mapSystem.LocalToChunkIndices(gridUid, grid, grid.MapToGrid(mousePos));
var mapSystem = EntityManager.System<SharedMapSystem>();
var chunkIndex = mapSystem.LocalToChunkIndices(gridUid, grid, _mapSystem.MapToGrid(gridUid, mousePos));
var chunk = mapSystem.GetOrAddChunk(gridUid, grid, chunkIndex);
shell.WriteLine($"worldBounds: {mapSystem.CalcWorldAABB(gridUid, grid, chunk)} localBounds: {chunk.CachedBounds}");

View File

@@ -1,16 +1,19 @@
using Robust.Client.GameObjects;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Robust.Client.Console.Commands
{
public sealed class GridChunkBBCommand : LocalizedCommands
public sealed class GridChunkBBCommand : LocalizedEntityCommands
{
[Dependency] private readonly GridChunkBoundsDebugSystem _system = default!;
public override string Command => "showchunkbb";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
EntitySystem.Get<GridChunkBoundsDebugSystem>().Enabled ^= true;
_system.Enabled ^= true;
}
}
}

View File

@@ -204,7 +204,7 @@ Suspendisse hendrerit blandit urna ut laoreet. Suspendisse ac elit at erat males
private Control TabRichText()
{
var label = new RichTextLabel();
label.SetMessage(FormattedMessage.FromMarkup(Lipsum));
label.SetMessage(FormattedMessage.FromMarkupOrThrow(Lipsum));
TabContainer.SetTabTitle(label, "RichText");
return label;

View File

@@ -1,4 +1,5 @@
using System.Numerics;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects;
@@ -14,6 +15,8 @@ namespace Robust.Client.Debugging
{
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly TransformSystem _transform = default!;
private bool _debugPositions;
private bool _debugRotations;
@@ -35,7 +38,7 @@ namespace Robust.Client.Debugging
if (value && !_overlayManager.HasOverlay<EntityPositionOverlay>())
{
_overlayManager.AddOverlay(new EntityPositionOverlay(_lookup, EntityManager));
_overlayManager.AddOverlay(new EntityPositionOverlay(_lookup, EntityManager, _transform));
}
else
{
@@ -74,13 +77,15 @@ namespace Robust.Client.Debugging
{
private readonly EntityLookupSystem _lookup;
private readonly IEntityManager _entityManager;
private readonly SharedTransformSystem _transform;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
public EntityPositionOverlay(EntityLookupSystem lookup, IEntityManager entityManager)
public EntityPositionOverlay(EntityLookupSystem lookup, IEntityManager entityManager, SharedTransformSystem transform)
{
_lookup = lookup;
_entityManager = entityManager;
_transform = transform;
}
protected internal override void Draw(in OverlayDrawArgs args)
@@ -88,11 +93,10 @@ namespace Robust.Client.Debugging
const float stubLength = 0.25f;
var worldHandle = (DrawingHandleWorld) args.DrawingHandle;
var xformQuery = _entityManager.GetEntityQuery<TransformComponent>();
foreach (var entity in _lookup.GetEntitiesIntersecting(args.MapId, args.WorldBounds))
{
var (center, worldRotation) = xformQuery.GetComponent(entity).GetWorldPositionRotation();
var (center, worldRotation) = _transform.GetWorldPositionRotation(entity);
var xLine = worldRotation.RotateVec(Vector2.UnitX);
var yLine = worldRotation.RotateVec(Vector2.UnitY);

View File

@@ -47,6 +47,7 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.Player;
@@ -78,6 +79,14 @@ namespace Robust.Client.Debugging
internal int PointCount;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly IOverlayManager _overlay = default!;
[Dependency] private readonly IEyeManager _eye = default!;
[Dependency] private readonly IInputManager _input = default!;
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
internal ContactPoint[] Points = new ContactPoint[MaxContactPoints];
@@ -89,20 +98,21 @@ namespace Robust.Client.Debugging
if (value == _flags) return;
if (_flags == PhysicsDebugFlags.None)
IoCManager.Resolve<IOverlayManager>().AddOverlay(
_overlay.AddOverlay(
new PhysicsDebugOverlay(
EntityManager,
IoCManager.Resolve<IEyeManager>(),
IoCManager.Resolve<IInputManager>(),
IoCManager.Resolve<IMapManager>(),
IoCManager.Resolve<IPlayerManager>(),
IoCManager.Resolve<IResourceCache>(),
_eye,
_input,
_map,
_player,
_resourceCache,
this,
Get<EntityLookupSystem>(),
Get<SharedPhysicsSystem>()));
_entityLookup,
_physics,
_transform));
if (value == PhysicsDebugFlags.None)
IoCManager.Resolve<IOverlayManager>().RemoveOverlay(typeof(PhysicsDebugOverlay));
_overlay.RemoveOverlay(typeof(PhysicsDebugOverlay));
_flags = value;
}
@@ -198,6 +208,7 @@ namespace Robust.Client.Debugging
private readonly DebugPhysicsSystem _debugPhysicsSystem;
private readonly EntityLookupSystem _lookup;
private readonly SharedPhysicsSystem _physicsSystem;
private readonly SharedTransformSystem _transformSystem;
public override OverlaySpace Space => OverlaySpace.WorldSpace | OverlaySpace.ScreenSpace;
@@ -208,7 +219,7 @@ namespace Robust.Client.Debugging
private HashSet<Joint> _drawnJoints = new();
private List<Entity<MapGridComponent>> _grids = new();
public PhysicsDebugOverlay(IEntityManager entityManager, IEyeManager eyeManager, IInputManager inputManager, IMapManager mapManager, IPlayerManager playerManager, IResourceCache cache, DebugPhysicsSystem system, EntityLookupSystem lookup, SharedPhysicsSystem physicsSystem)
public PhysicsDebugOverlay(IEntityManager entityManager, IEyeManager eyeManager, IInputManager inputManager, IMapManager mapManager, IPlayerManager playerManager, IResourceCache cache, DebugPhysicsSystem system, EntityLookupSystem lookup, SharedPhysicsSystem physicsSystem, SharedTransformSystem transformSystem)
{
_entityManager = entityManager;
_eyeManager = eyeManager;
@@ -218,6 +229,7 @@ namespace Robust.Client.Debugging
_debugPhysicsSystem = system;
_lookup = lookup;
_physicsSystem = physicsSystem;
_transformSystem = transformSystem;
_font = new VectorFont(cache.GetResource<FontResource>("/EngineFonts/NotoSans/NotoSans-Regular.ttf"), 10);
}
@@ -327,7 +339,7 @@ namespace Robust.Client.Debugging
{
if (jointComponent.JointCount == 0 ||
!_entityManager.TryGetComponent(uid, out TransformComponent? xf1) ||
!viewAABB.Contains(xf1.WorldPosition)) continue;
!viewAABB.Contains(_transformSystem.GetWorldPosition(xf1))) continue;
foreach (var (_, joint) in jointComponent.Joints)
{
@@ -517,8 +529,8 @@ namespace Robust.Client.Debugging
if (!_entityManager.TryGetComponent(joint.BodyAUid, out TransformComponent? xform1) ||
!_entityManager.TryGetComponent(joint.BodyBUid, out TransformComponent? xform2)) return;
var matrix1 = xform1.WorldMatrix;
var matrix2 = xform2.WorldMatrix;
var matrix1 = _transformSystem.GetWorldMatrix(xform1);
var matrix2 = _transformSystem.GetWorldMatrix(xform2);
var xf1 = new Vector2(matrix1.M31, matrix1.M32);
var xf2 = new Vector2(matrix2.M31, matrix2.M32);
@@ -526,8 +538,8 @@ namespace Robust.Client.Debugging
var p1 = Vector2.Transform(joint.LocalAnchorA, matrix1);
var p2 = Vector2.Transform(joint.LocalAnchorB, matrix2);
var xfa = new Transform(xf1, xform1.WorldRotation);
var xfb = new Transform(xf2, xform2.WorldRotation);
var xfa = new Transform(xf1, _transformSystem.GetWorldRotation(xform1));
var xfb = new Transform(xf2, _transformSystem.GetWorldRotation(xform2));
switch (joint)
{

View File

@@ -48,16 +48,6 @@ namespace Robust.Client.GameObjects
return base.CreateEntity(prototypeName, out metadata);
}
void IClientEntityManagerInternal.InitializeEntity(EntityUid entity, MetaDataComponent? meta)
{
base.InitializeEntity(entity, meta);
}
void IClientEntityManagerInternal.StartEntity(EntityUid entity)
{
base.StartEntity(entity);
}
/// <inheritdoc />
public override void DirtyEntity(EntityUid uid, MetaDataComponent? meta = null)
{

View File

@@ -18,6 +18,8 @@ namespace Robust.Client.GameObjects
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly SharedMapSystem _map = default!;
private GridChunkBoundsOverlay? _overlay;
@@ -36,7 +38,9 @@ namespace Robust.Client.GameObjects
_overlay = new GridChunkBoundsOverlay(
EntityManager,
_eyeManager,
_mapManager);
_mapManager,
_transform,
_map);
_overlayManager.AddOverlay(_overlay);
}
@@ -56,16 +60,20 @@ namespace Robust.Client.GameObjects
private readonly IEntityManager _entityManager;
private readonly IEyeManager _eyeManager;
private readonly IMapManager _mapManager;
private readonly SharedTransformSystem _transformSystem;
private readonly SharedMapSystem _mapSystem;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private List<Entity<MapGridComponent>> _grids = new();
public GridChunkBoundsOverlay(IEntityManager entManager, IEyeManager eyeManager, IMapManager mapManager)
public GridChunkBoundsOverlay(IEntityManager entManager, IEyeManager eyeManager, IMapManager mapManager, SharedTransformSystem transformSystem, SharedMapSystem mapSystem)
{
_entityManager = entManager;
_eyeManager = eyeManager;
_mapManager = mapManager;
_transformSystem = transformSystem;
_mapSystem = mapSystem;
}
protected internal override void Draw(in OverlayDrawArgs args)
@@ -78,11 +86,11 @@ namespace Robust.Client.GameObjects
_mapManager.FindGridsIntersecting(currentMap, viewport, ref _grids);
foreach (var grid in _grids)
{
var worldMatrix = _entityManager.GetComponent<TransformComponent>(grid).WorldMatrix;
var worldMatrix = _transformSystem.GetWorldMatrix(grid);
worldHandle.SetTransform(worldMatrix);
var transform = new Transform(Vector2.Zero, Angle.Zero);
var chunkEnumerator = grid.Comp.GetMapChunks(viewport);
var chunkEnumerator = _mapSystem.GetMapChunks(grid.Owner, grid.Comp, viewport);
while (chunkEnumerator.MoveNext(out var chunk))
{

View File

@@ -196,7 +196,7 @@ namespace Robust.Client.GameObjects
wOffset = new Vector2(wX, wY);
}
var coords = EntityCoordinates.FromMap(pent, _transform.GetMapCoordinates(pent).Offset(wOffset), _transform, EntityManager);
var coords = _transform.ToCoordinates(pent, _transform.GetMapCoordinates(pent).Offset(wOffset));
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(keyFunction);
var message = new ClientFullInputCmdMessage(_timing.CurTick,

View File

@@ -14,6 +14,7 @@ namespace Robust.Client.GameObjects
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly TransformSystem _transform = default!;
internal bool Enabled { get; set; }
@@ -43,7 +44,7 @@ namespace Robust.Client.GameObjects
return;
}
var screenPos = _eyeManager.WorldToScreen(EntityManager.GetComponent<TransformComponent>(player.Value).WorldPosition);
var screenPos = _eyeManager.WorldToScreen(_transform.GetWorldPosition(Transform(player.Value)));
LayoutContainer.SetPosition(_label, screenPos + new Vector2(0, 50));
_label.Visible = true;

View File

@@ -7,9 +7,5 @@ namespace Robust.Client.GameObjects
// These methods are used by the Game State Manager.
EntityUid CreateEntity(string? prototypeName, out MetaDataComponent metadata);
void InitializeEntity(EntityUid entity, MetaDataComponent? meta = null);
void StartEntity(EntityUid entity);
}
}

View File

@@ -77,7 +77,7 @@ namespace Robust.Client.ViewVariables.Editors
{
var protoMan = IoCManager.Resolve<IPrototypeManager>();
if (!protoMan.TryGetVariantFrom(typeof(T), out var variant)) return;
if (!protoMan.TryGetKindFrom(typeof(T), out var variant)) return;
var list = new List<string>();

View File

@@ -18,6 +18,8 @@ namespace Robust.Shared.CPUJob.JobQueues
/// <typeparam name="T">The type of result this job generates</typeparam>
public abstract class Job<T> : IJob
{
private readonly ISawmill _sawmill = Logger.GetSawmill("job");
public JobStatus Status { get; private set; } = JobStatus.Pending;
/// <summary>
@@ -184,7 +186,7 @@ namespace Robust.Shared.CPUJob.JobQueues
{
// TODO: Should this be exposed differently?
// I feel that people might forget to check whether the job failed.
Logger.ErrorS("job", "Job failed on exception:\n{0}", e);
_sawmill.Error("Job failed on exception:\n{0}", e);
Exception = e;
_taskTcs.TrySetException(e);
}

View File

@@ -24,6 +24,7 @@ public abstract class ComponentTreeSystem<TTreeComp, TComp> : EntitySystem
[Dependency] private readonly RecursiveMoveSystem _recursiveMoveSys = default!;
[Dependency] protected readonly SharedTransformSystem XformSystem = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
private readonly Queue<ComponentTreeEntry<TComp>> _updateQueue = new();
private readonly HashSet<EntityUid> _updated = new();
@@ -288,11 +289,9 @@ public abstract class ComponentTreeSystem<TTreeComp, TComp> : EntitySystem
return true;
}, includeMap: false);
var mapUid = _mapManager.GetMapEntityId(mapId);
if (TryComp(mapUid, out TTreeComp? mapTreeComp))
if (_mapSystem.TryGetMap(mapId, out var mapUid) && TryComp(mapUid, out TTreeComp? mapTreeComp))
{
state.trees.Add((mapUid, mapTreeComp));
state.trees.Add((mapUid.Value, mapTreeComp));
}
return state.trees;

View File

@@ -8,10 +8,9 @@ using Robust.Shared.Map.Components;
namespace Robust.Shared.Console.Commands;
sealed class AddMapCommand : LocalizedCommands
sealed class AddMapCommand : LocalizedEntityCommands
{
[Dependency] private readonly IMapManagerInternal _map = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
public override string Command => "addmap";
public override bool RequireServerOrSingleplayer => true;
@@ -23,10 +22,10 @@ sealed class AddMapCommand : LocalizedCommands
var mapId = new MapId(int.Parse(args[0]));
if (!_map.MapExists(mapId))
if (!_mapSystem.MapExists(mapId))
{
var init = args.Length < 2 || !bool.Parse(args[1]);
_entMan.System<SharedMapSystem>().CreateMap(mapId, runMapInit: init);
EntityManager.System<SharedMapSystem>().CreateMap(mapId, runMapInit: init);
shell.WriteLine($"Map with ID {mapId} created.");
return;
@@ -64,11 +63,8 @@ sealed class RemoveMapCommand : LocalizedCommands
}
}
sealed class RemoveGridCommand : LocalizedCommands
sealed class RemoveGridCommand : LocalizedEntityCommands
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IMapManager _map = default!;
public override string Command => "rmgrid";
public override bool RequireServerOrSingleplayer => true;
@@ -82,20 +78,20 @@ sealed class RemoveGridCommand : LocalizedCommands
var gridIdNet = NetEntity.Parse(args[0]);
if (!_entManager.TryGetEntity(gridIdNet, out var gridId) || !_entManager.HasComponent<MapGridComponent>(gridId))
if (!EntityManager.TryGetEntity(gridIdNet, out var gridId) || !EntityManager.HasComponent<MapGridComponent>(gridId))
{
shell.WriteError($"Grid {gridId} does not exist.");
return;
}
_map.DeleteGrid(gridId.Value);
EntityManager.DeleteEntity(gridId);
shell.WriteLine($"Grid {gridId} was removed.");
}
}
internal sealed class RunMapInitCommand : LocalizedCommands
internal sealed class RunMapInitCommand : LocalizedEntityCommands
{
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
public override string Command => "mapinit";
public override bool RequireServerOrSingleplayer => true;
@@ -111,26 +107,27 @@ internal sealed class RunMapInitCommand : LocalizedCommands
var arg = args[0];
var mapId = new MapId(int.Parse(arg, CultureInfo.InvariantCulture));
if (!_map.MapExists(mapId))
if (!_mapSystem.MapExists(mapId))
{
shell.WriteError("Map does not exist!");
return;
}
if (_map.IsMapInitialized(mapId))
if (_mapSystem.IsInitialized(mapId))
{
shell.WriteError("Map is already initialized!");
return;
}
_map.DoMapInitialize(mapId);
_mapSystem.InitializeMap(mapId);
}
}
internal sealed class ListMapsCommand : LocalizedCommands
internal sealed class ListMapsCommand : LocalizedEntityCommands
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
public override string Command => "lsmap";
@@ -143,13 +140,15 @@ internal sealed class ListMapsCommand : LocalizedCommands
foreach (var mapId in _map.GetAllMapIds().OrderBy(id => id.Value))
{
var mapUid = _map.GetMapEntityId(mapId);
if (!_mapSystem.TryGetMap(mapId, out var mapUid))
continue;
msg.AppendFormat("{0}: {1}, init: {2}, paused: {3}, nent: {4}, grids: {5}\n",
mapId, _entManager.GetComponent<MetaDataComponent>(mapUid).EntityName,
_map.IsMapInitialized(mapId),
_map.IsMapPaused(mapId),
_entManager.GetNetEntity(_map.GetMapEntityId(mapId)),
mapId,
_entManager.GetComponent<MetaDataComponent>(mapUid.Value).EntityName,
_mapSystem.IsInitialized(mapUid),
_mapSystem.IsPaused(mapId),
_entManager.GetNetEntity(mapUid),
string.Join(",", _map.GetAllGrids(mapId).Select(grid => grid.Owner)));
}
@@ -157,9 +156,10 @@ internal sealed class ListMapsCommand : LocalizedCommands
}
}
internal sealed class ListGridsCommand : LocalizedCommands
internal sealed class ListGridsCommand : LocalizedEntityCommands
{
[Dependency] private readonly IEntityManager _ent = default!;
[Dependency]
private readonly SharedTransformSystem _transformSystem = default!;
public override string Command => "lsgrid";
@@ -169,15 +169,14 @@ internal sealed class ListGridsCommand : LocalizedCommands
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var msg = new StringBuilder();
var xformSystem = _ent.System<SharedTransformSystem>();
var xformQuery = _ent.GetEntityQuery<TransformComponent>();
var grids = _ent.AllComponentsList<MapGridComponent>();
var xformQuery = EntityManager.GetEntityQuery<TransformComponent>();
var grids = EntityManager.AllComponentsList<MapGridComponent>();
grids.Sort((x, y) => x.Uid.CompareTo(y.Uid));
foreach (var (uid, grid) in grids)
foreach (var (uid, _) in grids)
{
var xform = xformQuery.GetComponent(uid);
var worldPos = xformSystem.GetWorldPosition(xform);
var worldPos = _transformSystem.GetWorldPosition(xform);
msg.AppendFormat("{0}: map: {1}, ent: {2}, pos: {3:0.0},{4:0.0} \n",
uid, xform.MapID, uid, worldPos.X, worldPos.Y);

View File

@@ -61,7 +61,7 @@ internal sealed class TeleportCommand : LocalizedEntityCommands
else
{
var mapEnt = _map.GetMapEntityIdOrThrow(mapId);
_transform.SetWorldPosition(transform, position);
_transform.SetWorldPosition((entity, transform), position);
_transform.SetParent(entity, transform, mapEnt);
}

View File

@@ -59,7 +59,7 @@ namespace Robust.Shared.Console
void WriteMarkup(string markup)
{
WriteLine(FormattedMessage.FromMarkup(markup));
WriteLine(FormattedMessage.FromMarkupPermissive(markup));
}
/// <summary>

View File

@@ -659,7 +659,9 @@ namespace Robust.Shared.Containers
if (!transform.Comp.ParentUid.IsValid()
|| !TryGetContainingContainer(transform.Comp.ParentUid, out var container)
|| !TryInsertIntoContainer(transform, container))
transform.Comp.AttachToGridOrMap();
{
_transform.AttachToGridOrMap(transform, transform.Comp);
}
}
private bool TryInsertIntoContainer(Entity<TransformComponent> transform, BaseContainer container)

View File

@@ -660,21 +660,25 @@ namespace Robust.Shared.GameObjects
/// Raised when the Anchor state of the transform is changed.
/// </summary>
[ByRefEvent]
public readonly struct AnchorStateChangedEvent
public readonly struct AnchorStateChangedEvent(
EntityUid entity,
TransformComponent transform,
bool detaching = false)
{
public readonly TransformComponent Transform;
public EntityUid Entity => Transform.Owner;
public readonly TransformComponent Transform = transform;
public EntityUid Entity { get; } = entity;
public bool Anchored => Transform.Anchored;
/// <summary>
/// If true, the entity is being detached to null-space
/// </summary>
public readonly bool Detaching;
public readonly bool Detaching = detaching;
[Obsolete("Use constructor that takes in EntityUid")]
public AnchorStateChangedEvent(TransformComponent transform, bool detaching = false)
: this(transform.Owner, transform, detaching)
{
Detaching = detaching;
Transform = transform;
}
}

View File

@@ -23,7 +23,7 @@ namespace Robust.Shared.GameObjects
[Reflect(false), PublicAPI]
public abstract partial class EntitySystem : IEntitySystem, IPostInjectInit
{
[Dependency] protected readonly EntityManager EntityManager;
[Dependency] protected readonly EntityManager EntityManager = default!;
[Dependency] protected readonly ILogManager LogManager = default!;
[Dependency] private readonly ISharedPlayerManager _playerMan = default!;
[Dependency] private readonly IReplayRecordingManager _replayMan = default!;
@@ -65,11 +65,8 @@ namespace Robust.Shared.GameObjects
IEnumerable<Type> IEntitySystem.UpdatesAfter => UpdatesAfter;
IEnumerable<Type> IEntitySystem.UpdatesBefore => UpdatesBefore;
protected EntitySystem() : this(default!) { }
protected EntitySystem(IEntityManager entityManager)
protected EntitySystem()
{
EntityManager = (EntityManager)entityManager;
Subs = new Subscriptions(this);
}

View File

@@ -90,7 +90,7 @@ public abstract partial class SharedTransformSystem
if (!wasAnchored && xform.Running)
{
var ev = new AnchorStateChangedEvent(xform);
var ev = new AnchorStateChangedEvent(uid, xform);
RaiseLocalEvent(uid, ref ev, true);
}
@@ -150,7 +150,7 @@ public abstract partial class SharedTransformSystem
if (!xform.Running)
return;
var ev = new AnchorStateChangedEvent(xform);
var ev = new AnchorStateChangedEvent(uid, xform);
RaiseLocalEvent(uid, ref ev, true);
}
@@ -249,19 +249,20 @@ public abstract partial class SharedTransformSystem
if (!component._anchored)
return;
MapGridComponent? grid;
Entity<MapGridComponent>? grid = null;
// First try find grid via parent:
if (component.GridUid == component.ParentUid && TryComp(component.ParentUid, out MapGridComponent? gridComp))
{
grid = gridComp;
grid = (component.ParentUid, gridComp);
}
else
{
// Entity may not be directly parented to the grid (e.g., spawned using some relative entity coordinates)
// in that case, we attempt to attach to a grid.
var pos = new MapCoordinates(GetWorldPosition(component), component.MapID);
_mapManager.TryFindGridAt(pos, out _, out grid);
if (_mapManager.TryFindGridAt(pos, out var gridUid, out gridComp))
grid = (gridUid, gridComp);
}
if (grid == null)
@@ -270,7 +271,7 @@ public abstract partial class SharedTransformSystem
return;
}
if (!AnchorEntity(uid, component, grid))
if (!AnchorEntity((uid, component), grid))
component._anchored = false;
}
@@ -308,7 +309,7 @@ public abstract partial class SharedTransformSystem
if (xform.Anchored)
{
DebugTools.Assert(xform.ParentUid == xform.GridUid && xform.ParentUid.IsValid());
var anchorEv = new AnchorStateChangedEvent(xform);
var anchorEv = new AnchorStateChangedEvent(uid, xform);
RaiseLocalEvent(uid, ref anchorEv, true);
}
@@ -746,7 +747,7 @@ public abstract partial class SharedTransformSystem
if (oldAnchored != newState.Anchored && xform.Initialized)
{
var ev = new AnchorStateChangedEvent(xform);
var ev = new AnchorStateChangedEvent(uid, xform);
RaiseLocalEvent(uid, ref ev, true);
}
@@ -934,7 +935,7 @@ public abstract partial class SharedTransformSystem
// Entity was not actually in the transform hierarchy. This is probably a sign that something is wrong, or that the function is being misused.
Log.Warning($"Target entity ({ToPrettyString(relative)}) not in transform hierarchy while calling {nameof(GetRelativePositionRotation)}.");
var relXform = query.GetComponent(relative);
pos = Vector2.Transform(pos, relXform.InvWorldMatrix);
pos = Vector2.Transform(pos, GetInvWorldMatrix(relXform));
rot = rot - GetWorldRotation(relXform, query);
break;
}
@@ -976,10 +977,11 @@ public abstract partial class SharedTransformSystem
public void SetWorldPosition(EntityUid uid, Vector2 worldPos)
{
var xform = XformQuery.GetComponent(uid);
SetWorldPosition(xform, worldPos);
SetWorldPosition((uid, xform), worldPos);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Obsolete("Use overload that takes Entity<T> instead")]
public void SetWorldPosition(TransformComponent component, Vector2 worldPos)
{
SetWorldPosition((component.Owner, component), worldPos);
@@ -1313,10 +1315,9 @@ public abstract partial class SharedTransformSystem
{
newParent = gridUid;
}
else if (_mapManager.GetMapEntityId(xform.MapID) is { Valid: true } mapEnt
&& !TerminatingOrDeleted(mapEnt))
else if (_map.TryGetMap(xform.MapID, out var mapEnt) && !TerminatingOrDeleted(mapEnt))
{
newParent = mapEnt;
newParent = mapEnt.Value;
}
else
{
@@ -1446,7 +1447,7 @@ public abstract partial class SharedTransformSystem
var tileIndices = _map.TileIndicesFor(xform.GridUid.Value, grid, xform.Coordinates);
_map.RemoveFromSnapGridCell(xform.GridUid.Value, grid, tileIndices, uid);
xform._anchored = false;
var anchorStateChangedEvent = new AnchorStateChangedEvent(xform, true);
var anchorStateChangedEvent = new AnchorStateChangedEvent(uid, xform, true);
RaiseLocalEvent(uid, ref anchorStateChangedEvent, true);
}

View File

@@ -12,7 +12,8 @@ namespace Robust.Shared.Map
{
IoCManager.Resolve(ref entityManager, ref mapManager);
var gridId = coords.GetGridUid(entityManager);
var xform = entityManager.System<SharedTransformSystem>();
var gridId = xform.GetGrid(coords);
var mapSystem = entityManager.System<SharedMapSystem>();
if (entityManager.TryGetComponent<MapGridComponent>(gridId, out var mapGrid))
@@ -20,8 +21,7 @@ namespace Robust.Shared.Map
return mapSystem.GridTileToLocal(gridId.Value, mapGrid, mapSystem.CoordinatesToTile(gridId.Value, mapGrid, coords));
}
var transformSystem = entityManager.System<SharedTransformSystem>();
var mapCoords = coords.ToMap(entityManager, transformSystem);
var mapCoords = xform.ToMapCoordinates(coords);
if (mapManager.TryFindGridAt(mapCoords, out var gridUid, out mapGrid))
{
@@ -49,7 +49,8 @@ namespace Robust.Shared.Map
// TODO: Use CollisionManager to get nearest edge.
// figure out closest intersect
var gridIntersect = gridSearchBox.Intersect(gridXform.WorldMatrix.TransformBox(grid.Comp.LocalAABB));
var worldMatrix = xform.GetWorldMatrix(gridXform);
var gridIntersect = gridSearchBox.Intersect(worldMatrix.TransformBox(grid.Comp.LocalAABB));
var gridDist = (gridIntersect.Center - mapCoords.Position).LengthSquared();
if (gridDist >= distance)

View File

@@ -143,14 +143,14 @@ namespace Robust.Shared.Map
return new Vector2i();
var mapSystem = entityManager.System<SharedMapSystem>();
var gridIdOpt = GetGridUid(entityManager);
var gridIdOpt = transformSystem.GetGrid(this);
if (gridIdOpt is { } gridId && gridId.IsValid())
{
var grid = entityManager.GetComponent<MapGridComponent>(gridId);
return mapSystem.GetTileRef(gridId, grid, this).GridIndices;
}
var vec = ToMapPos(entityManager, transformSystem);
var vec = transformSystem.ToMapCoordinates(this);
return new Vector2i((int)MathF.Floor(vec.X), (int)MathF.Floor(vec.Y));
}
@@ -334,8 +334,8 @@ namespace Robust.Shared.Map
return true;
}
var mapCoordinates = ToMap(entityManager, transformSystem);
var otherMapCoordinates = otherCoordinates.ToMap(entityManager, transformSystem);
var mapCoordinates = transformSystem.ToMapCoordinates(this);
var otherMapCoordinates = transformSystem.ToMapCoordinates(otherCoordinates);
if (mapCoordinates.MapId != otherMapCoordinates.MapId)
return false;

View File

@@ -115,7 +115,7 @@ internal static class HappyEyeballsHttp
await socket.ConnectAsync(new IPEndPoint(address, port), cancel).ConfigureAwait(false);
return socket;
}
catch (Exception e)
catch (Exception)
{
// Log.Verbose(e, "Happy Eyeballs to {Address} [{Index}] failed", address, index);
socket.Dispose();

View File

@@ -1,6 +1,6 @@
using System;
using System.Buffers;
using System.Runtime.InteropServices;
using System.Buffers.Binary;
using System.Threading;
using Lidgren.Network;
using SpaceWizards.Sodium;
@@ -60,11 +60,10 @@ internal sealed class NetEncryption
ciphertext = message.Data = new byte[encryptedSize];
}
// TODO: this is probably broken for big-endian machines.
Span<byte> nonceData = stackalloc byte[CryptoAeadXChaCha20Poly1305Ietf.NoncePublicBytes];
nonceData.Fill(0);
MemoryMarshal.Write(nonceData, ref nonce);
MemoryMarshal.Write(ciphertext, ref nonce);
BinaryPrimitives.WriteUInt64LittleEndian(nonceData, nonce);
BinaryPrimitives.WriteUInt64LittleEndian(ciphertext, nonce);
CryptoAeadXChaCha20Poly1305Ietf.Encrypt(
// ciphertext
@@ -93,10 +92,9 @@ internal sealed class NetEncryption
var buffer = ArrayPool<byte>.Shared.Rent(cipherText.Length);
cipherText.CopyTo(buffer);
// TODO: this is probably broken for big-endian machines.
Span<byte> nonceData = stackalloc byte[CryptoAeadXChaCha20Poly1305Ietf.NoncePublicBytes];
nonceData.Fill(0);
MemoryMarshal.Write(nonceData, ref nonce);
BinaryPrimitives.WriteUInt64LittleEndian(nonceData, nonce);
var result = CryptoAeadXChaCha20Poly1305Ietf.Decrypt(
// plaintext

View File

@@ -17,8 +17,8 @@ namespace Robust.Shared.Physics.Controllers;
public sealed class Gravity2DController : VirtualController
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
private ISawmill _sawmill = default!;
@@ -72,7 +72,7 @@ public sealed class Gravity2DController : VirtualController
public void SetGravity(MapId mapId, Vector2 value)
{
var mapUid = _mapManager.GetMapEntityId(mapId);
var mapUid = _mapSystem.GetMap(mapId);
var gravity = EnsureComp<Gravity2DComponent>(mapUid);
if (gravity.Gravity.Equals(value))

View File

@@ -53,7 +53,7 @@ public partial class SharedPhysicsSystem
{
if (component.BodyType != BodyType.Static)
{
SetAwake(uid, component, true);
SetAwake((uid, component), true);
}
}
@@ -491,14 +491,14 @@ public partial class SharedPhysicsSystem
if (body.BodyType == BodyType.Static)
{
SetAwake(uid, body, false);
SetAwake((uid, body), false);
body.LinearVelocity = Vector2.Zero;
body.AngularVelocity = 0.0f;
}
// Even if it's dynamic if it can't collide then don't force it awake.
else if (body.CanCollide)
{
SetAwake(uid, body, true);
SetAwake((uid, body), true);
}
body.Force = Vector2.Zero;
@@ -571,7 +571,7 @@ public partial class SharedPhysicsSystem
body.CanCollide = value;
if (!value)
SetAwake(uid, body, false);
SetAwake((uid, body), false);
if (body.Initialized)
{
@@ -655,7 +655,7 @@ public partial class SharedPhysicsSystem
return;
if (!value)
SetAwake(uid, body, true);
SetAwake((uid, body), true);
body.SleepingAllowed = value;

View File

@@ -45,13 +45,15 @@ namespace Robust.Shared.Player
{
IoCManager.Resolve(ref entityManager, ref playerMan, ref cfgMan);
var transform = entityManager.GetComponent<TransformComponent>(origin);
return AddPlayersByPvs(transform.MapPosition, rangeMultiplier, entityManager, playerMan, cfgMan);
var transformSystem = entityManager.System<SharedTransformSystem>();
return AddPlayersByPvs(transformSystem.GetMapCoordinates(transform), rangeMultiplier, entityManager, playerMan, cfgMan);
}
/// <summary>
/// Adds all players inside an entity's PVS.
/// The current PVS range will be multiplied by <see cref="rangeMultiplier"/>.
/// </summary>
[Obsolete("Use overload that takes in managers")]
public Filter AddPlayersByPvs(TransformComponent origin, float rangeMultiplier = 2f)
{
return AddPlayersByPvs(origin.MapPosition, rangeMultiplier);
@@ -64,7 +66,8 @@ namespace Robust.Shared.Player
public Filter AddPlayersByPvs(EntityCoordinates origin, float rangeMultiplier = 2f, IEntityManager? entityMan = null, ISharedPlayerManager? playerMan = null)
{
IoCManager.Resolve(ref entityMan, ref playerMan);
return AddPlayersByPvs(origin.ToMap(entityMan, entityMan.System<SharedTransformSystem>()), rangeMultiplier, entityMan, playerMan);
var system = entityMan.System<SharedTransformSystem>();
return AddPlayersByPvs(system.ToMapCoordinates(origin), rangeMultiplier, entityMan, playerMan);
}
/// <summary>
@@ -168,12 +171,13 @@ namespace Robust.Shared.Player
{
IoCManager.Resolve(ref playerMan, ref entMan);
var xformQuery = entMan.GetEntityQuery<TransformComponent>();
var xformSystem = entMan.System<SharedTransformSystem>();
return AddWhere(session =>
session.AttachedEntity != null &&
xformQuery.TryGetComponent(session.AttachedEntity.Value, out var xform) &&
xform.MapID == position.MapId &&
(xform.WorldPosition - position.Position).Length() < range, playerMan);
(xformSystem.GetWorldPosition(xform) - position.Position).Length() < range, playerMan);
}
/// <summary>
@@ -211,7 +215,7 @@ namespace Robust.Shared.Player
/// <summary>
/// Removes players from the filter.
/// </summary>
public Filter RemovePlayers(params ICommonSession[] players) => RemovePlayers(players);
public Filter RemovePlayers(params ICommonSession[] players) => RemovePlayers((IEnumerable<ICommonSession>) players);
/// <summary>
/// Removes a single player from the filter, specified by the entity to which they are attached.
@@ -232,7 +236,7 @@ namespace Robust.Shared.Player
/// <summary>
/// Removes players from the filter, specified by the entities to which they are attached.
/// </summary>
public Filter RemovePlayersByAttachedEntity(params EntityUid[] uids) => RemovePlayersByAttachedEntity(uids);
public Filter RemovePlayersByAttachedEntity(params EntityUid[] uids) => RemovePlayersByAttachedEntity((IEnumerable<EntityUid>) uids);
/// <summary>
/// Removes all players from the filter that match a predicate.
@@ -260,12 +264,13 @@ namespace Robust.Shared.Player
{
IoCManager.Resolve(ref entMan);
var xformQuery = entMan.GetEntityQuery<TransformComponent>();
var xformSystem = entMan.System<SharedTransformSystem>();
return RemoveWhere(session =>
session.AttachedEntity != null &&
xformQuery.TryGetComponent(session.AttachedEntity.Value, out var xform) &&
xform.MapID == position.MapId &&
(xform.WorldPosition - position.Position).Length() < range);
(xformSystem.GetWorldPosition(xform) - position.Position).Length() < range);
}
/// <summary>
@@ -370,6 +375,7 @@ namespace Robust.Shared.Player
/// <summary>
/// A filter with every player whose PVS overlaps this point.
/// </summary>
[Obsolete("Use overload that takes in managers")]
public static Filter Pvs(TransformComponent origin, float rangeMultiplier = 2f)
{
return Empty().AddPlayersByPvs(origin, rangeMultiplier);

View File

@@ -18,7 +18,7 @@ namespace Robust.Shared.Serialization.TypeSerializers.Implementations
ISerializationContext? context = null,
ISerializationManager.InstantiationDelegate<FormattedMessage>? instanceProvider = null)
{
return FormattedMessage.FromMarkup(node.Value);
return FormattedMessage.FromMarkupOrThrow(node.Value);
}
public ValidationNode Validate(ISerializationManager serializationManager, ValueDataNode node,

View File

@@ -16,12 +16,15 @@ internal sealed class BuildInfoCommand : ToolshedCommand
public void BuildInfo([CommandInvocationContext] IInvocationContext ctx)
{
var game = _cfg.GetCVar(CVars.BuildForkId);
ctx.WriteLine(FormattedMessage.FromMarkup($"[color={Gold}]Game:[/color] {game}"));
var buildCommit = _cfg.GetCVar(CVars.BuildHash);
ctx.WriteLine(FormattedMessage.FromMarkup($"[color={Gold}]Build commit:[/color] {buildCommit}"));
var buildManifest = _cfg.GetCVar(CVars.BuildManifestHash);
ctx.WriteLine(FormattedMessage.FromMarkup($"[color={Gold}]Manifest hash:[/color] {buildManifest}"));
var engine = _cfg.GetCVar(CVars.BuildEngineVersion);
ctx.WriteLine(FormattedMessage.FromMarkup($"[color={Gold}]Engine ver:[/color] {engine}"));
ctx.WriteLine(FormattedMessage.FromMarkupOrThrow($"""
[color={Gold}]Game:[/color] {game}
[color={Gold}]Build commit:[/color] {buildCommit}
[color={Gold}]Manifest hash:[/color] {buildManifest}
[color={Gold}]Engine ver:[/color] {engine}
"""));
}
}

View File

@@ -8,7 +8,7 @@ public sealed class NotForServerConsoleError : IConError
{
public FormattedMessage DescribeInner()
{
return FormattedMessage.FromMarkup(
return FormattedMessage.FromMarkupOrThrow(
"You must be logged in with a client to use this, the server console isn't workable.");
}

View File

@@ -9,7 +9,7 @@ public record SessionHasNoEntityError(ICommonSession Session) : IConError
{
public FormattedMessage DescribeInner()
{
return FormattedMessage.FromMarkup($"The user {Session.Name} has no attached entity.");
return FormattedMessage.FromMarkupOrThrow($"The user {Session.Name} has no attached entity.");
}
public string? Expression { get; set; }

View File

@@ -82,7 +82,7 @@ public interface IInvocationContext
/// </remarks>
public void WriteMarkup(string markup)
{
WriteLine(FormattedMessage.FromMarkup(markup));
WriteLine(FormattedMessage.FromMarkupPermissive(markup));
}
/// <summary>

View File

@@ -352,7 +352,7 @@ public record OutOfInputError : IConError
{
public FormattedMessage DescribeInner()
{
return FormattedMessage.FromMarkup("Ran out of input data when data was expected.");
return FormattedMessage.FromMarkupOrThrow("Ran out of input data when data was expected.");
}
public string? Expression { get; set; }

View File

@@ -103,7 +103,7 @@ public record BadVarTypeError(Type Got, Type Expected, string VarName) : IConErr
{
public FormattedMessage DescribeInner()
{
return FormattedMessage.FromMarkup(
return FormattedMessage.FromMarkupOrThrow(
$"Got unexpected type {Got.PrettyName()} in {VarName}, expected {Expected.PrettyName()}");
}

View File

@@ -93,7 +93,7 @@ public record struct StringMustStartWithQuote : IConError
{
public FormattedMessage DescribeInner()
{
return FormattedMessage.FromMarkup("A string must start with a quote.");
return FormattedMessage.FromMarkupOrThrow("A string must start with a quote.");
}
public string? Expression { get; set; }

View File

@@ -271,30 +271,34 @@ public sealed class ZStdDecompressStream : Stream
return 0;
}
unsafe
{
fixed (byte* inputPtr = _buffer)
fixed (byte* outputPtr = buffer.Span)
{
ZSTD_outBuffer outputBuf = default;
outputBuf.dst = outputPtr;
outputBuf.pos = 0;
outputBuf.size = (nuint)buffer.Length;
ZSTD_inBuffer inputBuf = default;
inputBuf.src = inputPtr;
inputBuf.pos = (nuint)_bufferPos;
inputBuf.size = (nuint)_bufferSize;
var ret = DecompressChunk(this, buffer.Span);
if (ret > 0)
return (int)ret;
var ret = ZSTD_decompressStream(_ctx, &outputBuf, &inputBuf);
_bufferPos = (int)inputBuf.pos;
ZStdException.ThrowIfError(ret);
if (outputBuf.pos > 0)
return (int)outputBuf.pos;
}
}
} while (true);
static unsafe nuint DecompressChunk(ZStdDecompressStream stream, Span<byte> buffer)
{
fixed (byte* inputPtr = stream._buffer)
fixed (byte* outputPtr = buffer)
{
ZSTD_outBuffer outputBuf = default;
outputBuf.dst = outputPtr;
outputBuf.pos = 0;
outputBuf.size = (nuint)buffer.Length;
ZSTD_inBuffer inputBuf = default;
inputBuf.src = inputPtr;
inputBuf.pos = (nuint)stream._bufferPos;
inputBuf.size = (nuint)stream._bufferSize;
var ret = ZSTD_decompressStream(stream._ctx, &outputBuf, &inputBuf);
stream._bufferPos = (int)inputBuf.pos;
ZStdException.ThrowIfError(ret);
return outputBuf.pos;
}
}
}
public override long Seek(long offset, SeekOrigin origin)

View File

@@ -14,7 +14,7 @@ internal abstract partial class ViewVariablesManager
if (_typeHandlers.TryGetValue(typeof(T), out var h))
return (ViewVariablesTypeHandler<T>)h;
var handler = new ViewVariablesTypeHandler<T>();
var handler = new ViewVariablesTypeHandler<T>(Sawmill);
_typeHandlers.Add(typeof(T), handler);
return handler;
}

View File

@@ -31,9 +31,11 @@ public sealed class ViewVariablesTypeHandler<T> : ViewVariablesTypeHandler
{
private readonly List<TypeHandlerData> _handlers = new();
private readonly Dictionary<string, PathHandler> _paths = new();
private readonly ISawmill _sawmill;
internal ViewVariablesTypeHandler()
internal ViewVariablesTypeHandler(ISawmill sawmill)
{
_sawmill = sawmill;
}
/// <summary>
@@ -210,7 +212,9 @@ public sealed class ViewVariablesTypeHandler<T> : ViewVariablesTypeHandler
}
catch (NullReferenceException e)
{
Logger.ErrorS(nameof(ViewVariablesManager), e,
_sawmill.Log(
LogLevel.Error,
e,
$"NRE caught in setter for path \"{path}\" for type \"{typeof(T).Name}\"...");
}
});

View File

@@ -8,6 +8,7 @@ using Robust.Server.Debugging;
using Robust.Server.GameObjects;
using Robust.Server.GameStates;
using Robust.Server.Physics;
using Robust.Shared.ComponentTrees;
using Robust.Shared.Configuration;
using Robust.Shared.Containers;
using Robust.Shared.ContentPack;
@@ -26,6 +27,7 @@ using Robust.Shared.Threading;
using Robust.Shared.Utility;
using InputSystem = Robust.Server.GameObjects.InputSystem;
using MapSystem = Robust.Server.GameObjects.MapSystem;
using PointLightComponent = Robust.Client.GameObjects.PointLightComponent;
namespace Robust.UnitTesting
{
@@ -126,8 +128,8 @@ namespace Robust.UnitTesting
if (Project == UnitTestProject.Client)
{
systems.LoadExtraSystemType<ClientMetaDataSystem>();
systems.LoadExtraSystemType<Robust.Server.Containers.ContainerSystem>();
systems.LoadExtraSystemType<Robust.Server.GameObjects.TransformSystem>();
systems.LoadExtraSystemType<ContainerSystem>();
systems.LoadExtraSystemType<Robust.Client.GameObjects.TransformSystem>();
systems.LoadExtraSystemType<Robust.Client.Physics.BroadPhaseSystem>();
systems.LoadExtraSystemType<Robust.Client.Physics.JointSystem>();
systems.LoadExtraSystemType<Robust.Client.Physics.PhysicsSystem>();
@@ -135,6 +137,12 @@ namespace Robust.UnitTesting
systems.LoadExtraSystemType<PrototypeReloadSystem>();
systems.LoadExtraSystemType<Robust.Client.Debugging.DebugPhysicsSystem>();
systems.LoadExtraSystemType<Robust.Client.GameObjects.MapSystem>();
systems.LoadExtraSystemType<Robust.Client.GameObjects.PointLightSystem>();
systems.LoadExtraSystemType<LightTreeSystem>();
systems.LoadExtraSystemType<RecursiveMoveSystem>();
systems.LoadExtraSystemType<SpriteSystem>();
systems.LoadExtraSystemType<SpriteTreeSystem>();
systems.LoadExtraSystemType<GridChunkBoundsDebugSystem>();
}
else
{
@@ -171,6 +179,11 @@ namespace Robust.UnitTesting
compFactory.RegisterClass<MapSaveTileMapComponent>();
compFactory.RegisterClass<MapSaveIdComponent>();
}
else
{
compFactory.RegisterClass<PointLightComponent>();
compFactory.RegisterClass<SpriteComponent>();
}
deps.Resolve<IParallelManagerInternal>().Initialize();