diff --git a/Torch.API/ITorchBase.cs b/Torch.API/ITorchBase.cs
index cff8cd3..06c4ae0 100644
--- a/Torch.API/ITorchBase.cs
+++ b/Torch.API/ITorchBase.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
+using Microsoft.Extensions.Configuration;
using Torch.API.Managers;
using Torch.API.Session;
using VRage.Game.ModAPI;
@@ -25,6 +26,11 @@ namespace Torch.API
/// Configuration for the current instance.
///
ITorchConfig Config { get; }
+
+ ///
+ /// Extended Configuration for the current instance.
+ ///
+ IConfiguration Configuration { get; }
///
[Obsolete]
diff --git a/Torch.API/Torch.API.csproj b/Torch.API/Torch.API.csproj
index fa44ad7..e5a9810 100644
--- a/Torch.API/Torch.API.csproj
+++ b/Torch.API/Torch.API.csproj
@@ -17,6 +17,7 @@
+
diff --git a/Torch.API/packages.lock.json b/Torch.API/packages.lock.json
index 5aa3fce..cab203d 100644
--- a/Torch.API/packages.lock.json
+++ b/Torch.API/packages.lock.json
@@ -8,6 +8,15 @@
"resolved": "0.9.0",
"contentHash": "xCqODS+wzpUXNtg4bMMvXG5PLbP0iTwRzRn2R+zWHKm83E6tbV2bCagawXp1EnZeNpd5OXpMxehulZWns8efzQ=="
},
+ "Microsoft.Extensions.Configuration.Binder": {
+ "type": "Direct",
+ "requested": "[7.0.4, )",
+ "resolved": "7.0.4",
+ "contentHash": "8+XPvJnHZsYgHOQlcMuQe7QNF5KdVKHH1F/wW3nd8/u81Gk/XFAYMDP0Lpz18h7/AM95M662vvqMorcYxCBB4w==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration.Abstractions": "7.0.0"
+ }
+ },
"NLog": {
"type": "Direct",
"requested": "[5.1.0, )",
@@ -64,6 +73,19 @@
"resolved": "6.0.0",
"contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg=="
},
+ "Microsoft.Extensions.Configuration.Abstractions": {
+ "type": "Transitive",
+ "resolved": "7.0.0",
+ "contentHash": "f34u2eaqIjNO9YLHBz8rozVZ+TcFiFs0F3r7nUJd7FRkVSxk8u4OpoK226mi49MwexHOR2ibP9MFvRUaLilcQQ==",
+ "dependencies": {
+ "Microsoft.Extensions.Primitives": "7.0.0"
+ }
+ },
+ "Microsoft.Extensions.Primitives": {
+ "type": "Transitive",
+ "resolved": "7.0.0",
+ "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q=="
+ },
"Newtonsoft.Json": {
"type": "Transitive",
"resolved": "13.0.1",
diff --git a/Torch.Server/Initializer.cs b/Torch.Server/Initializer.cs
index ef8d766..6f4c2fe 100644
--- a/Torch.Server/Initializer.cs
+++ b/Torch.Server/Initializer.cs
@@ -85,9 +85,9 @@ namespace Torch.Server
return true;
}
- public void Run()
+ public void Run(IConfiguration configuration)
{
- _server = new TorchServer(Config, ApplicationContext.Current.InstanceDirectory.FullName, ApplicationContext.Current.InstanceName);
+ _server = new TorchServer(Config, ApplicationContext.Current.InstanceDirectory.FullName, ApplicationContext.Current.InstanceName, configuration);
if (ApplicationContext.Current.IsService || Config.NoGui)
{
diff --git a/Torch.Server/Program.cs b/Torch.Server/Program.cs
index 07bf777..f0e701d 100644
--- a/Torch.Server/Program.cs
+++ b/Torch.Server/Program.cs
@@ -39,7 +39,7 @@ namespace Torch.Server
context.GameBinariesDirectory.FullName);
#endif
- initializer.Run();
+ initializer.Run(configuration);
}
private static void SetupLogging(IApplicationContext context, IConfiguration configuration)
diff --git a/Torch.Server/TorchServer.cs b/Torch.Server/TorchServer.cs
index eeb84cb..bcd3491 100644
--- a/Torch.Server/TorchServer.cs
+++ b/Torch.Server/TorchServer.cs
@@ -8,6 +8,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using Microsoft.Diagnostics.Runtime;
+using Microsoft.Extensions.Configuration;
using NLog;
using PropertyChanged;
using Sandbox;
@@ -46,8 +47,9 @@ namespace Torch.Server
//Here to trigger rebuild
///
- public TorchServer(ITorchConfig config, string instancePath, string instanceName) : base(config)
+ public TorchServer(ITorchConfig config, string instancePath, string instanceName, IConfiguration configuration) : base(config)
{
+ Configuration = configuration;
InstancePath = instancePath;
InstanceName = instanceName;
DedicatedInstance = new InstanceManager(this);
@@ -136,6 +138,8 @@ namespace Torch.Server
Log.Info($"Initialized server '{InstanceName}' at '{InstancePath}'");
}
+ public override IConfiguration Configuration { get; }
+
///
public override void Start()
{
diff --git a/Torch.Server/packages.lock.json b/Torch.Server/packages.lock.json
index 567bf08..a107874 100644
--- a/Torch.Server/packages.lock.json
+++ b/Torch.Server/packages.lock.json
@@ -601,6 +601,7 @@
"type": "Project",
"dependencies": {
"JorgeSerrano.Json.JsonSnakeCaseNamingPolicy": "[0.9.0, )",
+ "Microsoft.Extensions.Configuration.Binder": "[7.0.4, )",
"NLog": "[5.1.0, )",
"NuGet.Commands": "[6.4.0, )",
"NuGet.DependencyResolver.Core": "[6.4.0, )",
diff --git a/Torch/TorchBase.cs b/Torch/TorchBase.cs
index f1ad7bf..c72603a 100644
--- a/Torch/TorchBase.cs
+++ b/Torch/TorchBase.cs
@@ -5,6 +5,7 @@ using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.Extensions.Configuration;
using NLog;
using Sandbox;
using Sandbox.Game;
@@ -59,6 +60,8 @@ namespace Torch
///
public ITorchConfig Config { get; protected set; }
+ public abstract IConfiguration Configuration { get; }
+
///
public SemanticVersioning.Version TorchVersion { get; }
public string InstancePath { get; protected init;}
diff --git a/Torch/VRageGame.cs b/Torch/VRageGame.cs
index 9d1b913..61e905e 100644
--- a/Torch/VRageGame.cs
+++ b/Torch/VRageGame.cs
@@ -8,6 +8,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Havok;
+using Microsoft.Extensions.Configuration;
using NLog;
using NLog.Fluent;
using Sandbox;
@@ -30,6 +31,7 @@ using VRage.Dedicated;
using VRage.EOS;
using VRage.FileSystem;
using VRage.Game;
+using VRage.Game.ModAPI;
using VRage.Game.ObjectBuilder;
using VRage.Game.SessionComponents;
using VRage.GameServices;
@@ -169,10 +171,13 @@ namespace Torch
MyInitializer.InvokeBeforeRun(_appSteamId, _appName, MyVRage.Platform.System.GetRootPath(), _userDataPath);
_log.Info("Loading Dedicated Config");
+
// object created in SpaceEngineersGame.SetupPerGameSettings()
MySandboxGame.ConfigDedicated.Load();
- MyPlatformGameSettings.CONSOLE_COMPATIBLE = MySandboxGame.ConfigDedicated.ConsoleCompatibility;
+ ApplyConfiguration(MySandboxGame.ConfigDedicated);
+ MyPlatformGameSettings.CONSOLE_COMPATIBLE = MySandboxGame.ConfigDedicated.ConsoleCompatibility;
+
//Type.GetType("VRage.Steam.MySteamService, VRage.Steam").GetProperty("IsActive").GetSetMethod(true).Invoke(service, new object[] {SteamAPI.Init()});
_log.Info("Initializing network services");
@@ -302,6 +307,18 @@ namespace Torch
MyGlobalTypeMetadata.Static.Init(false);
}
+ private void ApplyConfiguration(IMyConfigDedicated dedicated)
+ {
+ var config = _torch.Configuration.GetSection("DedicatedServer");
+
+ dedicated.ServerPort = config.GetValue("Port", dedicated.ServerPort);
+ dedicated.ConsoleCompatibility = config.GetValue("ConsoleCompatibility", dedicated.ConsoleCompatibility);
+ dedicated.IP = config.GetValue("Ip", dedicated.IP);
+ dedicated.WorldName = config.GetValue("WorldName", dedicated.WorldName);
+ dedicated.ServerName = config.GetValue("ServerName", dedicated.ServerName);
+ dedicated.ServerDescription = config.GetValue("ServerDescription", dedicated.ServerDescription);
+ }
+
private void Destroy()
{
_game.Dispose();
diff --git a/Torch/packages.lock.json b/Torch/packages.lock.json
index 194a78c..b771224 100644
--- a/Torch/packages.lock.json
+++ b/Torch/packages.lock.json
@@ -145,6 +145,27 @@
"resolved": "3.3.3",
"contentHash": "j/rOZtLMVJjrfLRlAMckJLPW/1rze9MT1yfWqSIbUPGRu1m1P0fuo9PmqapwsmePfGB5PJrudQLvmUOAMF0DqQ=="
},
+ "Microsoft.Extensions.Configuration.Abstractions": {
+ "type": "Transitive",
+ "resolved": "7.0.0",
+ "contentHash": "f34u2eaqIjNO9YLHBz8rozVZ+TcFiFs0F3r7nUJd7FRkVSxk8u4OpoK226mi49MwexHOR2ibP9MFvRUaLilcQQ==",
+ "dependencies": {
+ "Microsoft.Extensions.Primitives": "7.0.0"
+ }
+ },
+ "Microsoft.Extensions.Configuration.Binder": {
+ "type": "Transitive",
+ "resolved": "7.0.4",
+ "contentHash": "8+XPvJnHZsYgHOQlcMuQe7QNF5KdVKHH1F/wW3nd8/u81Gk/XFAYMDP0Lpz18h7/AM95M662vvqMorcYxCBB4w==",
+ "dependencies": {
+ "Microsoft.Extensions.Configuration.Abstractions": "7.0.0"
+ }
+ },
+ "Microsoft.Extensions.Primitives": {
+ "type": "Transitive",
+ "resolved": "7.0.0",
+ "contentHash": "um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q=="
+ },
"Microsoft.Xaml.Behaviors.Wpf": {
"type": "Transitive",
"resolved": "1.1.31",
@@ -383,6 +404,7 @@
"type": "Project",
"dependencies": {
"JorgeSerrano.Json.JsonSnakeCaseNamingPolicy": "[0.9.0, )",
+ "Microsoft.Extensions.Configuration.Binder": "[7.0.4, )",
"NLog": "[5.1.0, )",
"NuGet.Commands": "[6.4.0, )",
"NuGet.DependencyResolver.Core": "[6.4.0, )",