Add independent console option. Various random fixes

This commit is contained in:
Brant Martin
2019-02-20 20:20:09 -05:00
parent 2bb3aa84a7
commit 967d8ce068
4 changed files with 15 additions and 7 deletions

View File

@@ -111,8 +111,15 @@ quit";
init.ContinueWith(x => _server.Start()); init.ContinueWith(x => _server.Start());
Log.Info("Showing UI"); Log.Info("Showing UI");
#if !DEBUG
if (!_config.IndependentConsole)
{
Console.SetOut(TextWriter.Null); Console.SetOut(TextWriter.Null);
NativeMethods.FreeConsole(); NativeMethods.FreeConsole();
}
#endif
new TorchUI(_server).ShowDialog(); new TorchUI(_server).ShowDialog();
} }
else else

View File

@@ -72,10 +72,13 @@ namespace Torch.Server
[Obsolete("Use vanilla reserved slot config")] [Obsolete("Use vanilla reserved slot config")]
public HashSet<ulong> ReservedPlayers { get; set; } = new HashSet<ulong>(); public HashSet<ulong> ReservedPlayers { get; set; } = new HashSet<ulong>();
//Prevent reserved players being written to disk, but allow it to bre read //Prevent reserved players being written to disk, but allow it to be read
//remove this when ReservedPlayers is removed //remove this when ReservedPlayers is removed
private bool ShouldSerializeReservedPlayers() => false; private bool ShouldSerializeReservedPlayers() => false;
[Arg("console", "Keeps a separate console window open after the main UI loads.")]
public bool IndependentConsole { get; set; } = false;
[XmlIgnore] [XmlIgnore]
private string _path; private string _path;

View File

@@ -195,8 +195,7 @@ namespace Torch.Server
public override void Init(object gameInstance) public override void Init(object gameInstance)
{ {
base.Init(gameInstance); base.Init(gameInstance);
var game = gameInstance as MySandboxGame; if (gameInstance is MySandboxGame && MySession.Static != null)
if (game != null && MySession.Static != null)
State = ServerState.Running; State = ServerState.Running;
else else
State = ServerState.Stopped; State = ServerState.Stopped;

View File

@@ -273,8 +273,7 @@ namespace Torch
MySessionLoader.LoadSingleplayerSession(sessionPath); MySessionLoader.LoadSingleplayerSession(sessionPath);
return; return;
} }
ulong checkpointSize; MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out ulong checkpointSize);
MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSize);
if (MySession.IsCompatibleVersion(checkpoint)) if (MySession.IsCompatibleVersion(checkpoint))
{ {
if (MyWorkshop.DownloadWorldModsBlocking(checkpoint.Mods, null).Success) if (MyWorkshop.DownloadWorldModsBlocking(checkpoint.Mods, null).Success)