From cc91fa36539d4f8f4c1efde48f66ec769a5dff1f Mon Sep 17 00:00:00 2001 From: John Gross Date: Sat, 26 Oct 2019 11:38:38 -0700 Subject: [PATCH] Fix mod downloading, more descriptive sandbox error message --- Torch.Server/Initializer.cs | 4 ++-- Torch.Server/Managers/MultiplayerManagerDedicated.cs | 2 +- Torch/MySteamServiceWrapper.cs | 7 ++++++- Torch/VRageGame.cs | 8 +++----- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Torch.Server/Initializer.cs b/Torch.Server/Initializer.cs index 43c7b1c..6ea29a2 100644 --- a/Torch.Server/Initializer.cs +++ b/Torch.Server/Initializer.cs @@ -216,11 +216,11 @@ quit"; StandardOutputEncoding = Encoding.ASCII }; var cmd = Process.Start(steamCmdProc); - + // ReSharper disable once PossibleNullReferenceException while (!cmd.HasExited) { - log.Info(cmd.StandardOutput.ReadLine()); + log.Info(cmd.StandardOutput.ReadToEnd()); Thread.Sleep(100); } } diff --git a/Torch.Server/Managers/MultiplayerManagerDedicated.cs b/Torch.Server/Managers/MultiplayerManagerDedicated.cs index 8a380c5..58616a1 100644 --- a/Torch.Server/Managers/MultiplayerManagerDedicated.cs +++ b/Torch.Server/Managers/MultiplayerManagerDedicated.cs @@ -221,7 +221,7 @@ namespace Torch.Server.Managers if (Players.ContainsKey(steamId)) { - _log.Warn($"Player {steamId} already has already joined!"); + _log.Warn($"Player {steamId} has already joined!"); UserRejected(steamId, JoinResult.AlreadyJoined); } else if (Torch.CurrentSession.KeenSession.OnlineMode == MyOnlineModeEnum.OFFLINE && diff --git a/Torch/MySteamServiceWrapper.cs b/Torch/MySteamServiceWrapper.cs index c1ba92f..c74995a 100644 --- a/Torch/MySteamServiceWrapper.cs +++ b/Torch/MySteamServiceWrapper.cs @@ -8,7 +8,7 @@ namespace Torch /// /// Provides static accessor for MySteamService because Keen made it internal /// - public class MySteamServiceWrapper + public static class MySteamServiceWrapper { private static readonly MethodInfo _getGameService; @@ -20,5 +20,10 @@ namespace Torch var prop = type.GetProperty("Static", BindingFlags.Static | BindingFlags.Public); _getGameService = prop.GetGetMethod(); } + + public static IMyGameService Init(bool dedicated, uint appId) + { + return (IMyGameService)Activator.CreateInstance(Type.GetType("VRage.Steam.MySteamService, VRage.Steam"), dedicated, appId); + } } } \ No newline at end of file diff --git a/Torch/VRageGame.cs b/Torch/VRageGame.cs index 7d45453..a972643 100644 --- a/Torch/VRageGame.cs +++ b/Torch/VRageGame.cs @@ -137,11 +137,9 @@ namespace Torch { bool dedicated = Sandbox.Engine.Platform.Game.IsDedicated; Environment.SetEnvironmentVariable("SteamAppId", _appSteamId.ToString()); - //KEEN WHY - Activator.CreateInstance(Type.GetType("VRage.Steam.MySteamService, VRage.Steam"), new object[] {dedicated, _appSteamId}); - var service = MySteamServiceWrapper.Static; + var service = MySteamServiceWrapper.Init(dedicated, _appSteamId); MyServiceManager.Instance.AddService(service); - var serviceInstance = MySteamUgcService.Create(MyPerServerSettings.AppId, service); + var serviceInstance = MySteamUgcService.Create(_appSteamId, service); MyServiceManager.Instance.AddService(serviceInstance); if (dedicated && !MyGameService.HasGameServer) { @@ -239,7 +237,7 @@ namespace Torch if (MySandboxGame.FatalErrorDuringInit) { - throw new InvalidOperationException("Failed to start sandbox game: fatal error during init"); + throw new InvalidOperationException("Failed to start sandbox game: see Keen log for details"); } try {