-
-
Notifications
You must be signed in to change notification settings - Fork 4
Server Config
Stratum does not piggyback on vanilla server config. It loads its own config files at startup and keeps the main config split into sidecars.
- Config model:
sources/VintagestoryLib/Vintagestory.Server/StratumConfig.cs - Config load/save:
sources/VintagestoryLib/Vintagestory.Server/StratumRuntime.cs - Startup wiring:
sources/VintagestoryLib/Vintagestory.Server/ServerSystemStratum.cs
stratum.jsonstratum-commands.jsonstratum-performance.json
StratumRuntime.LoadOrCreateConfig sets those paths under the game config folder and saves them back out after load.
ConfigPath = Path.Combine(GamePaths.Config, "stratum.json");
CommandsConfigPath = Path.Combine(GamePaths.Config, "stratum-commands.json");
PerformanceConfigPath = Path.Combine(GamePaths.Config, "stratum-performance.json");
if (!File.Exists(ConfigPath))
{
Config = StratumConfig.CreateDefault();
SaveConfig();
}
else
{
string json = File.ReadAllText(ConfigPath);
Config = JsonConvert.DeserializeObject<StratumConfig>(json) ?? StratumConfig.CreateDefault();
if (File.Exists(CommandsConfigPath))
{
Config.Commands = JsonConvert.DeserializeObject<StratumCommandsConfig>(File.ReadAllText(CommandsConfigPath)) ?? new StratumCommandsConfig();
}
if (File.Exists(PerformanceConfigPath))
{
Config.Performance = JsonConvert.DeserializeObject<StratumPerformanceConfig>(File.ReadAllText(PerformanceConfigPath)) ?? new StratumPerformanceConfig();
}
Config.EnsurePopulated();
SaveConfig();
}ServerSystemStratum.OnBeginConfiguration is where Stratum loads config and applies the startup-only pieces:
bool loaded = StratumRuntime.LoadOrCreateConfig(server, out string message);
if (StratumRuntime.Config.Diagnostics.LogStartupSummary)
{
LogStartupSummary(loaded, message);
}
StratumBlockEntityInitConfig beInit = StratumRuntime.Config.Performance.BlockEntityInit;
BlockEntity.StratumDefaultInitialDelaySpreadMs = (beInit != null && beInit.Enabled) ? beInit.MaxStaggerMs : 0;That same method also applies the timer-resolution setting and optional startup preflight.
OnBeginRunGame then wires runtime services and identity config keys (stratum, stratumVersion, stratumBaseGameVersion).
StratumConfig is split into these areas:
DiagnosticsHardeningPacketLimitsPacketBackPressureBlockBreakGuardsClientModPolicyPerformanceCommandsChatThemeCrowdSpawnLoadTestingLoginProtectionPlayerPrivacyNametagsNetwork
The config also carries a ConfigVersion and a small migration step for older configs.
Current default config version is 2. The migration code only touches values that match the old default exactly, so custom settings stay custom.
if (ConfigVersion < 2)
{
StratumPhysicsConfig phys = Performance?.Physics;
if (phys != null)
{
if (phys.ParallelThreshold == 256) phys.ParallelThreshold = 32;
}
ConfigVersion = 2;
}If you want to understand what a setting does, the order is:
- The JSON default in
StratumServer/stratum.default.json - The config class in
StratumConfig - The runtime class that consumes it
- The patch file that changes the live behavior