Change cvar usages to use CVarDef and define them in CVars (#1330)

Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
DrSmugleaf
2020-10-24 15:40:06 +02:00
committed by GitHub
parent 2c999faea5
commit 6bbc4b01e9
30 changed files with 363 additions and 228 deletions

View File

@@ -6,6 +6,7 @@ using Robust.Client.Interfaces.GameObjects;
using Robust.Client.Interfaces.GameStates;
using Robust.Client.Interfaces.Utility;
using Robust.Client.Player;
using Robust.Shared;
using Robust.Shared.Enums;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.Map;
@@ -75,7 +76,7 @@ namespace Robust.Client
OnRunLevelChanged(ClientRunLevel.Connecting);
_net.ClientConnect(endPoint.Host, endPoint.Port,
PlayerNameOverride ?? _configManager.GetCVar<string>("player.name"));
PlayerNameOverride ?? _configManager.GetCVar(CVars.PlayerName));
}
/// <inheritdoc />

View File

@@ -10,9 +10,8 @@ using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using Robust.Shared.Network.Messages;
using Robust.Client.Player;
using Robust.Shared.Configuration;
using Robust.Shared;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Input;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.GameObjects;
@@ -79,18 +78,18 @@ namespace Robust.Client.GameStates
_network.RegisterNetMessage<MsgStateAck>(MsgStateAck.NAME);
_client.RunLevelChanged += RunLevelChanged;
_config.RegisterCVar("net.interp", true, CVar.ARCHIVE, b => _processor.Interpolation = b);
_config.RegisterCVar("net.interp_ratio", 0, CVar.ARCHIVE, i => _processor.InterpRatio = i);
_config.RegisterCVar("net.logging", false, CVar.ARCHIVE, b => _processor.Logging = b);
_config.RegisterCVar("net.predict", true, CVar.ARCHIVE, b => Predicting = b);
_config.RegisterCVar("net.predict_size", 1, CVar.ARCHIVE, i => PredictSize = i);
_config.RegisterCVar("net.state_buf_merge_threshold", 5, CVar.ARCHIVE, i => StateBufferMergeThreshold = i);
_config.OnValueChanged(CVars.NetInterp, b => _processor.Interpolation = b, true);
_config.OnValueChanged(CVars.NetInterpRatio, i => _processor.InterpRatio = i, true);
_config.OnValueChanged(CVars.NetLogging, b => _processor.Logging = b, true);
_config.OnValueChanged(CVars.NetPredict, b => Predicting = b, true);
_config.OnValueChanged(CVars.NetPredictSize, i => PredictSize = i, true);
_config.OnValueChanged(CVars.NetStateBufMergeThreshold, i => StateBufferMergeThreshold = i, true);
_processor.Interpolation = _config.GetCVar<bool>("net.interp");
_processor.InterpRatio = _config.GetCVar<int>("net.interp_ratio");
_processor.Logging = _config.GetCVar<bool>("net.logging");
Predicting = _config.GetCVar<bool>("net.predict");
PredictSize = _config.GetCVar<int>("net.predict_size");
_processor.Interpolation = _config.GetCVar(CVars.NetInterp);
_processor.InterpRatio = _config.GetCVar(CVars.NetInterpRatio);
_processor.Logging = _config.GetCVar(CVars.NetLogging);
Predicting = _config.GetCVar(CVars.NetPredict);
PredictSize = _config.GetCVar(CVars.NetPredictSize);
}
/// <inheritdoc />
@@ -123,7 +122,7 @@ namespace Robust.Client.GameStates
var inputMan = IoCManager.Resolve<IInputManager>();
inputMan.NetworkBindMap.TryGetKeyFunction(message.InputFunctionId, out var boundFunc);
Logger.DebugS("net.predict",
Logger.DebugS(CVars.NetPredict.Name,
$"CL> SENT tick={_timing.CurTick}, sub={_timing.TickFraction}, seq={_nextInputCmdSeq}, func={boundFunc.FunctionName}, state={message.State}");
_nextInputCmdSeq++;
}
@@ -212,7 +211,7 @@ namespace Robust.Client.GameStates
if (_lastProcessedSeq < curState.LastProcessedInput)
{
Logger.DebugS("net.predict", $"SV> RCV tick={_timing.CurTick}, seq={_lastProcessedSeq}");
Logger.DebugS(CVars.NetPredict.Name, $"SV> RCV tick={_timing.CurTick}, seq={_lastProcessedSeq}");
_lastProcessedSeq = curState.LastProcessedInput;
}
}
@@ -231,7 +230,7 @@ namespace Robust.Client.GameStates
var inCmd = _pendingInputs.Dequeue();
_inputManager.NetworkBindMap.TryGetKeyFunction(inCmd.InputFunctionId, out var boundFunc);
Logger.DebugS("net.predict",
Logger.DebugS(CVars.NetPredict.Name,
$"SV> seq={inCmd.InputSequence}, func={boundFunc.FunctionName}, state={inCmd.State}");
}
@@ -249,7 +248,7 @@ namespace Robust.Client.GameStates
if (_pendingInputs.Count > 0)
{
Logger.DebugS("net.predict", "CL> Predicted:");
Logger.DebugS(CVars.NetPredict.Name, "CL> Predicted:");
}
var pendingInputEnumerator = _pendingInputs.GetEnumerator();
@@ -274,7 +273,7 @@ namespace Robust.Client.GameStates
_inputManager.NetworkBindMap.TryGetKeyFunction(inputCmd.InputFunctionId, out var boundFunc);
Logger.DebugS("net.predict",
Logger.DebugS(CVars.NetPredict.Name,
$" seq={inputCmd.InputSequence}, sub={inputCmd.SubTick}, dTick={tick}, func={boundFunc.FunctionName}, " +
$"state={inputCmd.State}");
@@ -315,7 +314,7 @@ namespace Robust.Client.GameStates
continue;
}
Logger.DebugS("net.predict", $"Entity {entity.Uid} was made dirty.");
Logger.DebugS(CVars.NetPredict.Name, $"Entity {entity.Uid} was made dirty.");
if (!_processor.TryGetLastServerStates(entity.Uid, out var last))
{
@@ -333,7 +332,7 @@ namespace Robust.Client.GameStates
continue;
}
Logger.DebugS("net.predict", $" And also its component {comp.Name}");
Logger.DebugS(CVars.NetPredict.Name, $" And also its component {comp.Name}");
// TODO: Handle interpolation.
comp.HandleComponentState(compState, null);
}

View File

@@ -9,6 +9,7 @@ using OpenToolkit.Audio.OpenAL;
using OpenToolkit.Audio.OpenAL.Extensions.Creative.EFX;
using Robust.Client.Audio;
using Robust.Client.Interfaces.Graphics;
using Robust.Shared;
using Robust.Shared.Log;
using Vector2 = Robust.Shared.Maths.Vector2;
@@ -76,8 +77,7 @@ namespace Robust.Client.Graphics.Clyde
private void _audioOpenDevice()
{
var preferredDevice = _configurationManager.GetCVar<string>("audio.device");
var preferredDevice = _configurationManager.GetCVar(CVars.AudioDevice);
// Open device.
if (!string.IsNullOrEmpty(preferredDevice))

View File

@@ -11,6 +11,7 @@ using Robust.Client.Input;
using Robust.Client.Interfaces.Graphics;
using Robust.Client.Interfaces.UserInterface;
using Robust.Client.Utility;
using Robust.Shared;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Maths;
@@ -140,8 +141,8 @@ namespace Robust.Client.Graphics.Clyde
private bool InitWindow()
{
var width = _configurationManager.GetCVar<int>("display.width");
var height = _configurationManager.GetCVar<int>("display.height");
var width = _configurationManager.GetCVar(CVars.DisplayWidth);
var height = _configurationManager.GetCVar(CVars.DisplayHeight);
Monitor* monitor = null;
@@ -159,7 +160,7 @@ namespace Robust.Client.Graphics.Clyde
GLFW.WindowHint(WindowHintString.X11ClassName, "SS14");
GLFW.WindowHint(WindowHintString.X11InstanceName, "SS14");
var renderer = (Renderer) _configurationManager.GetCVar<int>("display.renderer");
var renderer = (Renderer) _configurationManager.GetCVar<int>(CVars.DisplayRenderer);
Span<Renderer> renderers = (renderer == Renderer.Default) ? stackalloc Renderer[] {
Renderer.OpenGL33,

View File

@@ -12,10 +12,12 @@ using Robust.Client.Interfaces.Graphics.Overlays;
using Robust.Client.Interfaces.Map;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Interfaces.UserInterface;
using Robust.Shared;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Log;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
@@ -28,7 +30,7 @@ namespace Robust.Client.Graphics.Clyde
/// <summary>
/// Responsible for most things rendering on OpenGL mode.
/// </summary>
internal sealed partial class Clyde : ClydeBase, IClydeInternal, IClydeAudio
internal sealed partial class Clyde : ClydeBase, IClydeInternal, IClydeAudio, IPostInjectInit
{
[Dependency] private readonly IClydeTileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
@@ -91,6 +93,10 @@ namespace Robust.Client.Graphics.Clyde
public override bool Initialize()
{
base.Initialize();
_configurationManager.OnValueChanged(CVars.DisplayOGLCheckErrors, b => _checkGLErrors = b, true);
if (!InitWindowing())
{
return false;
@@ -126,8 +132,8 @@ namespace Robust.Client.Graphics.Clyde
protected override void ReadConfig()
{
base.ReadConfig();
_lightmapDivider = _configurationManager.GetCVar<int>("display.lightmapdivider");
_enableSoftShadows = _configurationManager.GetCVar<bool>("display.softshadows");
_lightmapDivider = _configurationManager.GetCVar(CVars.DisplayLightMapDivider);
_enableSoftShadows = _configurationManager.GetCVar(CVars.DisplaySoftShadows);
}
protected override void ReloadConfig()
@@ -137,20 +143,15 @@ namespace Robust.Client.Graphics.Clyde
RegenAllLightRts();
}
public override void PostInject()
public void PostInject()
{
base.PostInject();
_mapManager.TileChanged += _updateTileMapOnUpdate;
_mapManager.OnGridCreated += _updateOnGridCreated;
_mapManager.OnGridRemoved += _updateOnGridRemoved;
_mapManager.GridChanged += _updateOnGridModified;
_configurationManager.RegisterCVar("display.renderer", (int) Renderer.Default);
_configurationManager.RegisterCVar("display.ogl_check_errors", false, onValueChanged: b => _checkGLErrors = b);
// This cvar does not modify the actual GL version requested or anything,
// it overrides the version we detect to detect GL features.
_configurationManager.RegisterCVar("display.ogl_override_version", "");
RegisterBlockCVars();
}
@@ -242,7 +243,7 @@ namespace Robust.Client.Graphics.Clyde
private (int major, int minor)? ParseGLOverrideVersion()
{
var overrideGLVersion = _configurationManager.GetCVar<string>("display.ogl_override_version");
var overrideGLVersion = _configurationManager.GetCVar(CVars.DisplayOGLOverrideVersion);
if (string.IsNullOrEmpty(overrideGLVersion))
{
return null;

View File

@@ -66,6 +66,7 @@ namespace Robust.Client.Graphics.Clyde
public override bool Initialize()
{
base.Initialize();
return true;
}

View File

@@ -1,7 +1,7 @@
using System;
using Robust.Client.Interfaces;
using Robust.Client.Interfaces.Graphics;
using Robust.Shared.Configuration;
using Robust.Shared;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
@@ -18,31 +18,26 @@ namespace Robust.Client.Graphics
/// <summary>
/// Manages the game window, resolutions, fullscreen mode, VSync, etc...
/// </summary>
internal abstract class ClydeBase : IPostInjectInit
internal abstract class ClydeBase
{
private const string CVarVSync = "display.vsync";
private const string CVarWindowMode = "display.windowmode";
[Dependency] protected readonly IConfigurationManager _configurationManager = default!;
[Dependency] protected readonly IGameControllerInternal _gameController = default!;
protected WindowMode WindowMode { get; private set; } = WindowMode.Windowed;
protected bool VSync { get; private set; } = true;
public virtual void PostInject()
{
_configurationManager.RegisterCVar(CVarVSync, VSync, CVar.ARCHIVE, _vSyncChanged);
_configurationManager.RegisterCVar(CVarWindowMode, (int) WindowMode, CVar.ARCHIVE, _windowModeChanged);
_configurationManager.RegisterCVar("display.width", 1280);
_configurationManager.RegisterCVar("display.height", 720);
_configurationManager.RegisterCVar("display.lightmapdivider", 2, onValueChanged: LightmapDividerChanged);
_configurationManager.RegisterCVar("display.softshadows", true, onValueChanged: SoftShadowsChanged);
_configurationManager.RegisterCVar("audio.device", "");
}
public abstract Vector2i ScreenSize { get; }
public abstract void SetWindowTitle(string title);
public abstract bool Initialize();
public virtual bool Initialize()
{
_configurationManager.OnValueChanged(CVars.DisplayVSync, _vSyncChanged, true);
_configurationManager.OnValueChanged(CVars.DisplayWindowMode, _windowModeChanged, true);
_configurationManager.OnValueChanged(CVars.DisplayLightMapDivider, LightmapDividerChanged, true);
_configurationManager.OnValueChanged(CVars.DisplaySoftShadows, SoftShadowsChanged, true);
return true;
}
protected virtual void ReloadConfig()
{
@@ -53,8 +48,8 @@ namespace Robust.Client.Graphics
protected virtual void ReadConfig()
{
WindowMode = (WindowMode) _configurationManager.GetCVar<int>(CVarWindowMode);
VSync = _configurationManager.GetCVar<bool>(CVarVSync);
WindowMode = (WindowMode) _configurationManager.GetCVar(CVars.DisplayWindowMode);
VSync = _configurationManager.GetCVar(CVars.DisplayVSync);
}
private void _vSyncChanged(bool newValue)
@@ -69,7 +64,7 @@ namespace Robust.Client.Graphics
private void _windowModeChanged(int newValue)
{
WindowMode = (Graphics.WindowMode)newValue;
WindowMode = (WindowMode) newValue;
WindowModeChanged();
}

View File

@@ -12,11 +12,10 @@ using Robust.Shared.Utility;
using SharpFont;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
namespace Robust.Client.Graphics
{
internal sealed class FontManager : IFontManagerInternal, IPostInjectInit
internal sealed class FontManager : IFontManagerInternal
{
[Dependency] private readonly IConfigurationManager _configuration = default!;
@@ -41,7 +40,7 @@ namespace Robust.Client.Graphics
void IFontManagerInternal.Initialize()
{
BaseFontDPI = (uint) _configuration.GetCVar<int>("display.fontdpi");
BaseFontDPI = (uint) _configuration.GetCVar(CVars.DisplayFontDpi);
}
public IFontInstanceHandle MakeInstance(IFontFaceHandle handle, int size)
@@ -401,10 +400,5 @@ namespace Robust.Client.Graphics
// Maps glyph index to atlas.
public Dictionary<uint, AtlasTexture> AtlasData { get; }
}
void IPostInjectInit.PostInject()
{
_configuration.RegisterCVar("display.fontdpi", 96);
}
}
}

View File

@@ -3,6 +3,7 @@ using Robust.Client.Input;
using Robust.Client.Interfaces.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared;
using Robust.Shared.Input;
using Robust.Shared.Map;
using Robust.Shared.Maths;
@@ -33,8 +34,9 @@ namespace Robust.Client.Interfaces.UserInterface
Control? CurrentlyHovered { get; }
float UIScale { get; }
/// <summary>
/// Gets the default UIScale that we will use if <c>display.uiScale</c> gets set to 0.
/// Gets the default UIScale that we will use if <see cref="CVars.DisplayUIScale"/> gets set to 0.
/// Based on the OS-assigned window scale factor.
/// </summary>
float DefaultUIScale { get; }

View File

@@ -55,8 +55,6 @@ namespace Robust.Client.Player
/// <inheritdoc />
public void Initialize()
{
_config.RegisterCVar("player.name", "JoeGenero", CVar.ARCHIVE);
_network.RegisterNetMessage<MsgPlayerListReq>(MsgPlayerListReq.NAME);
_network.RegisterNetMessage<MsgPlayerList>(MsgPlayerList.NAME, HandlePlayerList);
}

View File

@@ -10,7 +10,7 @@ using Robust.Client.Interfaces.UserInterface;
using Robust.Client.Player;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Configuration;
using Robust.Shared;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.Interfaces.Configuration;
@@ -25,7 +25,7 @@ using Robust.Shared.Timing;
namespace Robust.Client.UserInterface
{
internal sealed class UserInterfaceManager : IDisposable, IUserInterfaceManagerInternal, IPostInjectInit
internal sealed class UserInterfaceManager : IDisposable, IUserInterfaceManagerInternal
{
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IClyde _displayManager = default!;
@@ -88,7 +88,9 @@ namespace Robust.Client.UserInterface
public void Initialize()
{
_uiScaleChanged(_configurationManager.GetCVar<float>("display.uiScale"));
_configurationManager.OnValueChanged(CVars.DisplayUIScale, _uiScaleChanged, true);
_uiScaleChanged(_configurationManager.GetCVar(CVars.DisplayUIScale));
ThemeDefaults = new UIThemeDummy();
_initializeCommon();
@@ -724,11 +726,6 @@ namespace Robust.Client.UserInterface
}
}
void IPostInjectInit.PostInject()
{
_configurationManager.RegisterCVar("display.uiScale", 0f, CVar.ARCHIVE, _uiScaleChanged);
}
private void _uiScaleChanged(float newValue)
{
UIScale = newValue == 0f ? DefaultUIScale : newValue;

View File

@@ -1,13 +1,14 @@
using DiscordRPC;
using DiscordRPC.Logging;
using Robust.Client.Interfaces.Utility;
using Robust.Shared;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.Log;
using Robust.Shared.IoC;
namespace Robust.Client.Utility
{
internal sealed class DiscordRichPresence : IDiscordRichPresence, IPostInjectInit
internal sealed class DiscordRichPresence : IDiscordRichPresence
{
private static readonly RichPresence _defaultPresence = new RichPresence
{
@@ -32,7 +33,27 @@ namespace Robust.Client.Utility
public void Initialize()
{
if (_configurationManager.GetCVar<bool>("discord.enabled"))
_configurationManager.OnValueChanged(CVars.DiscordEnabled, newValue =>
{
if (!_initialized)
{
return;
}
if (newValue)
{
if (_client == null || _client.IsDisposed)
{
_start();
}
}
else
{
_stop();
}
});
if (_configurationManager.GetCVar(CVars.DiscordEnabled))
{
_start();
}
@@ -98,29 +119,6 @@ namespace Robust.Client.Utility
_stop();
}
public void PostInject()
{
_configurationManager.RegisterCVar("discord.enabled", true, onValueChanged: newValue =>
{
if (!_initialized)
{
return;
}
if (newValue)
{
if (_client == null || _client.IsDisposed)
{
_start();
}
}
else
{
_stop();
}
});
}
private sealed class NativeLogger : ILogger
{
private readonly ISawmill _sawmill;

View File

@@ -109,7 +109,7 @@ namespace Robust.Server
public int MaxPlayers => _config.GetCVar(CVars.GameMaxPlayers);
/// <inheritdoc />
public string ServerName => _config.GetCVar<string>("game.hostname");
public string ServerName => _config.GetCVar(CVars.GameHostName);
/// <inheritdoc />
public void Restart()
@@ -185,22 +185,16 @@ namespace Robust.Server
//Sets up Logging
_config.RegisterCVar("log.enabled", true, CVar.ARCHIVE);
_config.RegisterCVar("log.path", "logs", CVar.ARCHIVE);
_config.RegisterCVar("log.format", "log_%(date)s-T%(time)s.txt", CVar.ARCHIVE);
_config.RegisterCVar("log.level", LogLevel.Info, CVar.ARCHIVE);
_config.RegisterCVar("log.runtimelog", true, CVar.ARCHIVE);
_logHandlerFactory = logHandlerFactory;
var logHandler = logHandlerFactory?.Invoke() ?? null;
var logEnabled = _config.GetCVar<bool>("log.enabled");
var logEnabled = _config.GetCVar(CVars.LogEnabled);
if (logEnabled && logHandler == null)
{
var logPath = _config.GetCVar<string>("log.path");
var logFormat = _config.GetCVar<string>("log.format");
var logPath = _config.GetCVar(CVars.LogPath);
var logFormat = _config.GetCVar(CVars.LogFormat);
var logFilename = logFormat.Replace("%(date)s", DateTime.Now.ToString("yyyy-MM-dd"))
.Replace("%(time)s", DateTime.Now.ToString("hh-mm-ss"));
var fullPath = Path.Combine(logPath, logFilename);
@@ -213,7 +207,7 @@ namespace Robust.Server
logHandler = new FileLogHandler(logPath);
}
_log.RootSawmill.Level = _config.GetCVar<LogLevel>("log.level");
_log.RootSawmill.Level = _config.GetCVar(CVars.LogLevel);
if (logEnabled && logHandler != null)
{
@@ -342,22 +336,16 @@ namespace Robust.Server
private bool SetupLoki()
{
_config.RegisterCVar("loki.enabled", false);
_config.RegisterCVar("loki.name", "");
_config.RegisterCVar("loki.address", "");
_config.RegisterCVar("loki.username", "");
_config.RegisterCVar("loki.password", "");
var enabled = _config.GetCVar<bool>("loki.enabled");
var enabled = _config.GetCVar(CVars.LokiEnabled);
if (!enabled)
{
return true;
}
var serverName = _config.GetCVar<string>("loki.name");
var address = _config.GetCVar<string>("loki.address");
var username = _config.GetCVar<string>("loki.username");
var password = _config.GetCVar<string>("loki.password");
var serverName = _config.GetCVar(CVars.LokiName);
var address = _config.GetCVar(CVars.LokiAddress);
var username = _config.GetCVar(CVars.LokiUsername);
var password = _config.GetCVar(CVars.LokiPassword);
if (string.IsNullOrWhiteSpace(serverName))
{
@@ -476,7 +464,7 @@ namespace Robust.Server
{
var cfgMgr = IoCManager.Resolve<IConfigurationManager>();
cfgMgr.RegisterCVar("net.tickrate", 60, CVar.ARCHIVE | CVar.REPLICATED | CVar.SERVER, i =>
cfgMgr.OnValueChanged(CVars.NetTickrate, i =>
{
var b = (byte) i;
_time.TickRate = b;
@@ -484,11 +472,10 @@ namespace Robust.Server
Logger.InfoS("game", $"Tickrate changed to: {b} on tick {_time.CurTick}");
SendTickRateUpdateToClients(b);
});
cfgMgr.SetCVar(CVars.GameType, (int) GameType.Game);
cfgMgr.RegisterCVar("game.hostname", "MyServer", CVar.ARCHIVE);
cfgMgr.RegisterCVar("game.type", GameType.Game);
_time.TickRate = (byte) _config.GetCVar<int>("net.tickrate");
_time.TickRate = (byte) _config.GetCVar(CVars.NetTickrate);
Logger.InfoS("srv", $"Name: {ServerName}");
Logger.InfoS("srv", $"TickRate: {_time.TickRate}({_time.TickPeriod.TotalMilliseconds:0.00}ms)");
@@ -512,10 +499,10 @@ namespace Robust.Server
// shutdown entities
_entities.Shutdown();
if (_config.GetCVar<bool>("log.runtimelog"))
if (_config.GetCVar(CVars.LogRuntimeLog))
{
// Wrtie down exception log
var logPath = _config.GetCVar<string>("log.path");
var logPath = _config.GetCVar(CVars.LogPath);
var relPath = PathHelpers.ExecutableRelativeFile(logPath);
Directory.CreateDirectory(relPath);
var pathToWrite = Path.Combine(relPath,

View File

@@ -2,6 +2,7 @@
using System.Net;
using Robust.Server.Interfaces.Player;
using Robust.Server.Player;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.Enums;
@@ -31,8 +32,6 @@ namespace Robust.Server.Console
{
var logger = _logManager.GetSawmill("con.groups");
_configurationManager.RegisterCVar("console.loginlocal", true, CVar.ARCHIVE);
_netManager.RegisterNetMessage<MsgConGroupUpdate>(MsgConGroupUpdate.Name);
_playerManager.PlayerStatusChanged += _onClientStatusChanged;
@@ -51,13 +50,14 @@ namespace Robust.Server.Console
{
_sessions.OnClientStatusChanged(sender, e);
if (e.NewStatus == SessionStatus.Connected && _configurationManager.GetCVar<bool>("console.loginlocal"))
if (e.NewStatus == SessionStatus.Connected &&
_configurationManager.GetCVar(CVars.ConsoleLoginLocal))
{
var session = e.Session;
var address = session.ConnectedClient.RemoteEndPoint.Address;
if (Equals(address, IPAddress.Loopback) || Equals(address, IPAddress.IPv6Loopback))
{
SetGroup(session, new ConGroupIndex(_configurationManager.GetCVar<int>("console.hostGroup")));
SetGroup(session, new ConGroupIndex(_configurationManager.GetCVar(CVars.ConsoleHostGroup)));
UpdateClientData(session);
}
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.Interfaces.Configuration;
@@ -59,21 +60,6 @@ namespace Robust.Server.Console
/// <inheritdoc />
public void Initialize()
{
// register console admin global password. DO NOT ADD THE REPLICATED FLAG
if (!_configMan.IsCVarRegistered("console.password"))
_configMan.RegisterCVar("console.password", string.Empty,
CVar.ARCHIVE | CVar.SERVER | CVar.NOT_CONNECTED);
if (!_configMan.IsCVarRegistered("console.hostpassword"))
_configMan.RegisterCVar("console.hostpassword", string.Empty,
CVar.ARCHIVE | CVar.SERVER | CVar.NOT_CONNECTED);
if (!_configMan.IsCVarRegistered("console.adminGroup"))
_configMan.RegisterCVar("console.adminGroup", 100, CVar.ARCHIVE | CVar.SERVER);
if (!_configMan.IsCVarRegistered("console.hostGroup"))
_configMan.RegisterCVar("console.hostGroup", 200, CVar.ARCHIVE | CVar.SERVER);
ReloadCommands();
// setup networking with clients
@@ -185,8 +171,8 @@ namespace Robust.Server.Console
if (session == null)
throw new ArgumentNullException(nameof(session));
var realPass = _configMan.GetCVar<string>("console.password");
var hostPass = _configMan.GetCVar<string>("console.hostpassword");
var realPass = _configMan.GetCVar(CVars.ConsolePassword);
var hostPass = _configMan.GetCVar(CVars.ConsoleHostPassword);
// password disabled
if (string.IsNullOrWhiteSpace(realPass))
@@ -197,7 +183,7 @@ namespace Robust.Server.Console
return false;
// success!
_groupController.SetGroup(session, new ConGroupIndex(_configMan.GetCVar<int>("console.adminGroup")));
_groupController.SetGroup(session, new ConGroupIndex(_configMan.GetCVar(CVars.ConsoleAdminGroup)));
return true;
}
@@ -238,7 +224,7 @@ namespace Robust.Server.Console
if (session == null)
throw new ArgumentNullException(nameof(session));
var realPass = _configMan.GetCVar<string>("console.hostpassword");
var realPass = _configMan.GetCVar(CVars.ConsoleHostPassword);
// password disabled
if (string.IsNullOrWhiteSpace(realPass))
@@ -249,7 +235,7 @@ namespace Robust.Server.Console
return false;
// success!
_groupController.SetGroup(session, new ConGroupIndex(_configMan.GetCVar<int>("console.hostGroup")));
_groupController.SetGroup(session, new ConGroupIndex(_configMan.GetCVar(CVars.ConsoleHostGroup)));
return true;
}

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using Robust.Server.Interfaces.Player;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Robust.Shared;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.Interfaces.Configuration;
@@ -24,8 +24,8 @@ namespace Robust.Server.Console
/// </summary>
public ConGroupIndex DefaultGroup
{
get => new ConGroupIndex(_configMan.GetCVar<int>("console.defaultGroup"));
set => _configMan.SetCVar("console.defaultGroup", value.Index);
get => new ConGroupIndex(_configMan.GetCVar(CVars.ConsoleDefaultGroup));
set => _configMan.SetCVar(CVars.ConsoleDefaultGroup, value.Index);
}
/// <summary>
@@ -37,9 +37,6 @@ namespace Robust.Server.Console
{
_configMan = configMan;
_logger = logger;
if(!_configMan.IsCVarRegistered("console.defaultGroup"))
_configMan.RegisterCVar("console.defaultGroup", 1, CVar.ARCHIVE);
}
/// <summary>

View File

@@ -1,5 +1,6 @@
using System;
using Prometheus;
using Robust.Shared;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Log;
@@ -8,7 +9,7 @@ using Robust.Shared.Log;
namespace Robust.Server.DataMetrics
{
internal sealed class MetricsManager : IMetricsManager, IPostInjectInit, IDisposable
internal sealed class MetricsManager : IMetricsManager, IDisposable
{
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
@@ -19,17 +20,14 @@ namespace Robust.Server.DataMetrics
public void Initialize()
{
_initialized = true;
_configurationManager.OnValueChanged(CVars.MetricsEnabled, _ => Reload());
_configurationManager.OnValueChanged(CVars.MetricsHost, _ => Reload());
_configurationManager.OnValueChanged(CVars.MetricsPort, _ => Reload());
Reload();
}
void IPostInjectInit.PostInject()
{
_configurationManager.RegisterCVar("metrics.enabled", false, onValueChanged: _ => Reload());
_configurationManager.RegisterCVar("metrics.host", "localhost", onValueChanged: _ => Reload());
_configurationManager.RegisterCVar("metrics.port", 44880, onValueChanged: _ => Reload());
}
private async void Stop()
{
if (_metricServer == null)
@@ -58,14 +56,14 @@ namespace Robust.Server.DataMetrics
Stop();
var enabled = _configurationManager.GetCVar<bool>("metrics.enabled");
var enabled = _configurationManager.GetCVar(CVars.MetricsEnabled);
if (!enabled)
{
return;
}
var host = _configurationManager.GetCVar<string>("metrics.host");
var port = _configurationManager.GetCVar<int>("metrics.port");
var host = _configurationManager.GetCVar(CVars.MetricsHost);
var port = _configurationManager.GetCVar(CVars.MetricsPort);
Logger.InfoS("metrics", "Prometheus metrics enabled, host: {1} port: {0}", port, host);
_metricServer = new MetricServer(host, port);

View File

@@ -9,6 +9,7 @@ using Robust.Server.GameObjects.EntitySystemMessages;
using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.Player;
using Robust.Server.Interfaces.Timing;
using Robust.Shared;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Components.Transform;
@@ -42,7 +43,7 @@ namespace Robust.Server.GameObjects
private float? _maxUpdateRangeCache;
public float MaxUpdateRange => _maxUpdateRangeCache
??= _configurationManager.GetCVar<float>("net.maxupdaterange");
??= _configurationManager.GetCVar(CVars.NetMaxUpdateRange);
private int _nextServerEntityUid = (int) EntityUid.FirstUid;

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.Player;
using Robust.Server.Player;
using Robust.Shared;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Configuration;
@@ -19,7 +20,7 @@ namespace Robust.Server.GameObjects
/// <summary>
/// The server implementation of the Entity Network Manager.
/// </summary>
public class ServerEntityNetworkManager : IServerEntityNetworkManager, IPostInjectInit
public class ServerEntityNetworkManager : IServerEntityNetworkManager
{
[Dependency] private readonly IServerNetManager _networkManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
@@ -46,7 +47,7 @@ namespace Robust.Server.GameObjects
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
_logLateMsgs = _configurationManager.GetCVar<bool>("net.log_late_msg");
_configurationManager.OnValueChanged(CVars.NetLogLateMsg, b => _logLateMsgs = b, true);
}
public void Update()
@@ -193,10 +194,5 @@ namespace Robust.Server.GameObjects
return y.Sequence.CompareTo(x.Sequence);
}
}
void IPostInjectInit.PostInject()
{
_configurationManager.RegisterCVar("net.log_late_msg", true, onValueChanged: b => _logLateMsgs = b);
}
}
}

View File

@@ -7,6 +7,7 @@ using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.GameState;
using Robust.Server.Interfaces.Player;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Enums;
using Robust.Shared.GameStates;
@@ -41,7 +42,7 @@ namespace Robust.Server.GameStates
[Dependency] private readonly IServerEntityNetworkManager _entityNetworkManager = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
public bool PvsEnabled => _configurationManager.GetCVar<bool>("net.pvs");
public bool PvsEnabled => _configurationManager.GetCVar(CVars.NetPVS);
/// <inheritdoc />
public void Initialize()
@@ -51,9 +52,6 @@ namespace Robust.Server.GameStates
_networkManager.Connected += HandleClientConnected;
_networkManager.Disconnect += HandleClientDisconnect;
_configurationManager.RegisterCVar("net.pvs", true, CVar.ARCHIVE);
_configurationManager.RegisterCVar("net.maxupdaterange", 12.5f, CVar.ARCHIVE);
}
private void HandleClientConnected(object? sender, NetChannelArgs e)

View File

@@ -5,6 +5,7 @@ using System.Net.Http;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Robust.Shared;
using Robust.Shared.Log;
using Robust.Shared.Utility;
@@ -85,7 +86,7 @@ namespace Robust.Server.ServerStatus
return true;
}
var downloadUrlWindows = _configurationManager.GetCVar<string>("build.download_url_windows");
var downloadUrlWindows = _configurationManager.GetCVar(CVars.BuildDownloadUrlWindows);
JObject? buildInfo;
@@ -100,16 +101,16 @@ namespace Robust.Server.ServerStatus
["download_urls"] = new JObject
{
["Windows"] = downloadUrlWindows,
["MacOS"] = _configurationManager.GetCVar<string>("build.download_url_macos"),
["Linux"] = _configurationManager.GetCVar<string>("build.download_url_linux")
["MacOS"] = _configurationManager.GetCVar(CVars.BuildDownloadUrlMacOS),
["Linux"] = _configurationManager.GetCVar(CVars.BuildDownloadUrlLinux)
},
["fork_id"] = _configurationManager.GetCVar<string>("build.fork_id"),
["version"] = _configurationManager.GetCVar<string>("build.version"),
["fork_id"] = _configurationManager.GetCVar(CVars.BuildForkId),
["version"] = _configurationManager.GetCVar(CVars.BuildVersion),
["hashes"] = new JObject
{
["Windows"] = _configurationManager.GetCVar<string>("build.hash_windows"),
["MacOS"] = _configurationManager.GetCVar<string>("build.hash_macos"),
["Linux"] = _configurationManager.GetCVar<string>("build.hash_linux"),
["Windows"] = _configurationManager.GetCVar(CVars.BuildHashWindows),
["MacOS"] = _configurationManager.GetCVar(CVars.BuildHashMacOS),
["Linux"] = _configurationManager.GetCVar(CVars.BuildHashLinux),
},
};
}
@@ -124,7 +125,7 @@ namespace Robust.Server.ServerStatus
var jObject = new JObject
{
["connect_address"] = _configurationManager.GetCVar<string>("status.connectaddress"),
["connect_address"] = _configurationManager.GetCVar(CVars.StatusConnectAddress),
["auth"] = authInfo,
["build"] = buildInfo
};

View File

@@ -16,7 +16,7 @@ using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Robust.Server.Interfaces.ServerStatus;
using Robust.Shared.Configuration;
using Robust.Shared;
using Robust.Shared.ContentPack;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.Network;
@@ -94,7 +94,7 @@ namespace Robust.Server.ServerStatus
{
RegisterCVars();
if (!_configurationManager.GetCVar<bool>("status.enabled"))
if (!_configurationManager.GetCVar(CVars.StatusEnabled))
{
return;
}
@@ -133,7 +133,7 @@ namespace Robust.Server.ServerStatus
private IPEndPoint GetBinding()
{
var binding = _configurationManager.GetCVar<string>("status.bind").Split(':');
var binding = _configurationManager.GetCVar(CVars.StatusBind).Split(':');
var ipAddrStr = binding[0];
if (ipAddrStr == "+" || ipAddrStr == "*")
{
@@ -171,18 +171,14 @@ namespace Robust.Server.ServerStatus
{
}
_configurationManager.RegisterCVar("status.enabled", true, CVar.ARCHIVE);
_configurationManager.RegisterCVar("status.bind", "*:1212", CVar.ARCHIVE);
_configurationManager.RegisterCVar("status.connectaddress", "", CVar.ARCHIVE);
_configurationManager.RegisterCVar("build.fork_id", info?.ForkId ?? "", CVar.ARCHIVE);
_configurationManager.RegisterCVar("build.version", info?.Version ?? "", CVar.ARCHIVE);
_configurationManager.RegisterCVar("build.download_url_windows", info?.Downloads.Windows ?? "", CVar.ARCHIVE);
_configurationManager.RegisterCVar("build.download_url_macos", info?.Downloads.MacOS ?? "", CVar.ARCHIVE);
_configurationManager.RegisterCVar("build.download_url_linux", info?.Downloads.Linux ?? "", CVar.ARCHIVE);
_configurationManager.RegisterCVar("build.hash_windows", info?.Hashes.Windows ?? "", CVar.ARCHIVE);
_configurationManager.RegisterCVar("build.hash_macos", info?.Hashes.MacOS ?? "", CVar.ARCHIVE);
_configurationManager.RegisterCVar("build.hash_linux", info?.Hashes.Linux ?? "", CVar.ARCHIVE);
_configurationManager.SetCVar(CVars.BuildForkId, info?.ForkId ?? "");
_configurationManager.SetCVar(CVars.BuildVersion, info?.Version ?? "");
_configurationManager.SetCVar(CVars.BuildDownloadUrlWindows, info?.Downloads.Windows ?? "");
_configurationManager.SetCVar(CVars.BuildDownloadUrlMacOS, info?.Downloads.MacOS ?? "");
_configurationManager.SetCVar(CVars.BuildDownloadUrlLinux, info?.Downloads.Linux ?? "");
_configurationManager.SetCVar(CVars.BuildHashWindows, info?.Hashes.Windows ?? "");
_configurationManager.SetCVar(CVars.BuildHashMacOS, info?.Hashes.MacOS ?? "");
_configurationManager.SetCVar(CVars.BuildHashLinux, info?.Hashes.Linux ?? "");
}
[JsonObject(ItemRequired = Required.DisallowNull)]

View File

@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using Robust.Server.Interfaces;
using Robust.Server.Interfaces.ServerStatus;
using Robust.Shared;
using Robust.Shared.Asynchronous;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.Timing;
@@ -39,10 +40,6 @@ namespace Robust.Server.ServerStatus
{
_statusHost.AddHandler(UpdateHandler);
_statusHost.AddHandler(ShutdownHandler);
_configurationManager.RegisterCVar("watchdog.token", "", onValueChanged: _ => UpdateToken());
_configurationManager.RegisterCVar("watchdog.key", "", onValueChanged: _ => UpdateToken());
_configurationManager.RegisterCVar("watchdog.baseUrl", "http://localhost:5000");
}
private bool UpdateHandler(HttpMethod method, HttpRequest request, HttpResponse response)
@@ -169,14 +166,17 @@ namespace Robust.Server.ServerStatus
public void Initialize()
{
_configurationManager.OnValueChanged(CVars.WatchdogToken, _ => UpdateToken());
_configurationManager.OnValueChanged(CVars.WatchdogKey, _ => UpdateToken());
UpdateToken();
}
private void UpdateToken()
{
var tok = _configurationManager.GetCVar<string>("watchdog.token");
var key = _configurationManager.GetCVar<string>("watchdog.key");
var baseUrl = _configurationManager.GetCVar<string>("watchdog.baseUrl");
var tok = _configurationManager.GetCVar(CVars.WatchdogToken);
var key = _configurationManager.GetCVar(CVars.WatchdogKey);
var baseUrl = _configurationManager.GetCVar(CVars.WatchdogBaseUrl);
_watchdogToken = string.IsNullOrEmpty(tok) ? null : tok;
_watchdogKey = string.IsNullOrEmpty(key) ? null : key;
_baseUri = string.IsNullOrEmpty(baseUrl) ? null : new Uri(baseUrl);

View File

@@ -1,5 +1,6 @@
using System;
using Robust.Shared.Configuration;
using Robust.Shared.Log;
namespace Robust.Shared
{
@@ -42,9 +43,126 @@ namespace Robust.Shared
public static readonly CVarDef<bool> NetDualStack =
CVarDef.Create("net.dualstack", false, CVar.ARCHIVE | CVar.SERVERONLY);
public static readonly CVarDef<bool> NetInterp =
CVarDef.Create("net.interp", true, CVar.ARCHIVE);
public static readonly CVarDef<int> NetInterpRatio =
CVarDef.Create("net.interp_ratio", 0, CVar.ARCHIVE);
public static readonly CVarDef<bool> NetLogging =
CVarDef.Create("net.logging", false, CVar.ARCHIVE);
public static readonly CVarDef<bool> NetPredict =
CVarDef.Create("net.predict", true, CVar.ARCHIVE);
public static readonly CVarDef<int> NetPredictSize =
CVarDef.Create("net.predict_size", 1, CVar.ARCHIVE);
public static readonly CVarDef<int> NetStateBufMergeThreshold =
CVarDef.Create("net.state_buf_merge_threshold", 5, CVar.ARCHIVE);
public static readonly CVarDef<bool> NetPVS =
CVarDef.Create("net.pvs", true, CVar.ARCHIVE);
public static readonly CVarDef<float> NetMaxUpdateRange =
CVarDef.Create("net.maxupdaterange", 12.5f, CVar.ARCHIVE);
public static readonly CVarDef<bool> NetLogLateMsg =
CVarDef.Create("net.log_late_msg", true);
public static readonly CVarDef<int> NetTickrate =
CVarDef.Create("net.tickrate", 60, CVar.ARCHIVE | CVar.REPLICATED | CVar.SERVER);
public static readonly CVarDef<bool> MetricsEnabled =
CVarDef.Create("metrics.enabled", false);
public static readonly CVarDef<string> MetricsHost =
CVarDef.Create("metrics.host", "localhost");
public static readonly CVarDef<int> MetricsPort =
CVarDef.Create("metrics.port", 44880);
public static readonly CVarDef<bool> StatusEnabled =
CVarDef.Create("status.enabled", true, CVar.ARCHIVE);
public static readonly CVarDef<string> StatusBind =
CVarDef.Create("status.bind", "*:1212", CVar.ARCHIVE);
public static readonly CVarDef<string> StatusConnectAddress =
CVarDef.Create("status.connectaddress", "", CVar.ARCHIVE);
public static readonly CVarDef<string> BuildForkId =
CVarDef.Create("build.fork_id", "", CVar.ARCHIVE);
public static readonly CVarDef<string> BuildVersion =
CVarDef.Create("build.version", "", CVar.ARCHIVE);
public static readonly CVarDef<string> BuildDownloadUrlWindows =
CVarDef.Create("build.download_url_windows", string.Empty, CVar.ARCHIVE);
public static readonly CVarDef<string> BuildDownloadUrlMacOS =
CVarDef.Create("build.download_url_macos", "", CVar.ARCHIVE);
public static readonly CVarDef<string> BuildDownloadUrlLinux =
CVarDef.Create("build.download_url_linux", "", CVar.ARCHIVE);
public static readonly CVarDef<string> BuildHashWindows =
CVarDef.Create("build.hash_windows", "", CVar.ARCHIVE);
public static readonly CVarDef<string> BuildHashMacOS =
CVarDef.Create("build.hash_macos", "", CVar.ARCHIVE);
public static readonly CVarDef<string> BuildHashLinux =
CVarDef.Create("build.hash_linux", "", CVar.ARCHIVE);
public static readonly CVarDef<string> WatchdogToken =
CVarDef.Create("watchdog.token", "");
public static readonly CVarDef<string> WatchdogKey =
CVarDef.Create("watchdog.key", "");
public static readonly CVarDef<string> WatchdogBaseUrl =
CVarDef.Create("watchdog.baseUrl", "http://localhost:5000");
public static readonly CVarDef<int> GameMaxPlayers =
CVarDef.Create("game.maxplayers", 32, CVar.ARCHIVE | CVar.SERVERONLY);
public static readonly CVarDef<string> GameHostName =
CVarDef.Create("game.hostname", "MyServer", CVar.ARCHIVE);
public static readonly CVarDef<int> GameType =
CVarDef.Create("game.type", 0);
public static readonly CVarDef<bool> LogEnabled =
CVarDef.Create("log.enabled", true, CVar.ARCHIVE);
public static readonly CVarDef<string> LogPath =
CVarDef.Create("log.path", "logs", CVar.ARCHIVE);
public static readonly CVarDef<string> LogFormat =
CVarDef.Create("log.format", "log_%(date)s-T%(time)s.txt", CVar.ARCHIVE);
public static readonly CVarDef<LogLevel> LogLevel =
CVarDef.Create("log.level", Log.LogLevel.Info, CVar.ARCHIVE);
public static readonly CVarDef<bool> LogRuntimeLog =
CVarDef.Create("log.runtimelog", true, CVar.ARCHIVE);
public static readonly CVarDef<bool> LokiEnabled =
CVarDef.Create("loki.enabled", false);
public static readonly CVarDef<string> LokiName =
CVarDef.Create("loki.name", "");
public static readonly CVarDef<string> LokiAddress =
CVarDef.Create("loki.address", "");
public static readonly CVarDef<string> LokiUsername =
CVarDef.Create("loki.username", "");
public static readonly CVarDef<string> LokiPassword =
CVarDef.Create("loki.password", "");
public static readonly CVarDef<int> AuthMode =
CVarDef.Create("auth.mode", (int) Network.AuthMode.Optional, CVar.SERVERONLY);
@@ -63,6 +181,70 @@ namespace Robust.Shared
public static readonly CVarDef<string> AuthServer =
CVarDef.Create("auth.server", "http://localhost:5000/", CVar.SECURE);
public static readonly CVarDef<int> ConsoleDefaultGroup =
CVarDef.Create("console.defaultGroup", 1, CVar.ARCHIVE);
public static readonly CVarDef<bool> DisplayVSync =
CVarDef.Create("display.vsync", true, CVar.ARCHIVE);
public static readonly CVarDef<int> DisplayWindowMode =
CVarDef.Create("display.windowmode", 0, CVar.ARCHIVE);
public static readonly CVarDef<int> DisplayWidth =
CVarDef.Create("display.width", 1280);
public static readonly CVarDef<int> DisplayHeight =
CVarDef.Create("display.height", 720);
public static readonly CVarDef<int> DisplayLightMapDivider =
CVarDef.Create("display.lightmapdivider", 2);
public static readonly CVarDef<bool> DisplaySoftShadows =
CVarDef.Create("display.softshadows", true);
public static readonly CVarDef<float> DisplayUIScale =
CVarDef.Create("display.uiScale", 0f, CVar.ARCHIVE);
public static readonly CVarDef<int> DisplayRenderer =
CVarDef.Create("display.renderer", 0);
public static readonly CVarDef<int> DisplayFontDpi =
CVarDef.Create("display.fontdpi", 96);
public static readonly CVarDef<string> DisplayOGLOverrideVersion =
CVarDef.Create("display.ogl_override_version", string.Empty);
public static readonly CVarDef<bool> DisplayOGLCheckErrors =
CVarDef.Create("display.ogl_check_errors", false);
public static readonly CVarDef<string> AudioDevice =
CVarDef.Create("audio.device", string.Empty);
public static readonly CVarDef<string> PlayerName =
CVarDef.Create("player.name", "JoeGenero", CVar.ARCHIVE);
public static readonly CVarDef<bool> DiscordEnabled =
CVarDef.Create("discord.enabled", true);
public static readonly CVarDef<bool> ConsoleLoginLocal =
CVarDef.Create("console.loginlocal", true, CVar.ARCHIVE);
// register console admin global password. DO NOT ADD THE REPLICATED FLAG
public static readonly CVarDef<string> ConsolePassword =
CVarDef.Create("console.password", string.Empty, CVar.ARCHIVE | CVar.SERVER | CVar.NOT_CONNECTED);
public static readonly CVarDef<string> ConsoleHostPassword =
CVarDef.Create("console.hostpassword", string.Empty, CVar.ARCHIVE | CVar.SERVER | CVar.NOT_CONNECTED);
public static readonly CVarDef<int> ConsoleAdminGroup =
CVarDef.Create("console.adminGroup", 100, CVar.ARCHIVE | CVar.SERVER);
public static readonly CVarDef<int> ConsoleHostGroup =
CVarDef.Create("console.hostGroup", 200, CVar.ARCHIVE | CVar.SERVER);
public static readonly CVarDef<bool> SignalsHandle =
CVarDef.Create("signals.handle", true);
#if DEBUG
public static readonly CVarDef<float> NetFakeLoss = CVarDef.Create("net.fakeloss", 0f, CVar.CHEAT);
public static readonly CVarDef<float> NetFakeLagMin = CVarDef.Create("net.fakelagmin", 0f, CVar.CHEAT);

View File

@@ -238,7 +238,7 @@ namespace Robust.Shared.Configuration
if (invokeImmediately)
{
onValueChanged((T) reg.Value!);
onValueChanged((T) (reg.Value ?? reg.DefaultValue)!);
}
}

View File

@@ -49,7 +49,7 @@ namespace Robust.Shared.Network
msgLogin.ReadFromBuffer(incPacket);
var ip = connection.RemoteEndPoint.Address;
var isLocal = IPAddress.IsLoopback(ip) && _config.GetCVar<bool>("auth.allowlocal");
var isLocal = IPAddress.IsLoopback(ip) && _config.GetCVar(CVars.AuthAllowLocal);
var canAuth = msgLogin.CanAuth;
var needPk = msgLogin.NeedPubKey;
var authServer = _config.GetSecureCVar<string>("auth.server");

View File

@@ -134,7 +134,7 @@ namespace Robust.Shared.Network
= new Dictionary<NetConnection, TaskCompletionSource<object?>>();
/// <inheritdoc />
public int Port => _config.GetCVar<int>("net.port");
public int Port => _config.GetCVar(CVars.NetPort);
public bool IsAuthEnabled => _config.GetCVar<bool>("auth.enabled");
@@ -516,10 +516,10 @@ namespace Robust.Shared.Network
#if DEBUG
//Simulate Latency
netConfig.SimulatedLoss = _config.GetCVar<float>("net.fakeloss");
netConfig.SimulatedMinimumLatency = _config.GetCVar<float>("net.fakelagmin");
netConfig.SimulatedRandomLatency = _config.GetCVar<float>("net.fakelagrand");
netConfig.SimulatedDuplicatesChance = _config.GetCVar<float>("net.fakeduplicates");
netConfig.SimulatedLoss = _config.GetCVar(CVars.NetFakeLoss);
netConfig.SimulatedMinimumLatency = _config.GetCVar(CVars.NetFakeLagMin);
netConfig.SimulatedRandomLatency = _config.GetCVar(CVars.NetFakeLagRand);
netConfig.SimulatedDuplicatesChance = _config.GetCVar(CVars.NetFakeDuplicates);
netConfig.ConnectionTimeout = 30000f;
#endif

View File

@@ -9,24 +9,21 @@ using Robust.Shared.Log;
namespace Robust.Shared
{
internal abstract class SignalHandler : ISignalHandler, IDisposable, IPostInjectInit
internal abstract class SignalHandler : ISignalHandler, IDisposable
{
[Dependency] private readonly ITaskManager _taskManager = default!;
#pragma warning disable 414
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
#pragma warning restore 414
private Thread? _signalThread;
public void PostInject()
{
_configurationManager.RegisterCVar("signals.handle", true);
}
public void MaybeStart()
{
// I actually did try to implement a onValueChanged handler but couldn't make it work well.
// The problem is that shutting down the thread does not restore the default exit behavior.
#if UNIX
if (_configurationManager.GetCVar<bool>("signals.handle"))
if (_configurationManager.GetCVar(CVars.SignalsHandle))
{
Start();
}

View File

@@ -5,6 +5,7 @@ using System.Reflection;
using NUnit.Framework;
using Robust.Shared.ContentPack;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Reflection;
using Robust.Shared.IoC;
@@ -28,6 +29,7 @@ namespace Robust.UnitTesting
// Clear state across tests.
IoCManager.InitThread();
IoCManager.Clear();
RegisterIoC();
var assemblies = new List<Assembly>(4);
@@ -46,6 +48,11 @@ namespace Robust.UnitTesting
assemblies.Add(AppDomain.CurrentDomain.GetAssemblyByName("Robust.Shared"));
assemblies.Add(Assembly.GetExecutingAssembly());
foreach (var assembly in assemblies)
{
IoCManager.Resolve<IConfigurationManager>().LoadCVarsFromAssembly(assembly);
}
IoCManager.Resolve<IReflectionManager>().LoadAssemblies(assemblies);
// Required components for the engine to work

View File

@@ -1,4 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=BYOND/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Collidable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=olde/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Interp/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=olde/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tickrate/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>