mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Add non-generic GetCVar.
Surprised we didn't have this.
This commit is contained in:
@@ -40,6 +40,7 @@ END TEMPLATE-->
|
||||
### New features
|
||||
|
||||
* You can now specify CVar overrides via environment variable with the `ROBUST_CVAR_*` prefix. For example `ROBUST_CVAR_game__hostname=foobar` would set the appropriate CVar. Double underscores in the environment variable name are replaced with ".".
|
||||
* Added non-generic variant of `GetCVar` to `IConfigurationManager`.
|
||||
|
||||
### Bugfixes
|
||||
|
||||
|
||||
@@ -558,17 +558,21 @@ namespace Robust.Shared.Configuration
|
||||
OverrideDefault(def.Name, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public T GetCVar<T>(string name)
|
||||
public object GetCVar(string name)
|
||||
{
|
||||
using var _ = Lock.ReadGuard();
|
||||
if (_configVars.TryGetValue(name, out var cVar) && cVar.Registered)
|
||||
//TODO: Make flags work, required non-derpy net system.
|
||||
return (T)(GetConfigVarValue(cVar))!;
|
||||
return GetConfigVarValue(cVar);
|
||||
|
||||
throw new InvalidConfigurationException($"Trying to get unregistered variable '{name}'");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public T GetCVar<T>(string name)
|
||||
{
|
||||
return (T)GetCVar(name);
|
||||
}
|
||||
|
||||
public T GetCVar<T>(CVarDef<T> def) where T : notnull
|
||||
{
|
||||
return GetCVar<T>(def.Name);
|
||||
|
||||
@@ -118,6 +118,13 @@ namespace Robust.Shared.Configuration
|
||||
/// <param name="value">The new default value of the CVar.</param>
|
||||
void OverrideDefault<T>(CVarDef<T> def, T value) where T : notnull;
|
||||
|
||||
/// <summary>
|
||||
/// Get the value of a CVar.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the CVar.</param>
|
||||
/// <returns></returns>
|
||||
object GetCVar(string name);
|
||||
|
||||
/// <summary>
|
||||
/// Get the value of a CVar.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user