diff --git a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs index 442911b09e..9dc76e424e 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs @@ -60,9 +60,6 @@ public sealed partial class CargoSystem private void InitializeShuttle() { -#if !FULL_RELEASE - _configManager.OverrideDefault(CCVars.CargoShuttles, false); -#endif _enabled = _configManager.GetCVar(CCVars.CargoShuttles); // Don't want to immediately call this as shuttles will get setup in the natural course of things. _configManager.OnValueChanged(CCVars.CargoShuttles, SetCargoShuttleEnabled); diff --git a/Content.Server/Entry/EntryPoint.cs b/Content.Server/Entry/EntryPoint.cs index 92e7b8d832..4d3716113f 100644 --- a/Content.Server/Entry/EntryPoint.cs +++ b/Content.Server/Entry/EntryPoint.cs @@ -37,6 +37,9 @@ namespace Content.Server.Entry { public sealed class EntryPoint : GameServer { + private const string ConfigPresetsDir = "/ConfigPresets/"; + private const string ConfigPresetsDirBuild = $"{ConfigPresetsDir}Build/"; + private EuiManager _euiManager = default!; private IVoteManager _voteManager = default!; private ServerUpdateManager _updateManager = default!; @@ -48,6 +51,12 @@ namespace Content.Server.Entry { base.Init(); + var cfg = IoCManager.Resolve(); + var res = IoCManager.Resolve(); + var logManager = IoCManager.Resolve(); + + LoadConfigPresets(cfg, res, logManager.GetSawmill("configpreset")); + var aczProvider = new ContentMagicAczProvider(IoCManager.Resolve()); IoCManager.Resolve().SetMagicAczProvider(aczProvider); @@ -85,7 +94,6 @@ namespace Content.Server.Entry _playTimeTracking = IoCManager.Resolve(); _sysMan = IoCManager.Resolve(); - var logManager = IoCManager.Resolve(); logManager.GetSawmill("Storage").Level = LogLevel.Info; logManager.GetSawmill("db.ef").Level = LogLevel.Info; @@ -165,5 +173,47 @@ namespace Content.Server.Entry _playTimeTracking?.Shutdown(); _sysMan?.GetEntitySystemOrNull()?.OnServerDispose(); } + + private static void LoadConfigPresets(IConfigurationManager cfg, IResourceManager res, ISawmill sawmill) + { + LoadBuildConfigPresets(cfg, res, sawmill); + + var presets = cfg.GetCVar(CCVars.ConfigPresets); + if (presets == "") + return; + + foreach (var preset in presets.Split(',')) + { + var path = $"{ConfigPresetsDir}{preset}.toml"; + if (!res.TryContentFileRead(path, out var file)) + { + sawmill.Error("Unable to load config preset {Preset}!", path); + continue; + } + + cfg.LoadDefaultsFromTomlStream(file); + sawmill.Info("Loaded config preset: {Preset}", path); + } + } + + private static void LoadBuildConfigPresets(IConfigurationManager cfg, IResourceManager res, ISawmill sawmill) + { +#if !FULL_RELEASE + Load(CCVars.ConfigPresetDevelopment, "development"); +#endif +#if DEBUG + Load(CCVars.ConfigPresetDebug, "debug"); +#endif + + void Load(CVarDef cVar, string name) + { + var path = $"{ConfigPresetsDirBuild}{name}.toml"; + if (cfg.GetCVar(cVar) && res.TryContentFileRead(path, out var file)) + { + cfg.LoadDefaultsFromTomlStream(file); + sawmill.Info("Loaded config preset: {Preset}", path); + } + } + } } } diff --git a/Content.Server/NPC/Systems/NPCSystem.cs b/Content.Server/NPC/Systems/NPCSystem.cs index d58a73381b..1f753de767 100644 --- a/Content.Server/NPC/Systems/NPCSystem.cs +++ b/Content.Server/NPC/Systems/NPCSystem.cs @@ -34,10 +34,6 @@ namespace Content.Server.NPC.Systems public override void Initialize() { base.Initialize(); - // Makes physics etc debugging easier. -#if DEBUG - _configurationManager.OverrideDefault(CCVars.NPCEnabled, false); -#endif _sawmill = Logger.GetSawmill("npc"); _sawmill.Level = LogLevel.Info; diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.EmergencyShuttle.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.EmergencyShuttle.cs index 9914408ed0..68c82b5abc 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.EmergencyShuttle.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.EmergencyShuttle.cs @@ -55,9 +55,6 @@ public sealed partial class ShuttleSystem private void InitializeEscape() { -#if !FULL_RELEASE - _configManager.OverrideDefault(CCVars.EmergencyShuttleEnabled, false); -#endif _emergencyShuttleEnabled = _configManager.GetCVar(CCVars.EmergencyShuttleEnabled); // Don't immediately invoke as roundstart will just handle it. _configManager.OnValueChanged(CCVars.EmergencyShuttleEnabled, SetEmergencyShuttleEnabled); diff --git a/Content.Server/StationEvents/EventManagerSystem.cs b/Content.Server/StationEvents/EventManagerSystem.cs index 2bf556d89c..6a2b646602 100644 --- a/Content.Server/StationEvents/EventManagerSystem.cs +++ b/Content.Server/StationEvents/EventManagerSystem.cs @@ -30,10 +30,6 @@ public sealed class EventManagerSystem : EntitySystem _sawmill = Logger.GetSawmill("events"); -#if DEBUG - _configurationManager.OverrideDefault(CCVars.EventsEnabled, false); -#endif - _configurationManager.OnValueChanged(CCVars.EventsEnabled, SetEnabled, true); } diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 36931b3eb6..fd521a9615 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -140,7 +140,7 @@ namespace Content.Shared.CCVar /// Controls if the lobby is enabled. If it is not, and there are no available jobs, you may get stuck on a black screen. /// public static readonly CVarDef - GameLobbyEnabled = CVarDef.Create("game.lobbyenabled", false, CVar.ARCHIVE); + GameLobbyEnabled = CVarDef.Create("game.lobbyenabled", true, CVar.ARCHIVE); /// /// Controls the duration of the lobby timer in seconds. Defaults to 2 minutes and 30 seconds. @@ -1339,7 +1339,6 @@ namespace Content.Shared.CCVar * PLAYTIME */ - /// /// Time between play time autosaves, in seconds. /// @@ -1391,5 +1390,38 @@ namespace Content.Shared.CCVar /// public static readonly CVarDef InfoLinksBugReport = CVarDef.Create("infolinks.bug_report", "", CVar.SERVER | CVar.REPLICATED); + + /* + * CONFIG + */ + + // These are server-only for now since I don't foresee a client use yet, + // and I don't wanna have to start coming up with like .client suffixes and stuff like that. + + /// + /// Configuration presets to load during startup. + /// Multiple presets can be separated by comma and are loaded in order. + /// + /// + /// Loaded presets must be located under the ConfigPresets/ resource directory and end with the .toml extension. + /// Only the file name (without extension) must be given for this variable. + /// + public static readonly CVarDef ConfigPresets = + CVarDef.Create("config.presets", "", CVar.SERVERONLY); + + /// + /// Whether to load the preset development CVars. + /// This disables some things like lobby to make development easier. + /// Even when true, these are only loaded if the game is compiled with DEVELOPMENT set. + /// + public static readonly CVarDef ConfigPresetDevelopment = + CVarDef.Create("config.preset_development", true, CVar.SERVERONLY); + + /// + /// Whether to load the preset debug CVars. + /// Even when true, these are only loaded if the game is compiled with DEBUG set. + /// + public static readonly CVarDef ConfigPresetDebug = + CVarDef.Create("config.preset_debug", true, CVar.SERVERONLY); } } diff --git a/Resources/ConfigPresets/Build/debug.toml b/Resources/ConfigPresets/Build/debug.toml new file mode 100644 index 0000000000..850f666167 --- /dev/null +++ b/Resources/ConfigPresets/Build/debug.toml @@ -0,0 +1,7 @@ +[events] +# Annoying +enabled = false + +[npc] +# Makes physics etc debugging easier. +enabled = false diff --git a/Resources/ConfigPresets/Build/development.toml b/Resources/ConfigPresets/Build/development.toml new file mode 100644 index 0000000000..6e1c24c3d7 --- /dev/null +++ b/Resources/ConfigPresets/Build/development.toml @@ -0,0 +1,13 @@ +[game] +# Straight in-game baby +lobbyenabled = false + +[physics] +# Makes mapping annoying +grid_splitting = false + +[shuttle] +# Wastes startup time +cargo = false +emergency_enabled = false +