Change cvar usages to use CVarDef and define them in CCVars (#2250)

* Change cvar usages to use CVarDef and define them in CCVars

* Merge fixes

* Remove duplicate cvar registration
This commit is contained in:
DrSmugleaf
2020-11-07 01:15:56 +01:00
committed by GitHub
parent a7e7f20417
commit bf5b9ad03b
19 changed files with 136 additions and 72 deletions

View File

@@ -1,3 +1,4 @@
using Content.Shared;
using Robust.Client.Interfaces.Console; using Robust.Client.Interfaces.Console;
using Robust.Shared.Interfaces.Configuration; using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -14,10 +15,13 @@ namespace Content.Client.Commands
public bool Execute(IDebugConsole console, params string[] args) public bool Execute(IDebugConsole console, params string[] args)
{ {
var _configurationManager = IoCManager.Resolve<IConfigurationManager>(); var configurationManager = IoCManager.Resolve<IConfigurationManager>();
var old = _configurationManager.GetCVar<bool>("outline.enabled"); var cvar = CCVars.OutlineEnabled;
_configurationManager.SetCVar("outline.enabled", !old); var old = configurationManager.GetCVar(cvar);
console.AddLine($"Draw outlines set to: {_configurationManager.GetCVar<bool>("outline.enabled")}");
configurationManager.SetCVar(cvar, !old);
console.AddLine($"Draw outlines set to: {configurationManager.GetCVar(cvar)}");
return false; return false;
} }
} }

View File

@@ -101,8 +101,6 @@ namespace Content.Client
{ {
IoCManager.Resolve<IMapManager>().CreateNewMapEntity(MapId.Nullspace); IoCManager.Resolve<IMapManager>().CreateNewMapEntity(MapId.Nullspace);
}; };
_configurationManager.RegisterCVar("outline.enabled", true);
} }
/// <summary> /// <summary>

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Client.Interfaces.Parallax; using Content.Client.Interfaces.Parallax;
using Content.Shared;
using Nett; using Nett;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.Interfaces.ResourceManagement;
@@ -34,12 +35,12 @@ namespace Content.Client.Parallax
public async void LoadParallax() public async void LoadParallax()
{ {
if (!_configurationManager.GetCVar<bool>("parallax.enabled")) if (!_configurationManager.GetCVar(CCVars.ParallaxEnabled))
{ {
return; return;
} }
var debugParallax = _configurationManager.GetCVar<bool>("parallax.debug"); var debugParallax = _configurationManager.GetCVar(CCVars.ParallaxDebug);
string contents; string contents;
TomlTable table; TomlTable table;
// Load normal config into memory // Load normal config into memory

View File

@@ -3,6 +3,7 @@ using System.Collections.Immutable;
using System.Linq; using System.Linq;
using Content.Client.GameObjects.Components; using Content.Client.GameObjects.Components;
using Content.Client.Utility; using Content.Client.Utility;
using Content.Shared;
using Robust.Client.GameObjects.EntitySystems; using Robust.Client.GameObjects.EntitySystems;
using Robust.Client.Interfaces.GameObjects; using Robust.Client.Interfaces.GameObjects;
using Robust.Client.Interfaces.Graphics.ClientEye; using Robust.Client.Interfaces.Graphics.ClientEye;
@@ -71,7 +72,7 @@ namespace Content.Client.State
} }
InteractionOutlineComponent outline; InteractionOutlineComponent outline;
if(!ConfigurationManager.GetCVar<bool>("outline.enabled")) if(!ConfigurationManager.GetCVar(CCVars.OutlineEnabled))
{ {
if(entityToClick != null && entityToClick.TryGetComponent(out outline)) if(entityToClick != null && entityToClick.TryGetComponent(out outline))
{ {

View File

@@ -8,6 +8,7 @@ using Robust.Client.Interfaces.UserInterface;
using Robust.Client.ResourceManagement; using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Shared;
using Robust.Shared.Interfaces.Configuration; using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.Network; using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -111,10 +112,10 @@ namespace Content.Client.State
return; return;
} }
var configName = _configurationManager.GetCVar<string>("player.name"); var configName = _configurationManager.GetCVar(CVars.PlayerName);
if (_mainMenuControl.UserNameBox.Text != configName) if (_mainMenuControl.UserNameBox.Text != configName)
{ {
_configurationManager.SetCVar("player.name", inputName); _configurationManager.SetCVar(CVars.PlayerName, inputName);
_configurationManager.SaveToFile(); _configurationManager.SaveToFile();
} }
@@ -248,7 +249,7 @@ namespace Content.Client.State
vBox.AddChild(userNameHBox); vBox.AddChild(userNameHBox);
userNameHBox.AddChild(new Label {Text = "Username:"}); userNameHBox.AddChild(new Label {Text = "Username:"});
var currentUserName = _configurationManager.GetCVar<string>("player.name"); var currentUserName = _configurationManager.GetCVar(CVars.PlayerName);
UserNameBox = new LineEdit UserNameBox = new LineEdit
{ {
Text = currentUserName, PlaceHolder = "Username", Text = currentUserName, PlaceHolder = "Username",

View File

@@ -1,7 +1,9 @@
using Robust.Client.Graphics; using Content.Shared;
using Robust.Client.Graphics;
using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Shared;
using Robust.Shared.Interfaces.Configuration; using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
@@ -121,7 +123,7 @@ namespace Content.Client.UserInterface
}); });
ApplyButton.OnPressed += OnApplyButtonPressed; ApplyButton.OnPressed += OnApplyButtonPressed;
VSyncCheckBox.Pressed = _cfg.GetCVar<bool>("display.vsync"); VSyncCheckBox.Pressed = _cfg.GetCVar(CVars.DisplayVSync);
FullscreenCheckBox.Pressed = ConfigIsFullscreen; FullscreenCheckBox.Pressed = ConfigIsFullscreen;
LightingPresetOption.SelectId(GetConfigLightingQuality()); LightingPresetOption.SelectId(GetConfigLightingQuality());
_uiScaleOption.SelectId(GetConfigUIScalePreset(ConfigUIScale)); _uiScaleOption.SelectId(GetConfigUIScalePreset(ConfigUIScale));
@@ -137,11 +139,11 @@ namespace Content.Client.UserInterface
private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args) private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
{ {
_cfg.SetCVar("display.vsync", VSyncCheckBox.Pressed); _cfg.SetCVar(CVars.DisplayVSync, VSyncCheckBox.Pressed);
SetConfigLightingQuality(LightingPresetOption.SelectedId); SetConfigLightingQuality(LightingPresetOption.SelectedId);
_cfg.SetCVar("display.windowmode", _cfg.SetCVar(CVars.DisplayWindowMode,
(int) (FullscreenCheckBox.Pressed ? WindowMode.Fullscreen : WindowMode.Windowed)); (int) (FullscreenCheckBox.Pressed ? WindowMode.Fullscreen : WindowMode.Windowed));
_cfg.SetCVar("display.uiScale", UIScaleOptions[_uiScaleOption.SelectedId]); _cfg.SetCVar(CVars.DisplayUIScale, UIScaleOptions[_uiScaleOption.SelectedId]);
_cfg.SaveToFile(); _cfg.SaveToFile();
UpdateApplyButton(); UpdateApplyButton();
} }
@@ -159,7 +161,7 @@ namespace Content.Client.UserInterface
private void UpdateApplyButton() private void UpdateApplyButton()
{ {
var isVSyncSame = VSyncCheckBox.Pressed == _cfg.GetCVar<bool>("display.vsync"); var isVSyncSame = VSyncCheckBox.Pressed == _cfg.GetCVar(CVars.DisplayVSync);
var isFullscreenSame = FullscreenCheckBox.Pressed == ConfigIsFullscreen; var isFullscreenSame = FullscreenCheckBox.Pressed == ConfigIsFullscreen;
var isLightingQualitySame = LightingPresetOption.SelectedId == GetConfigLightingQuality(); var isLightingQualitySame = LightingPresetOption.SelectedId == GetConfigLightingQuality();
var isUIScaleSame = MathHelper.CloseTo(UIScaleOptions[_uiScaleOption.SelectedId], ConfigUIScale); var isUIScaleSame = MathHelper.CloseTo(UIScaleOptions[_uiScaleOption.SelectedId], ConfigUIScale);
@@ -167,14 +169,14 @@ namespace Content.Client.UserInterface
} }
private bool ConfigIsFullscreen => private bool ConfigIsFullscreen =>
_cfg.GetCVar<int>("display.windowmode") == (int) WindowMode.Fullscreen; _cfg.GetCVar(CVars.DisplayWindowMode) == (int) WindowMode.Fullscreen;
private float ConfigUIScale => _cfg.GetCVar<float>("display.uiScale"); private float ConfigUIScale => _cfg.GetCVar(CVars.DisplayUIScale);
private int GetConfigLightingQuality() private int GetConfigLightingQuality()
{ {
var val = _cfg.GetCVar<int>("display.lightmapdivider"); var val = _cfg.GetCVar(CVars.DisplayLightMapDivider);
var soft = _cfg.GetCVar<bool>("display.softshadows"); var soft = _cfg.GetCVar(CVars.DisplaySoftShadows);
if (val >= 8) if (val >= 8)
{ {
return 0; return 0;
@@ -198,20 +200,20 @@ namespace Content.Client.UserInterface
switch (value) switch (value)
{ {
case 0: case 0:
_cfg.SetCVar("display.lightmapdivider", 8); _cfg.SetCVar(CVars.DisplayLightMapDivider, 8);
_cfg.SetCVar("display.softshadows", false); _cfg.SetCVar(CVars.DisplaySoftShadows, false);
break; break;
case 1: case 1:
_cfg.SetCVar("display.lightmapdivider", 2); _cfg.SetCVar(CVars.DisplayLightMapDivider, 2);
_cfg.SetCVar("display.softshadows", false); _cfg.SetCVar(CVars.DisplaySoftShadows, false);
break; break;
case 2: case 2:
_cfg.SetCVar("display.lightmapdivider", 2); _cfg.SetCVar(CVars.DisplayLightMapDivider, 2);
_cfg.SetCVar("display.softshadows", true); _cfg.SetCVar(CVars.DisplaySoftShadows, true);
break; break;
case 3: case 3:
_cfg.SetCVar("display.lightmapdivider", 1); _cfg.SetCVar(CVars.DisplayLightMapDivider, 1);
_cfg.SetCVar("display.softshadows", true); _cfg.SetCVar(CVars.DisplaySoftShadows, true);
break; break;
} }
} }

View File

@@ -1,6 +1,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared;
using NUnit.Framework; using NUnit.Framework;
using Robust.Shared.Interfaces.Configuration; using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
@@ -31,7 +32,7 @@ namespace Content.IntegrationTests.Tests.Commands
server.Assert(() => server.Assert(() =>
{ {
configManager.SetCVar("game.lobbyenabled", lobbyEnabled); configManager.SetCVar(CCVars.GameLobbyEnabled, lobbyEnabled);
Assert.That(gameTicker.RunLevel, Is.EqualTo(GameRunLevel.InRound)); Assert.That(gameTicker.RunLevel, Is.EqualTo(GameRunLevel.InRound));

View File

@@ -38,9 +38,7 @@ namespace Content.IntegrationTests.Tests.Lobby
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var lobbyCvar = CCVars.GameLobbyEnabled; serverConfig.SetCVar(CCVars.GameLobbyEnabled, true);
serverConfig.SetCVar(lobbyCvar.Name, true);
serverTicker.RestartRound(); serverTicker.RestartRound();
}); });

View File

@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Server.GameObjects.Components.Movement; using Content.Server.GameObjects.Components.Movement;
using Content.Shared;
using Content.Shared.GameObjects.Components.Movement; using Content.Shared.GameObjects.Components.Movement;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.AI; using Robust.Server.AI;
@@ -42,7 +43,6 @@ namespace Content.Server.GameObjects.EntitySystems.AI
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
_configurationManager.RegisterCVar("ai.maxupdates", 64);
SubscribeLocalEvent<SleepAiMessage>(HandleAiSleep); SubscribeLocalEvent<SleepAiMessage>(HandleAiSleep);
var processors = _reflectionManager.GetAllChildren<AiLogicProcessor>(); var processors = _reflectionManager.GetAllChildren<AiLogicProcessor>();
@@ -58,7 +58,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI
/// <inheritdoc /> /// <inheritdoc />
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
var cvarMaxUpdates = _configurationManager.GetCVar<int>("ai.maxupdates"); var cvarMaxUpdates = _configurationManager.GetCVar(CCVars.AIMaxUpdates);
if (cvarMaxUpdates <= 0) if (cvarMaxUpdates <= 0)
return; return;

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Content.Server.GameObjects.Components.Atmos; using Content.Server.GameObjects.Components.Atmos;
using Content.Server.Atmos; using Content.Server.Atmos;
using Content.Shared;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.GameObjects.EntitySystems.Atmos; using Content.Shared.GameObjects.EntitySystems.Atmos;
using JetBrains.Annotations; using JetBrains.Annotations;
@@ -47,7 +48,6 @@ namespace Content.Server.GameObjects.EntitySystems.Atmos
_atmosphereSystem = Get<AtmosphereSystem>(); _atmosphereSystem = Get<AtmosphereSystem>();
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged; _playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
_configManager.RegisterCVar("net.atmosdbgoverlaytickrate", 3.0f);
} }
public override void Shutdown() public override void Shutdown()
@@ -89,7 +89,7 @@ namespace Content.Server.GameObjects.EntitySystems.Atmos
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
AccumulatedFrameTime += frameTime; AccumulatedFrameTime += frameTime;
_updateCooldown = 1 / _configManager.GetCVar<float>("net.atmosdbgoverlaytickrate"); _updateCooldown = 1 / _configManager.GetCVar(CCVars.NetAtmosDebugOverlayTickRate);
if (AccumulatedFrameTime < _updateCooldown) if (AccumulatedFrameTime < _updateCooldown)
{ {

View File

@@ -4,12 +4,14 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Content.Server.GameObjects.Components.Atmos; using Content.Server.GameObjects.Components.Atmos;
using Content.Shared;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.GameObjects.EntitySystems.Atmos; using Content.Shared.GameObjects.EntitySystems.Atmos;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Interfaces.Configuration; using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
@@ -65,7 +67,6 @@ namespace Content.Server.GameObjects.EntitySystems.Atmos
_atmosphereSystem = Get<AtmosphereSystem>(); _atmosphereSystem = Get<AtmosphereSystem>();
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged; _playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
_mapManager.OnGridRemoved += OnGridRemoved; _mapManager.OnGridRemoved += OnGridRemoved;
_configManager.RegisterCVar("net.gasoverlaytickrate", 3.0f);
} }
public override void Shutdown() public override void Shutdown()
@@ -228,14 +229,14 @@ namespace Content.Server.GameObjects.EntitySystems.Atmos
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
AccumulatedFrameTime += frameTime; AccumulatedFrameTime += frameTime;
_updateCooldown = 1 / _configManager.GetCVar<float>("net.gasoverlaytickrate"); _updateCooldown = 1 / _configManager.GetCVar(CCVars.NetGasOverlayTickRate);
if (AccumulatedFrameTime < _updateCooldown) if (AccumulatedFrameTime < _updateCooldown)
{ {
return; return;
} }
_updateRange = _configManager.GetCVar<float>("net.maxupdaterange") + RangeOffset; _updateRange = _configManager.GetCVar(CVars.NetMaxUpdateRange) + RangeOffset;
// TODO: So in the worst case scenario we still have to send a LOT of tile data per tick if there's a fire. // TODO: So in the worst case scenario we still have to send a LOT of tile data per tick if there's a fire.
// If we go with say 15 tile radius then we have up to 900 tiles to update per tick. // If we go with say 15 tile radius then we have up to 900 tiles to update per tick.

View File

@@ -9,6 +9,7 @@ using Content.Server.Interfaces.Chat;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Server.Mobs.Roles.Suspicion; using Content.Server.Mobs.Roles.Suspicion;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared;
using Content.Shared.GameObjects.Components.Inventory; using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.GameObjects.Components.PDA; using Content.Shared.GameObjects.Components.PDA;
using Content.Shared.Roles; using Content.Shared.Roles;
@@ -44,20 +45,12 @@ namespace Content.Server.GameTicking.GamePresets
private static string TraitorID = "SuspicionTraitor"; private static string TraitorID = "SuspicionTraitor";
private static string InnocentID = "SuspicionInnocent"; private static string InnocentID = "SuspicionInnocent";
public static void RegisterCVars(IConfigurationManager cfg)
{
cfg.RegisterCVar("game.suspicion_min_players", 5);
cfg.RegisterCVar("game.suspicion_min_traitors", 2);
cfg.RegisterCVar("game.suspicion_players_per_traitor", 5);
cfg.RegisterCVar("game.suspicion_starting_balance", 20);
}
public override bool Start(IReadOnlyList<IPlayerSession> readyPlayers, bool force = false) public override bool Start(IReadOnlyList<IPlayerSession> readyPlayers, bool force = false)
{ {
MinPlayers = _cfg.GetCVar<int>("game.suspicion_min_players"); MinPlayers = _cfg.GetCVar(CCVars.GameSuspicionMinPlayers);
MinTraitors = _cfg.GetCVar<int>("game.suspicion_min_traitors"); MinTraitors = _cfg.GetCVar(CCVars.GameSuspicionMinTraitors);
PlayersPerTraitor = _cfg.GetCVar<int>("game.suspicion_players_per_traitor"); PlayersPerTraitor = _cfg.GetCVar(CCVars.GameSuspicionPlayersPerTraitor);
TraitorStartingBalance = _cfg.GetCVar<int>("game.suspicion_starting_balance"); TraitorStartingBalance = _cfg.GetCVar(CCVars.GameSuspicionStartingBalance);
if (!force && readyPlayers.Count < MinPlayers) if (!force && readyPlayers.Count < MinPlayers)
{ {

View File

@@ -2,6 +2,7 @@
using System.Threading; using System.Threading;
using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.Chat;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Shared;
using Content.Shared.GameObjects.Components.Damage; using Content.Shared.GameObjects.Components.Damage;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Server.Player; using Robust.Server.Player;
@@ -56,7 +57,7 @@ namespace Content.Server.GameTicking.GameRules
{ {
_checkTimerCancel = null; _checkTimerCancel = null;
if (!_cfg.GetCVar<bool>("game.enablewin")) if (!_cfg.GetCVar(CCVars.GameLobbyEnableWin))
return; return;
IPlayerSession winner = null; IPlayerSession winner = null;

View File

@@ -6,6 +6,7 @@ using Content.Server.Interfaces.Chat;
using Content.Server.Interfaces.GameTicking; using Content.Server.Interfaces.GameTicking;
using Content.Server.Mobs.Roles.Suspicion; using Content.Server.Mobs.Roles.Suspicion;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared;
using Content.Shared.GameObjects.Components.Damage; using Content.Shared.GameObjects.Components.Damage;
using Robust.Server.GameObjects.EntitySystems; using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
@@ -58,7 +59,7 @@ namespace Content.Server.GameTicking.GameRules
private void _checkWinConditions() private void _checkWinConditions()
{ {
if (!_cfg.GetCVar<bool>("game.enablewin")) if (!_cfg.GetCVar(CCVars.GameLobbyEnableWin))
return; return;
var traitorsAlive = 0; var traitorsAlive = 0;

View File

@@ -88,7 +88,7 @@ namespace Content.Server.GameTicking
[ViewVariables] private bool DisallowLateJoin { get; set; } = false; [ViewVariables] private bool DisallowLateJoin { get; set; } = false;
[ViewVariables] private bool LobbyEnabled => _configurationManager.GetCVar<bool>("game.lobbyenabled"); [ViewVariables] private bool LobbyEnabled => _configurationManager.GetCVar(CCVars.GameLobbyEnabled);
[ViewVariables] private bool _updateOnRoundEnd; [ViewVariables] private bool _updateOnRoundEnd;
private CancellationTokenSource _updateShutdownCts; private CancellationTokenSource _updateShutdownCts;
@@ -119,7 +119,7 @@ namespace Content.Server.GameTicking
public event Action<GameRuleAddedEventArgs> OnRuleAdded; public event Action<GameRuleAddedEventArgs> OnRuleAdded;
private TimeSpan LobbyDuration => private TimeSpan LobbyDuration =>
TimeSpan.FromSeconds(_configurationManager.GetCVar<int>("game.lobbyduration")); TimeSpan.FromSeconds(_configurationManager.GetCVar(CCVars.GameLobbyDuration));
public override void Initialize() public override void Initialize()
{ {
@@ -127,8 +127,6 @@ namespace Content.Server.GameTicking
DebugTools.Assert(!_initialized); DebugTools.Assert(!_initialized);
PresetSuspicion.RegisterCVars(_configurationManager);
_netManager.RegisterNetMessage<MsgTickerJoinLobby>(nameof(MsgTickerJoinLobby)); _netManager.RegisterNetMessage<MsgTickerJoinLobby>(nameof(MsgTickerJoinLobby));
_netManager.RegisterNetMessage<MsgTickerJoinGame>(nameof(MsgTickerJoinGame)); _netManager.RegisterNetMessage<MsgTickerJoinGame>(nameof(MsgTickerJoinGame));
_netManager.RegisterNetMessage<MsgTickerLobbyStatus>(nameof(MsgTickerLobbyStatus)); _netManager.RegisterNetMessage<MsgTickerLobbyStatus>(nameof(MsgTickerLobbyStatus));
@@ -286,9 +284,9 @@ namespace Content.Server.GameTicking
if (!preset.Start(assignedJobs.Keys.ToList(), force)) if (!preset.Start(assignedJobs.Keys.ToList(), force))
{ {
if (_configurationManager.GetCVar<bool>("game.fallbackenabled")) if (_configurationManager.GetCVar(CCVars.GameLobbyFallbackEnabled))
{ {
SetStartPreset(_configurationManager.GetCVar<string>("game.fallbackpreset")); SetStartPreset(_configurationManager.GetCVar(CCVars.GameLobbyFallbackPreset));
var newPreset = MakeGamePreset(profiles); var newPreset = MakeGamePreset(profiles);
_chatManager.DispatchServerAnnouncement( _chatManager.DispatchServerAnnouncement(
$"Failed to start {preset.ModeTitle} mode! Defaulting to {newPreset.ModeTitle}..."); $"Failed to start {preset.ModeTitle} mode! Defaulting to {newPreset.ModeTitle}...");

View File

@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Server.Interfaces; using Content.Server.Interfaces;
using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.Chat;
using Content.Shared;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Newtonsoft.Json; using Newtonsoft.Json;
using Robust.Server.Interfaces.ServerStatus; using Robust.Server.Interfaces.ServerStatus;
@@ -27,9 +28,6 @@ namespace Content.Server
void IPostInjectInit.PostInject() void IPostInjectInit.PostInject()
{ {
_configurationManager.RegisterCVar<string>("status.mommiurl", null);
_configurationManager.RegisterCVar<string>("status.mommipassword", null);
_statusHost.AddHandler(_handleChatPost); _statusHost.AddHandler(_handleChatPost);
} }
@@ -46,8 +44,8 @@ namespace Content.Server
private async Task _sendMessageInternal(string type, object messageObject) private async Task _sendMessageInternal(string type, object messageObject)
{ {
var url = _configurationManager.GetCVar<string>("status.mommiurl"); var url = _configurationManager.GetCVar(CCVars.StatusMoMMIUrl);
var password = _configurationManager.GetCVar<string>("status.mommipassword"); var password = _configurationManager.GetCVar(CCVars.StatusMoMMIPassword);
if (string.IsNullOrWhiteSpace(url)) if (string.IsNullOrWhiteSpace(url))
{ {
return; return;
@@ -83,7 +81,7 @@ namespace Content.Server
return false; return false;
} }
var password = _configurationManager.GetCVar<string>("status.mommipassword"); var password = _configurationManager.GetCVar(CCVars.StatusMoMMIPassword);
OOCPostMessage message = null; OOCPostMessage message = null;
try try

View File

@@ -7,6 +7,21 @@ namespace Content.Shared
[CVarDefs] [CVarDefs]
public sealed class CCVars : CVars public sealed class CCVars : CVars
{ {
/*
* Status
*/
public static readonly CVarDef<string> StatusMoMMIUrl =
CVarDef.Create<string>("status.mommiurl", null);
public static readonly CVarDef<string> StatusMoMMIPassword =
CVarDef.Create<string>("status.mommipassword", null);
/*
* Game
*/
public static readonly CVarDef<bool> public static readonly CVarDef<bool>
EventsEnabled = CVarDef.Create("events.enabled", false, CVar.ARCHIVE | CVar.SERVERONLY); EventsEnabled = CVarDef.Create("events.enabled", false, CVar.ARCHIVE | CVar.SERVERONLY);
@@ -37,6 +52,21 @@ namespace Content.Shared
public static readonly CVarDef<bool> public static readonly CVarDef<bool>
GamePersistGuests = CVarDef.Create("game.persistguests", true, CVar.ARCHIVE | CVar.SERVERONLY); GamePersistGuests = CVarDef.Create("game.persistguests", true, CVar.ARCHIVE | CVar.SERVERONLY);
public static readonly CVarDef<int> GameSuspicionMinPlayers =
CVarDef.Create("game.suspicion_min_players", 5);
public static readonly CVarDef<int> GameSuspicionMinTraitors =
CVarDef.Create("game.suspicion_min_traitors", 2);
public static readonly CVarDef<int> GameSuspicionPlayersPerTraitor =
CVarDef.Create("game.suspicion_players_per_traitor", 5);
public static readonly CVarDef<int> GameSuspicionStartingBalance =
CVarDef.Create("game.suspicion_starting_balance", 20);
public static readonly CVarDef<bool> GameDiagonalMovement =
CVarDef.Create("game.diagonalmovement", true, CVar.ARCHIVE);
/* /*
* Database stuff * Database stuff
@@ -62,5 +92,43 @@ namespace Content.Shared
public static readonly CVarDef<string> DatabasePgPassword = public static readonly CVarDef<string> DatabasePgPassword =
CVarDef.Create("database.pg_password", "", CVar.SERVERONLY); CVarDef.Create("database.pg_password", "", CVar.SERVERONLY);
/*
* Outline
*/
public static readonly CVarDef<bool> OutlineEnabled =
CVarDef.Create("outline.enabled", true, CVar.CLIENTONLY);
/*
* Parallax
*/
public static readonly CVarDef<bool> ParallaxEnabled =
CVarDef.Create("parallax.enabled", true);
public static readonly CVarDef<bool> ParallaxDebug =
CVarDef.Create("parallax.debug", true);
/*
* AI
*/
public static readonly CVarDef<int> AIMaxUpdates =
CVarDef.Create("ai.maxupdates", 64);
/*
* Net
*/
public static readonly CVarDef<float> NetAtmosDebugOverlayTickRate =
CVarDef.Create("net.atmosdbgoverlaytickrate", 3.0f);
public static readonly CVarDef<float> NetGasOverlayTickRate =
CVarDef.Create("net.gasoverlaytickrate", 3.0f);
} }
} }

View File

@@ -139,7 +139,7 @@ namespace Content.Shared.GameObjects.Components.Movement
/// Whether or not the player can move diagonally. /// Whether or not the player can move diagonally.
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
public bool DiagonalMovementEnabled => _configurationManager.GetCVar<bool>("game.diagonalmovement"); public bool DiagonalMovementEnabled => _configurationManager.GetCVar<bool>(CCVars.GameDiagonalMovement);
/// <inheritdoc /> /// <inheritdoc />
public override void OnAdd() public override void OnAdd()

View File

@@ -41,8 +41,6 @@ namespace Content.Shared.GameObjects.EntitySystems
.Bind(EngineKeyFunctions.MoveDown, moveDownCmdHandler) .Bind(EngineKeyFunctions.MoveDown, moveDownCmdHandler)
.Bind(EngineKeyFunctions.Walk, new WalkInputCmdHandler()) .Bind(EngineKeyFunctions.Walk, new WalkInputCmdHandler())
.Register<SharedMoverSystem>(); .Register<SharedMoverSystem>();
_configurationManager.RegisterCVar("game.diagonalmovement", true, CVar.ARCHIVE);
} }
/// <inheritdoc /> /// <inheritdoc />