Get command system working, permissions system and ModAPI extensions in progress

This commit is contained in:
John Gross
2017-01-11 00:19:21 -08:00
parent 4949982fa8
commit 10836cbbb2
27 changed files with 625 additions and 149 deletions

View File

@@ -27,14 +27,22 @@ namespace Torch.Server
{
public Thread GameThread { get; private set; }
public bool IsRunning { get; private set; }
public bool IsService { get; set; }
public bool IsService { get; }
public string InstancePath { get; private set; }
public string InstanceName { get; }
public event Action SessionLoading;
private readonly AutoResetEvent _stopHandle = new AutoResetEvent(false);
internal TorchServer()
internal TorchServer(string instanceName = null)
{
if (instanceName != null)
{
IsService = true;
InstanceName = instanceName;
}
MySession.OnLoading += OnSessionLoading;
}
@@ -59,6 +67,8 @@ namespace Torch.Server
};
var gameVersion = MyPerGameSettings.BasicGameInfo.GameVersion;
MyFinalBuildConstants.APP_VERSION = gameVersion ?? 0;
InstancePath = InstanceName != null ? GetInstancePath(true, InstanceName) : GetInstancePath();
}
private void OnSessionLoading()
@@ -87,7 +97,7 @@ namespace Torch.Server
Environment.SetEnvironmentVariable("SteamAppId", MyPerServerSettings.AppId.ToString());
Log.Trace("Invoking RunMain");
try { Reflection.InvokeStaticMethod(typeof(DedicatedServer), "RunMain", "Torch", null, IsService, true); }
try { Reflection.InvokeStaticMethod(typeof(DedicatedServer), "RunMain", InstanceName, InstancePath, false, true); }
catch (Exception e)
{
Log.Error(e);
@@ -131,6 +141,14 @@ namespace Torch.Server
IsRunning = false;
}
private string GetInstancePath(bool isService = false, string instanceName = "Torch")
{
if (isService)
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), MyPerServerSettings.GameDSName, instanceName);
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), MyPerServerSettings.GameDSName);
}
private void CleanupProfilers()
{
typeof(MyRenderProfiler).GetField("m_threadProfiler", BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, null);