@@ -34,24 +34,22 @@ public class TorchServer : TorchBase, ITorchServer
3434 {
3535 public Thread GameThread { get ; private set ; }
3636 public bool IsRunning { get ; private set ; }
37- public string InstancePath { get ; private set ; }
38- public string InstanceName { get ; private set ; }
37+ public TorchConfig Config { get ; }
38+ public string InstanceName => Config ? . InstanceName ;
39+ public string InstancePath => Config ? . InstancePath ;
3940
4041 private readonly AutoResetEvent _stopHandle = new AutoResetEvent ( false ) ;
4142
42- public TorchServer ( TorchConfig options = null )
43+ public TorchServer ( TorchConfig config = null )
4344 {
44- var opt = options ?? new TorchConfig ( ) ;
45-
46- InstanceName = opt . InstanceName ;
47- InstancePath = opt . InstancePath ;
45+ Config = config ?? new TorchConfig ( ) ;
4846 }
4947
5048 public override void Init ( )
5149 {
5250 base . Init ( ) ;
5351
54- Log . Info ( $ "Init server instance '{ InstanceName } ' at path '{ InstancePath } '") ;
52+ Log . Info ( $ "Init server instance '{ Config . InstanceName } ' at path '{ Config . InstancePath } '") ;
5553
5654 MyFakes . ENABLE_INFINARIO = false ;
5755 MyPerGameSettings . SendLogToKeen = false ;
@@ -73,14 +71,6 @@ public void SetConfig(IMyConfigDedicated config)
7371 MySandboxGame . ConfigDedicated = config ;
7472 }
7573
76- public void SetInstance ( string path = null , string name = null )
77- {
78- if ( path != null )
79- InstancePath = path ;
80- if ( name != null )
81- InstanceName = name ;
82- }
83-
8474 public void Start ( IMyConfigDedicated config )
8575 {
8676 SetConfig ( config ) ;
@@ -95,14 +85,15 @@ public override void Start()
9585 if ( IsRunning )
9686 throw new InvalidOperationException ( "Server is already running." ) ;
9787
88+ Config . Save ( ) ;
9889 IsRunning = true ;
9990 Log . Info ( "Starting server." ) ;
10091
10192 MySandboxGame . IsDedicated = true ;
10293 Environment . SetEnvironmentVariable ( "SteamAppId" , MyPerServerSettings . AppId . ToString ( ) ) ;
10394
10495 Log . Trace ( "Invoking RunMain" ) ;
105- try { Reflection . InvokeStaticMethod ( typeof ( DedicatedServer ) , "RunMain" , InstanceName , InstancePath , false , true ) ; }
96+ try { Reflection . InvokeStaticMethod ( typeof ( DedicatedServer ) , "RunMain" , Config . InstanceName , Config . InstancePath , false , true ) ; }
10697 catch ( Exception e )
10798 {
10899 Log . Error ( "Error running server." ) ;
0 commit comments