mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Fix some issues Sonar caught.
This commit is contained in:
@@ -925,7 +925,7 @@ namespace Robust.Client.GameObjects
|
||||
}
|
||||
|
||||
var theLayer = Layers[layer];
|
||||
if (theLayer.State == null)
|
||||
if (theLayer.State.IsValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Robust.Client.GameStates
|
||||
private int _warningPayloadSize;
|
||||
private int _midrangePayloadSize;
|
||||
|
||||
private List<(GameTick Tick, int Payload, int lag, int interp)> _history = new List<(GameTick Tick, int Payload, int lag, int interp)>(HistorySize+10);
|
||||
private readonly List<(GameTick Tick, int Payload, int lag, int interp)> _history = new List<(GameTick Tick, int Payload, int lag, int interp)>(HistorySize+10);
|
||||
|
||||
public NetGraphOverlay() : base(nameof(NetGraphOverlay))
|
||||
{
|
||||
|
||||
@@ -26,7 +26,9 @@ namespace Robust.Client.ResourceManagement
|
||||
|
||||
var loadParameters = _tryLoadTextureParameters(cache, path) ?? TextureLoadParameters.Default;
|
||||
|
||||
_loadOpenGL(cache, stream, path, loadParameters);
|
||||
var manager = IoCManager.Resolve<IClyde>();
|
||||
|
||||
Texture = manager.LoadTextureFromPNGStream(stream, path.ToString(), loadParameters);
|
||||
}
|
||||
|
||||
private static TextureLoadParameters? _tryLoadTextureParameters(IResourceCache cache, ResourcePath path)
|
||||
@@ -52,13 +54,6 @@ namespace Robust.Client.ResourceManagement
|
||||
return null;
|
||||
}
|
||||
|
||||
private void _loadOpenGL(IResourceCache cache, Stream stream, ResourcePath path, TextureLoadParameters? parameters)
|
||||
{
|
||||
var manager = IoCManager.Resolve<IClyde>();
|
||||
|
||||
Texture = manager.LoadTextureFromPNGStream(stream, path.ToString(), parameters);
|
||||
}
|
||||
|
||||
public static implicit operator Texture(TextureResource res)
|
||||
{
|
||||
return res?.Texture;
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
/// </summary>
|
||||
public abstract class MenuEntry
|
||||
{
|
||||
internal MenuEntry()
|
||||
private protected MenuEntry()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
private readonly IPlayerManager playerManager;
|
||||
private readonly IEyeManager eyeManager;
|
||||
private readonly IInputManager inputManager;
|
||||
private readonly IResourceCache resourceCache;
|
||||
private readonly IStateManager stateManager;
|
||||
private readonly IClyde _displayManager;
|
||||
private readonly IMapManager _mapManager;
|
||||
@@ -35,7 +34,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
public DebugCoordsPanel(IPlayerManager playerMan,
|
||||
IEyeManager eyeMan,
|
||||
IInputManager inputMan,
|
||||
IResourceCache resCache,
|
||||
IStateManager stateMan,
|
||||
IClyde displayMan,
|
||||
IMapManager mapMan)
|
||||
@@ -43,7 +41,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
playerManager = playerMan;
|
||||
eyeManager = eyeMan;
|
||||
inputManager = inputMan;
|
||||
resourceCache = resCache;
|
||||
stateManager = stateMan;
|
||||
_displayManager = displayMan;
|
||||
_mapManager = mapMan;
|
||||
|
||||
@@ -58,9 +58,11 @@ Total Allocated: {FormatBytes(GC.GetTotalMemory(false))}";
|
||||
#endif
|
||||
}
|
||||
|
||||
#if NETCOREAPP
|
||||
private static string FormatBytes(long bytes)
|
||||
{
|
||||
return $"{bytes / 1024} KiB";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,20 +32,18 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
private readonly IPlayerManager _playerManager;
|
||||
private readonly IEyeManager _eyeManager;
|
||||
private readonly IInputManager _inputManager;
|
||||
private readonly IResourceCache _resourceCache;
|
||||
private readonly IStateManager _stateManager;
|
||||
private readonly IClyde _displayManager;
|
||||
private readonly IClientNetManager _netManager;
|
||||
private readonly IMapManager _mapManager;
|
||||
|
||||
//TODO: Think about a factory for this
|
||||
public DebugMonitors(IGameTiming gameTiming, IPlayerManager playerManager, IEyeManager eyeManager, IInputManager inputManager, IResourceCache resourceCache, IStateManager stateManager, IClyde displayManager, IClientNetManager netManager, IMapManager mapManager)
|
||||
public DebugMonitors(IGameTiming gameTiming, IPlayerManager playerManager, IEyeManager eyeManager, IInputManager inputManager, IStateManager stateManager, IClyde displayManager, IClientNetManager netManager, IMapManager mapManager)
|
||||
{
|
||||
_gameTiming = gameTiming;
|
||||
_playerManager = playerManager;
|
||||
_eyeManager = eyeManager;
|
||||
_inputManager = inputManager;
|
||||
_resourceCache = resourceCache;
|
||||
_stateManager = stateManager;
|
||||
_displayManager = displayManager;
|
||||
_netManager = netManager;
|
||||
@@ -71,14 +69,13 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
_fpsCounter = new FpsCounter(_gameTiming);
|
||||
AddChild(_fpsCounter);
|
||||
|
||||
_debugCoordsPanel = new DebugCoordsPanel(_playerManager, _eyeManager, _inputManager,
|
||||
_resourceCache, _stateManager, _displayManager, _mapManager);
|
||||
_debugCoordsPanel = new DebugCoordsPanel(_playerManager, _eyeManager, _inputManager, _stateManager, _displayManager, _mapManager);
|
||||
AddChild(_debugCoordsPanel);
|
||||
|
||||
_debugNetPanel = new DebugNetPanel(_netManager, _gameTiming, _resourceCache);
|
||||
_debugNetPanel = new DebugNetPanel(_netManager, _gameTiming);
|
||||
AddChild(_debugNetPanel);
|
||||
|
||||
_timeDebug = new DebugTimePanel(_resourceCache, _gameTiming)
|
||||
_timeDebug = new DebugTimePanel(_gameTiming)
|
||||
{
|
||||
Visible = false,
|
||||
};
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
|
||||
private readonly IClientNetManager NetManager;
|
||||
private readonly IGameTiming GameTiming;
|
||||
private readonly IResourceCache resourceCache;
|
||||
|
||||
private TimeSpan LastUpdate;
|
||||
private Label contents;
|
||||
@@ -31,11 +30,10 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
private long LastSentPackets;
|
||||
private long LastReceivedPackets;
|
||||
|
||||
public DebugNetPanel(IClientNetManager netMan, IGameTiming gameTiming, IResourceCache resCache)
|
||||
public DebugNetPanel(IClientNetManager netMan, IGameTiming gameTiming)
|
||||
{
|
||||
NetManager = netMan;
|
||||
GameTiming = gameTiming;
|
||||
resourceCache = resCache;
|
||||
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
@@ -11,14 +11,12 @@ namespace Robust.Client.UserInterface.CustomControls
|
||||
{
|
||||
public class DebugTimePanel : Panel
|
||||
{
|
||||
private readonly IResourceCache _resourceCache;
|
||||
private readonly IGameTiming _gameTiming;
|
||||
|
||||
private Label _contents;
|
||||
|
||||
public DebugTimePanel(IResourceCache resourceCache, IGameTiming gameTiming)
|
||||
public DebugTimePanel(IGameTiming gameTiming)
|
||||
{
|
||||
_resourceCache = resourceCache;
|
||||
_gameTiming = gameTiming;
|
||||
|
||||
PerformLayout();
|
||||
|
||||
@@ -76,8 +76,7 @@ namespace Robust.Client.UserInterface
|
||||
DebugConsole = new DebugConsole(_console, _resourceManager);
|
||||
RootControl.AddChild(DebugConsole);
|
||||
|
||||
_debugMonitors = new DebugMonitors(_gameTiming, _playerManager, _eyeManager, _inputManager,
|
||||
_resourceCache, _stateManager, _displayManager, _netManager, _mapManager);
|
||||
_debugMonitors = new DebugMonitors(_gameTiming, _playerManager, _eyeManager, _inputManager, _stateManager, _displayManager, _netManager, _mapManager);
|
||||
RootControl.AddChild(_debugMonitors);
|
||||
|
||||
_inputManager.SetInputCommand(EngineKeyFunctions.ShowDebugMonitors,
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Server.GameObjects;
|
||||
using System;
|
||||
using Robust.Server.Interfaces;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
@@ -38,14 +35,11 @@ namespace Robust.Server.Player
|
||||
UpdatePlayerState();
|
||||
}
|
||||
|
||||
[ViewVariables]
|
||||
public INetChannel ConnectedClient { get; }
|
||||
[ViewVariables] public INetChannel ConnectedClient { get; }
|
||||
|
||||
[ViewVariables]
|
||||
public IEntity AttachedEntity { get; private set; }
|
||||
[ViewVariables] public IEntity AttachedEntity { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
public EntityUid? AttachedEntityUid => AttachedEntity?.Uid;
|
||||
[ViewVariables] public EntityUid? AttachedEntityUid => AttachedEntity?.Uid;
|
||||
|
||||
private SessionStatus _status = SessionStatus.Connecting;
|
||||
|
||||
@@ -57,7 +51,16 @@ namespace Robust.Server.Player
|
||||
public SessionStatus Status
|
||||
{
|
||||
get => _status;
|
||||
set => OnPlayerStatusChanged(_status, value);
|
||||
set
|
||||
{
|
||||
if (_status == value)
|
||||
return;
|
||||
|
||||
_status = value;
|
||||
UpdatePlayerState();
|
||||
|
||||
PlayerStatusChanged?.Invoke(this, new SessionStatusEventArgs(this, _status, value));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -68,23 +71,11 @@ namespace Robust.Server.Player
|
||||
public NetSessionId SessionId { get; }
|
||||
|
||||
readonly PlayerData _data;
|
||||
[ViewVariables]
|
||||
public IPlayerData Data => _data;
|
||||
[ViewVariables] public IPlayerData Data => _data;
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<SessionStatusEventArgs> PlayerStatusChanged;
|
||||
|
||||
private void OnPlayerStatusChanged(SessionStatus oldStatus, SessionStatus newStatus)
|
||||
{
|
||||
if (oldStatus == newStatus)
|
||||
return;
|
||||
|
||||
_status = newStatus;
|
||||
UpdatePlayerState();
|
||||
|
||||
PlayerStatusChanged?.Invoke(this, new SessionStatusEventArgs(this, oldStatus, newStatus));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AttachToEntity(IEntity a)
|
||||
{
|
||||
@@ -107,7 +98,7 @@ namespace Robust.Server.Player
|
||||
/// <inheritdoc />
|
||||
public void DetachFromEntity()
|
||||
{
|
||||
if(AttachedEntity == null)
|
||||
if (AttachedEntity == null)
|
||||
return;
|
||||
|
||||
if (AttachedEntity.Deleted)
|
||||
@@ -127,7 +118,6 @@ namespace Robust.Server.Player
|
||||
{
|
||||
throw new InvalidOperationException("Tried to detach player, but entity does not have ActorComponent!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace Robust.Shared
|
||||
[Conditional("NETCOREAPP")]
|
||||
public static void RegisterSimpleMap(Assembly assembly, string baseName)
|
||||
{
|
||||
// On .NET Framework this doesn't need to run because:
|
||||
// On Windows, the DLL names should check out correctly to just work.
|
||||
// On Linux/macOS, Mono's DllMap handles it for us.
|
||||
#if NETCOREAPP
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
@@ -50,6 +53,9 @@ namespace Robust.Shared
|
||||
[Conditional("NETCOREAPP")]
|
||||
public static void RegisterExplicitMap(Assembly assembly, string baseName, string linuxName, string macName)
|
||||
{
|
||||
// On .NET Framework this doesn't need to run because:
|
||||
// On Windows, the DLL names should check out correctly to just work.
|
||||
// On Linux/macOS, Mono's DllMap handles it for us.
|
||||
#if NETCOREAPP
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user