From 2f3b6cdda7444d84604d209b1f5f02454e0d0ab3 Mon Sep 17 00:00:00 2001 From: John Gross Date: Mon, 31 Jul 2017 13:12:01 -0700 Subject: [PATCH] Fix crashes and save issues --- CHANGELOG.md | 2 +- Torch.Client/Properties/AssemblyInfo.cs | 4 ++-- Torch.Server/Managers/InstanceManager.cs | 6 +++++- Torch.Server/Program.cs | 8 ++++++-- Torch.Server/Properties/AssemblyInfo.cs | 4 ++-- Torch/Commands/CommandManager.cs | 2 +- Torch/Managers/MultiplayerManager.cs | 3 +++ Torch/Managers/NetworkManager/NetworkManager.cs | 7 +++---- Torch/Managers/PluginManager.cs | 3 ++- 9 files changed, 25 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aea744..26db267 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Torch.Client/Properties/AssemblyInfo.cs b/Torch.Client/Properties/AssemblyInfo.cs index 742eb73..bec242f 100644 --- a/Torch.Client/Properties/AssemblyInfo.cs +++ b/Torch.Client/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("1.0.207.7")] -[assembly: AssemblyFileVersion("1.0.207.7")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.212.393")] +[assembly: AssemblyFileVersion("1.0.212.393")] \ No newline at end of file diff --git a/Torch.Server/Managers/InstanceManager.cs b/Torch.Server/Managers/InstanceManager.cs index 4767d49..aef99e2 100644 --- a/Torch.Server/Managers/InstanceManager.cs +++ b/Torch.Server/Managers/InstanceManager.cs @@ -45,6 +45,8 @@ namespace Torch.Server.Managers MyFileSystem.Reset(); MyFileSystem.ExePath = Path.Combine(Torch.GetManager().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"); diff --git a/Torch.Server/Program.cs b/Torch.Server/Program.cs index e445998..4a4fac9 100644 --- a/Torch.Server/Program.cs +++ b/Torch.Server/Program.cs @@ -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 { diff --git a/Torch.Server/Properties/AssemblyInfo.cs b/Torch.Server/Properties/AssemblyInfo.cs index 90c0163..d6f73eb 100644 --- a/Torch.Server/Properties/AssemblyInfo.cs +++ b/Torch.Server/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("1.1.207.7")] -[assembly: AssemblyFileVersion("1.1.207.7")] \ No newline at end of file +[assembly: AssemblyVersion("1.1.212.393")] +[assembly: AssemblyFileVersion("1.1.212.393")] \ No newline at end of file diff --git a/Torch/Commands/CommandManager.cs b/Torch/Commands/CommandManager.cs index f19fec0..dd67c88 100644 --- a/Torch/Commands/CommandManager.cs +++ b/Torch/Commands/CommandManager.cs @@ -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) diff --git a/Torch/Managers/MultiplayerManager.cs b/Torch/Managers/MultiplayerManager.cs index f1b0465..8c7205a 100644 --- a/Torch/Managers/MultiplayerManager.cs +++ b/Torch/Managers/MultiplayerManager.cs @@ -120,6 +120,9 @@ namespace Torch.Managers /// 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(); if (commands.IsCommand(message)) diff --git a/Torch/Managers/NetworkManager/NetworkManager.cs b/Torch/Managers/NetworkManager/NetworkManager.cs index a262690..8a4f947 100644 --- a/Torch/Managers/NetworkManager/NetworkManager.cs +++ b/Torch/Managers/NetworkManager/NetworkManager.cs @@ -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; } diff --git a/Torch/Managers/PluginManager.cs b/Torch/Managers/PluginManager.cs index ff9ec71..d3acf8f 100644 --- a/Torch/Managers/PluginManager.cs +++ b/Torch/Managers/PluginManager.cs @@ -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; } }