Fix crashes and save issues

This commit is contained in:
John Gross
2017-07-31 13:12:01 -07:00
parent 525b496774
commit 2f3b6cdda7
9 changed files with 25 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
# Torch 1.1.205.478
# Torch 1.1.207.7
* Notes
- This release makes significant changes to TorchConfig.xml. It has been renamed to Torch.cfg and has different options.
* Features

View File

@@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.0.207.7")]
[assembly: AssemblyFileVersion("1.0.207.7")]
[assembly: AssemblyVersion("1.0.212.393")]
[assembly: AssemblyFileVersion("1.0.212.393")]

View File

@@ -45,6 +45,8 @@ namespace Torch.Server.Managers
MyFileSystem.Reset();
MyFileSystem.ExePath = Path.Combine(Torch.GetManager<FilesystemManager>().TorchDirectory, "DedicatedServer64");
MyFileSystem.Init("Content", path);
//Initializes saves path. Why this isn't in Init() we may never know.
MyFileSystem.InitUserSpecific(null);
var configPath = Path.Combine(path, CONFIG_NAME);
if (!File.Exists(configPath))
@@ -68,6 +70,8 @@ namespace Torch.Server.Managers
return;
}
LoadWorldMods();
/*
if (string.IsNullOrEmpty(DedicatedConfig.LoadWorld))
{
@@ -85,7 +89,7 @@ namespace Torch.Server.Managers
private void LoadWorldMods(bool modsOnly = true)
{
if (DedicatedConfig.LoadWorld == null)
if (string.IsNullOrEmpty(DedicatedConfig.LoadWorld))
return;
var sandboxPath = Path.Combine(DedicatedConfig.LoadWorld, "Sandbox.sbc");

View File

@@ -84,10 +84,14 @@ namespace Torch.Server
{
var pid = int.Parse(_config.WaitForPID);
var waitProc = Process.GetProcessById(pid);
_log.Warn($"Waiting for process {pid} to exit.");
waitProc.WaitForExit();
_log.Info("Continuing in 5 seconds.");
Thread.Sleep(5000);
if (!waitProc.HasExited)
{
_log.Warn($"Killing old process {pid}.");
waitProc.Kill();
}
}
catch
{

View File

@@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.1.207.7")]
[assembly: AssemblyFileVersion("1.1.207.7")]
[assembly: AssemblyVersion("1.1.212.393")]
[assembly: AssemblyFileVersion("1.1.212.393")]

View File

@@ -40,7 +40,7 @@ namespace Torch.Commands
public bool IsCommand(string command)
{
return command.Length > 1 && command[0] == Prefix;
return !string.IsNullOrEmpty(command) && command[0] == Prefix;
}
public void RegisterCommandModule(Type moduleType, ITorchPlugin plugin = null)

View File

@@ -120,6 +120,9 @@ namespace Torch.Managers
/// <inheritdoc />
public void SendMessage(string message, string author = "Server", long playerId = 0, string font = MyFontEnum.Red)
{
if (string.IsNullOrEmpty(message))
return;
ChatHistory.Add(new ChatMessage(DateTime.Now, 0, author, message));
var commands = Torch.GetManager<CommandManager>();
if (commands.IsCommand(message))

View File

@@ -126,8 +126,7 @@ namespace Torch.Managers
}
catch (Exception ex)
{
_log.Fatal(ex);
_log.Fatal(ex, "~Error processing event!");
_log.Error(ex);
//crash after logging, bad things could happen if we continue on with bad data
throw;
}
@@ -200,8 +199,8 @@ namespace Torch.Managers
}
catch (Exception ex)
{
_log.Fatal(ex);
_log.Fatal(ex, "Error when returning control to game server!");
_log.Error(ex, "Error processing network event!");
_log.Error(ex);
//crash after logging, bad things could happen if we continue on with bad data
throw;
}

View File

@@ -121,9 +121,10 @@ namespace Torch.Managers
commands.RegisterPluginCommands(plugin);
}
catch
catch (Exception e)
{
_log.Error($"Error loading plugin '{type.FullName}'");
_log.Error(e);
throw;
}
}