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());
Log.Info("Showing UI");
#if !DEBUG
if (!_config.IndependentConsole)
{
Console.SetOut(TextWriter.Null);
NativeMethods.FreeConsole();
}
#endif
new TorchUI(_server).ShowDialog();
}
else

View File

@@ -72,10 +72,13 @@ namespace Torch.Server
[Obsolete("Use vanilla reserved slot config")]
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
private bool ShouldSerializeReservedPlayers() => false;
[Arg("console", "Keeps a separate console window open after the main UI loads.")]
public bool IndependentConsole { get; set; } = false;
[XmlIgnore]
private string _path;

View File

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

View File

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