diff --git a/Robust.Shared/Configuration/ConfigurationManager.cs b/Robust.Shared/Configuration/ConfigurationManager.cs index 72844ae3dde..860fb0a2211 100644 --- a/Robust.Shared/Configuration/ConfigurationManager.cs +++ b/Robust.Shared/Configuration/ConfigurationManager.cs @@ -74,6 +74,24 @@ public HashSet LoadFromTomlStream(Stream file) return LoadFromTomlTable(tblRoot); } + /// + public HashSet ValidateTomlStream(Stream file) + { + TomlTable tblRoot; + try + { + tblRoot = Toml.ReadStream(file); + } + catch (Exception e) + { + _sawmill.Error("Unable to load configuration from table:\n{0}", e); + return []; + } + + return ValidateTomlTable(tblRoot); + } + + /// private HashSet LoadFromTomlTable(TomlTable table) { var loaded = new HashSet(); @@ -98,6 +116,17 @@ private HashSet LoadFromTomlTable(TomlTable table) return loaded; } + /// + private HashSet ValidateTomlTable(TomlTable table) + { + var loaded = new HashSet(); + + foreach (var (cvar, _) in ParseCVarValuesFromToml(table)) + loaded.Add(cvar); + + return loaded; + } + private void RunDeferredInvokeCallbacks(in ValueList callbackEvents) { foreach (var callback in callbackEvents) diff --git a/Robust.Shared/Configuration/IConfigurationManager.cs b/Robust.Shared/Configuration/IConfigurationManager.cs index 13a130bf6e0..06084865ac6 100644 --- a/Robust.Shared/Configuration/IConfigurationManager.cs +++ b/Robust.Shared/Configuration/IConfigurationManager.cs @@ -69,8 +69,24 @@ public interface IConfigurationManager /// void SaveToTomlStream(Stream stream, IEnumerable cvars); + /// + /// Load a TOML config file, using all CVar values specified inside. + /// + /// + /// All CVars in the TOML file must be registered when this function is called. + /// + /// A set of all CVars touched. HashSet LoadFromTomlStream(Stream stream); + /// + /// Load a TOML config file and try and parse its contents without side-effects. + /// + /// + /// All CVars in the TOML file must be registered when this function is called. + /// + /// A set of all CVars that would be touched by this stream. + HashSet ValidateTomlStream(Stream stream); + /// /// Load a TOML config file and use the CVar values specified as an . ///