From 38d2f1b62e0751f9fa96e5a9c1341355b6c72c3f Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 16 May 2018 07:09:05 -0400 Subject: [PATCH 01/16] Fix for MP --- Torch.API/Torch.API.csproj | 5 - Torch.Server/Managers/InstanceManager.cs | 12 +- .../Managers/MultiplayerManagerDedicated.cs | 5 +- Torch.Server/Torch.Server.csproj | 6 +- .../ViewModels/ConfigDedicatedViewModel.cs | 3 +- .../ViewModels/SessionSettingsViewModel.cs | 2 +- Torch.Server/ViewModels/SteamUserViewModel.cs | 4 +- Torch.Server/Views/ChatControl.xaml.cs | 1 - Torch.Server/Views/ModsControl.xaml.cs | 19 ++- Torch.Server/Views/PlayerListControl.xaml.cs | 1 - Torch/Commands/TorchCommands.cs | 8 +- Torch/Managers/MultiplayerManagerBase.cs | 1 - .../Managers/NetworkManager/NetworkManager.cs | 2 +- Torch/Managers/UpdateManager.cs | 1 - Torch/Patches/ObjectFactoryInitPatch.cs | 19 ++- Torch/SteamHelper.cs | 132 ------------------ Torch/SteamService.cs | 95 ------------- Torch/Torch.csproj | 6 +- Torch/Utils/MiscExtensions.cs | 6 +- Torch/Utils/Reflection.cs | 1 - Torch/VRageGame.cs | 7 +- Torch/ViewModels/PlayerViewModel.cs | 1 - 22 files changed, 57 insertions(+), 280 deletions(-) delete mode 100644 Torch/SteamHelper.cs delete mode 100644 Torch/SteamService.cs diff --git a/Torch.API/Torch.API.csproj b/Torch.API/Torch.API.csproj index 83783d4..c7137e0 100644 --- a/Torch.API/Torch.API.csproj +++ b/Torch.API/Torch.API.csproj @@ -74,11 +74,6 @@ ..\GameBinaries\SpaceEngineers.ObjectBuilders.XmlSerializers.dll False - - False - ..\GameBinaries\SteamSDK.dll - False - diff --git a/Torch.Server/Managers/InstanceManager.cs b/Torch.Server/Managers/InstanceManager.cs index c6b1d3b..8778182 100644 --- a/Torch.Server/Managers/InstanceManager.cs +++ b/Torch.Server/Managers/InstanceManager.cs @@ -106,7 +106,8 @@ namespace Torch.Server.Managers foreach (var mod in world.Checkpoint.Mods) sb.AppendLine(mod.PublishedFileId.ToString()); - DedicatedConfig.Mods = world.Checkpoint.Mods.Select(x => x.PublishedFileId).ToList(); + //TODO + //DedicatedConfig.Mods = world.Checkpoint.Mods.Select(x => x.PublishedFileId).ToList(); Log.Debug("Loaded mod list from world"); @@ -133,7 +134,8 @@ namespace Torch.Server.Managers return; } - DedicatedConfig.Mods = checkpoint.Mods.Select(x => x.PublishedFileId).ToList(); + //TODO + //DedicatedConfig.Mods = checkpoint.Mods.Select(x => x.PublishedFileId).ToList(); Log.Debug("Loaded mod list from world"); @@ -165,8 +167,10 @@ namespace Torch.Server.Managers checkpoint.SessionName = DedicatedConfig.WorldName; checkpoint.Settings = DedicatedConfig.SessionSettings; checkpoint.Mods.Clear(); - foreach (var modId in DedicatedConfig.Model.Mods) - checkpoint.Mods.Add(new MyObjectBuilder_Checkpoint.ModItem(modId)); + + //TODO: FIXIT + //foreach (var modId in DedicatedConfig.Model.SessionSettings..Mods) + // checkpoint.Mods.Add(new MyObjectBuilder_Checkpoint.ModItem(modId)); MyObjectBuilderSerializer.SerializeXML(sandboxPath, false, checkpoint); diff --git a/Torch.Server/Managers/MultiplayerManagerDedicated.cs b/Torch.Server/Managers/MultiplayerManagerDedicated.cs index 6420e85..8a3eb59 100644 --- a/Torch.Server/Managers/MultiplayerManagerDedicated.cs +++ b/Torch.Server/Managers/MultiplayerManagerDedicated.cs @@ -11,7 +11,7 @@ using Sandbox; using Sandbox.Engine.Multiplayer; using Sandbox.Engine.Networking; using Sandbox.Game.World; -using SteamSDK; +using Steamworks; using Torch.API; using Torch.API.Managers; using Torch.Managers; @@ -150,8 +150,7 @@ namespace Torch.Server.Managers //Largely copied from SE private void ValidateAuthTicketResponse(ulong steamId, JoinResult response, ulong steamOwner) { - var state = new P2PSessionState(); - Peer2Peer.GetSessionState(steamId, ref state); + SteamNetworking.GetP2PSessionState(new CSteamID(steamId), out P2PSessionState_t state); var ip = state.GetRemoteIP(); _log.Debug($"ValidateAuthTicketResponse(user={steamId}, response={response}, owner={steamOwner})"); diff --git a/Torch.Server/Torch.Server.csproj b/Torch.Server/Torch.Server.csproj index 02fd9a0..032393b 100644 --- a/Torch.Server/Torch.Server.csproj +++ b/Torch.Server/Torch.Server.csproj @@ -117,10 +117,8 @@ ..\GameBinaries\SpaceEngineers.ObjectBuilders.XmlSerializers.dll False - - False - ..\GameBinaries\SteamSDK.dll - False + + C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\DedicatedServer64\Steamworks.NET.dll diff --git a/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs b/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs index 7838e5e..439683d 100644 --- a/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs +++ b/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs @@ -77,7 +77,8 @@ namespace Torch.Server.ViewModels public List Banned { get => _config.Banned; set => SetValue(x => _config.Banned = x, value); } - public List Mods { get => _config.Mods; set => SetValue(x => _config.Mods = x, value); } + //TODO: FIX + //public List Mods { get => _config.Mods; set => SetValue(x => _config.Mods = x, value); } public int AsteroidAmount { get => _config.AsteroidAmount; set => SetValue(x => _config.AsteroidAmount = x, value); } diff --git a/Torch.Server/ViewModels/SessionSettingsViewModel.cs b/Torch.Server/ViewModels/SessionSettingsViewModel.cs index b0337fb..39f6dff 100644 --- a/Torch.Server/ViewModels/SessionSettingsViewModel.cs +++ b/Torch.Server/ViewModels/SessionSettingsViewModel.cs @@ -59,7 +59,7 @@ namespace Torch.Server.ViewModels /// [Display(Name = "Enable block limits")] - public System.Boolean EnableBlockLimits { get => _settings.EnableBlockLimits; set => SetValue(ref _settings.EnableBlockLimits, value); } + public MyBlockLimitsEnabledEnum EnableBlockLimits { get => _settings.BlockLimitsEnabled; set => SetValue(ref _settings.BlockLimitsEnabled, value); } /// [Display(Name = "Enable remote removal of owned blocks")] diff --git a/Torch.Server/ViewModels/SteamUserViewModel.cs b/Torch.Server/ViewModels/SteamUserViewModel.cs index 87d4987..56bbd9f 100644 --- a/Torch.Server/ViewModels/SteamUserViewModel.cs +++ b/Torch.Server/ViewModels/SteamUserViewModel.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using SteamSDK; +using Steamworks; namespace Torch.Server.ViewModels { @@ -15,7 +15,7 @@ namespace Torch.Server.ViewModels public SteamUserViewModel(ulong id) { SteamId = id; - Name = SteamAPI.Instance.Friends.GetPersonaName(id); + Name = SteamFriends.GetFriendPersonaName(new CSteamID(id)); } public SteamUserViewModel() : this(0) { } diff --git a/Torch.Server/Views/ChatControl.xaml.cs b/Torch.Server/Views/ChatControl.xaml.cs index 5cce943..3aa3d17 100644 --- a/Torch.Server/Views/ChatControl.xaml.cs +++ b/Torch.Server/Views/ChatControl.xaml.cs @@ -19,7 +19,6 @@ using Torch; using Sandbox; using Sandbox.Engine.Multiplayer; using Sandbox.Game.World; -using SteamSDK; using Torch.API; using Torch.API.Managers; using Torch.API.Session; diff --git a/Torch.Server/Views/ModsControl.xaml.cs b/Torch.Server/Views/ModsControl.xaml.cs index e9d4641..3fc7ec2 100644 --- a/Torch.Server/Views/ModsControl.xaml.cs +++ b/Torch.Server/Views/ModsControl.xaml.cs @@ -15,7 +15,6 @@ using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Sandbox.Engine.Networking; -using SteamSDK; using VRage.Game; namespace Torch.Server @@ -45,16 +44,16 @@ namespace Torch.Server mods = dialog.Result; } - foreach (var id in mods) - { - var details = SteamHelper.GetItemDetails(id); - if (details.FileType != WorkshopFileType.Community) - continue; + //foreach (var id in mods) + //{ + // var details = SteamHelper.GetItemDetails(id); + // if (details.FileType != WorkshopFileType.Community) + // continue; - var item = SteamHelper.GetModItem(details); - var desc = details.Description.Length < 500 ? details.Description : details.Description.Substring(0, 500); - ModList.Items.Add(new ModViewModel(item, desc)); - } + // var item = SteamHelper.GetModItem(details); + // var desc = details.Description.Length < 500 ? details.Description : details.Description.Substring(0, 500); + // ModList.Items.Add(new ModViewModel(item, desc)); + //} } private void modList_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) diff --git a/Torch.Server/Views/PlayerListControl.xaml.cs b/Torch.Server/Views/PlayerListControl.xaml.cs index d7c2179..bc26eb6 100644 --- a/Torch.Server/Views/PlayerListControl.xaml.cs +++ b/Torch.Server/Views/PlayerListControl.xaml.cs @@ -19,7 +19,6 @@ using Sandbox.Engine.Multiplayer; using Sandbox.Game.Multiplayer; using Sandbox.Game.World; using Sandbox.ModAPI; -using SteamSDK; using Torch.API; using Torch.API.Managers; using Torch.API.Session; diff --git a/Torch/Commands/TorchCommands.cs b/Torch/Commands/TorchCommands.cs index e3affc8..4085ed5 100644 --- a/Torch/Commands/TorchCommands.cs +++ b/Torch/Commands/TorchCommands.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using System.Timers; using Sandbox.Game.Multiplayer; using Sandbox.ModAPI; -using SteamSDK; +using Steamworks; using Torch; using Torch.API; using Torch.API.Managers; @@ -30,11 +30,11 @@ namespace Torch.Commands [Permission(MyPromoteLevel.None)] public void GetIP(ulong steamId = 0) { - var state = new P2PSessionState(); if (steamId == 0) steamId = Context.Player.SteamUserId; - Peer2Peer.GetSessionState(steamId, ref state); - var ip = new IPAddress(BitConverter.GetBytes(state.RemoteIP).Reverse().ToArray()); + + SteamNetworking.GetP2PSessionState(new CSteamID(steamId), out P2PSessionState_t state); + var ip = new IPAddress(BitConverter.GetBytes(state.m_nRemoteIP).Reverse().ToArray()); Context.Respond($"Your IP is {ip}"); } diff --git a/Torch/Managers/MultiplayerManagerBase.cs b/Torch/Managers/MultiplayerManagerBase.cs index 82c131c..c8c68b8 100644 --- a/Torch/Managers/MultiplayerManagerBase.cs +++ b/Torch/Managers/MultiplayerManagerBase.cs @@ -21,7 +21,6 @@ using Sandbox.Game.Entities.Character; using Sandbox.Game.Multiplayer; using Sandbox.Game.World; using Sandbox.ModAPI; -using SteamSDK; using Torch.API; using Torch.API.Managers; using Torch.Collections; diff --git a/Torch/Managers/NetworkManager/NetworkManager.cs b/Torch/Managers/NetworkManager/NetworkManager.cs index 95a3032..a1873f5 100644 --- a/Torch/Managers/NetworkManager/NetworkManager.cs +++ b/Torch/Managers/NetworkManager/NetworkManager.cs @@ -133,7 +133,7 @@ namespace Torch.Managers } var stream = new BitStream(); - stream.ResetRead(packet); + stream.ResetRead(packet.BitStream); var networkId = stream.ReadNetworkId(); //this value is unused, but removing this line corrupts the rest of the stream diff --git a/Torch/Managers/UpdateManager.cs b/Torch/Managers/UpdateManager.cs index 4a76c13..bdaaf32 100644 --- a/Torch/Managers/UpdateManager.cs +++ b/Torch/Managers/UpdateManager.cs @@ -11,7 +11,6 @@ using System.Threading; using System.Threading.Tasks; using NLog; using Octokit; -using SteamSDK; using Torch.API; namespace Torch.Managers diff --git a/Torch/Patches/ObjectFactoryInitPatch.cs b/Torch/Patches/ObjectFactoryInitPatch.cs index 51fc46e..c680edd 100644 --- a/Torch/Patches/ObjectFactoryInitPatch.cs +++ b/Torch/Patches/ObjectFactoryInitPatch.cs @@ -31,6 +31,7 @@ namespace Torch.Patches internal static void ForceRegisterAssemblies() { + var userAssemblies = MyPlugins.UserAssemblies; // static MyEntities() called by MySandboxGame.ForceStaticCtor RuntimeHelpers.RunClassConstructor(typeof(MyEntities).TypeHandle); { @@ -38,7 +39,14 @@ namespace Torch.Patches ObjectFactory_RegisterFromAssemblySafe(factory, typeof(MySandboxGame).Assembly); // calling assembly ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.GameAssembly); ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.SandboxAssembly); - ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.UserAssembly); + //ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.UserAssembly); + if (userAssemblies != null) + { + foreach (var assembly in userAssemblies) + { + ObjectFactory_RegisterFromAssemblySafe(factory, assembly); + } + } } // static MyGuiManager(): @@ -51,7 +59,14 @@ namespace Torch.Patches ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.SandboxAssembly); ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.GameAssembly); ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.SandboxGameAssembly); - ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.UserAssembly); + //ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.UserAssembly); + if (userAssemblies != null) + { + foreach (var assembly in userAssemblies) + { + ComponentTypeFactory_RegisterFromAssemblySafe(assembly); + } + } } // static MyObjectPoolManager() diff --git a/Torch/SteamHelper.cs b/Torch/SteamHelper.cs deleted file mode 100644 index d9e92c3..0000000 --- a/Torch/SteamHelper.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Win32; -using NLog; -using Sandbox; -using Sandbox.Engine.Networking; -using Sandbox.Engine.Platform; -using SteamSDK; -using Torch.API; -using VRage.Game; - -namespace Torch -{ - public static class SteamHelper - { - private static CancellationTokenSource _tokenSource = new CancellationTokenSource(); - private static CancellationToken _cancelToken; - private static Logger _log = LogManager.GetCurrentClassLogger(); - public static string BasePath { get; private set; } - private static string _libraryFolders; - - public static void Init() - { - BasePath = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Valve\Steam", "SteamPath", null) as string; - _libraryFolders = File.ReadAllText(Path.Combine(BasePath, @"steamapps\libraryfolders.vdf")); - _cancelToken = _tokenSource.Token; - - Task.Run(() => - { - while (!_cancelToken.IsCancellationRequested) - { - SteamAPI.Instance.RunCallbacks(); - Thread.Sleep(100); - } - }); - } - - public static void StopCallbackLoop() - { - _tokenSource.Cancel(); - } - - public static MySteamWorkshop.SubscribedItem GetItemInfo(ulong itemId) - { - MySteamWorkshop.SubscribedItem item = null; - - using (var mre = new ManualResetEvent(false)) - { - SteamAPI.Instance.RemoteStorage.GetPublishedFileDetails(itemId, 0, (ioFail, result) => - { - if (!ioFail && result.Result == Result.OK) - { - item = new MySteamWorkshop.SubscribedItem - { - Title = result.Title, - Description = result.Description, - PublishedFileId = result.PublishedFileId, - SteamIDOwner = result.SteamIDOwner, - Tags = result.Tags.Split(' '), - TimeUpdated = result.TimeUpdated, - UGCHandle = result.FileHandle - }; - } - else - { - _log.Error($"Failed to get item info for {itemId}"); - } - - mre.Set(); - }); - - mre.WaitOne(); - mre.Reset(); - - return item; - } - } - - public static SteamUGCDetails GetItemDetails(ulong itemId) - { - SteamUGCDetails details = default(SteamUGCDetails); - using (var re = new AutoResetEvent(false)) - { - SteamAPI.Instance.UGC.RequestUGCDetails(itemId, 0, (b, result) => - { - if (!b && result.Details.Result == Result.OK) - details = result.Details; - else - _log.Error($"Failed to get item details for {itemId}"); - - re.Set(); - }); - - re.WaitOne(); - } - - return details; - } - - public static MyObjectBuilder_Checkpoint.ModItem GetModItem(ulong modId) - { - var details = GetItemDetails(modId); - return new MyObjectBuilder_Checkpoint.ModItem(null, modId, details.Title); - } - - public static MyObjectBuilder_Checkpoint.ModItem GetModItem(SteamUGCDetails details) - { - return new MyObjectBuilder_Checkpoint.ModItem(null, details.PublishedFileId, details.Title); - } - - public static string GetInstallFolder(string subfolderName) - { - var basePaths = new List(); - var matches = Regex.Matches(_libraryFolders, @"""\d+""[ \t]+""([^""]+)""", RegexOptions.Singleline); - foreach (Match match in matches) - { - basePaths.Add(match.Groups[1].Value); - } - - var path = basePaths.Select(p => Path.Combine(p, "SteamApps", "common", subfolderName)).FirstOrDefault(Directory.Exists); - if (path != null && !path.EndsWith("\\")) - path += "\\"; - return path; - } - } -} diff --git a/Torch/SteamService.cs b/Torch/SteamService.cs deleted file mode 100644 index 552bc4f..0000000 --- a/Torch/SteamService.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NLog; -using SteamSDK; -using VRage.Steam; -using Sandbox; -using Sandbox.Engine.Networking; -using Torch.Utils; -using VRage.GameServices; - -namespace Torch -{ - /// - /// SNAGGED FROM PHOENIX84'S SE WORKSHOP TOOL - /// Keen's steam service calls RestartIfNecessary, which triggers steam to think the game was launched - /// outside of Steam, which causes this process to exit, and the game to launch instead with an arguments warning. - /// We have to override the default behavior, then forcibly set the correct options. - /// - public class SteamService : MySteamService - { - private static readonly Logger _log = LogManager.GetCurrentClassLogger(); - -#pragma warning disable 649 - [ReflectedSetter(Name = nameof(SteamServerAPI))] - private static Action _steamServerAPISetter; - [ReflectedSetter(Name = "m_gameServer")] - private static Action _steamGameServerSetter; - [ReflectedSetter(Name = nameof(AppId))] - private static Action _steamAppIdSetter; - [ReflectedSetter(Name = nameof(API))] - private static Action _steamApiSetter; - [ReflectedSetter(Name = nameof(IsActive))] - private static Action _steamIsActiveSetter; - [ReflectedSetter(Name = nameof(UserId))] - private static Action _steamUserIdSetter; - [ReflectedSetter(Name = nameof(UserName))] - private static Action _steamUserNameSetter; - [ReflectedSetter(Name = nameof(OwnsGame))] - private static Action _steamOwnsGameSetter; - [ReflectedSetter(Name = nameof(UserUniverse))] - private static Action _steamUserUniverseSetter; - [ReflectedSetter(Name = nameof(BranchName))] - private static Action _steamBranchNameSetter; - [ReflectedSetter(Name = nameof(InventoryAPI))] - private static Action _steamInventoryAPISetter; - [ReflectedMethod] - private static Action RegisterCallbacks; - [ReflectedSetter(Name = nameof(Peer2Peer))] - private static Action _steamPeer2PeerSetter; -#pragma warning restore 649 - - public SteamService(bool isDedicated, uint appId) - : base(true, appId) - { - SteamServerAPI.Instance.Dispose(); - _steamServerAPISetter.Invoke(this, null); - _steamGameServerSetter.Invoke(this, null); - _steamAppIdSetter.Invoke(this, appId); - - if (isDedicated) - { - _steamServerAPISetter.Invoke(this, null); - _steamGameServerSetter.Invoke(this, new MySteamGameServer()); - } - else - { - SteamAPI steamApi = SteamAPI.Instance; - _steamApiSetter.Invoke(this, steamApi); - bool initResult = steamApi.Init(); - if (!initResult) - _log.Warn("Failed to initialize SteamService"); - _steamIsActiveSetter.Invoke(this, initResult); - - if (IsActive) - { - _steamUserIdSetter.Invoke(this, steamApi.GetSteamUserId()); - _steamUserNameSetter.Invoke(this, steamApi.GetSteamName()); - _steamOwnsGameSetter.Invoke(this, steamApi.HasGame()); - _steamUserUniverseSetter.Invoke(this, (MyGameServiceUniverse)steamApi.GetSteamUserUniverse()); - _steamBranchNameSetter.Invoke(this, steamApi.GetBranchName()); - steamApi.LoadStats(); - - _steamInventoryAPISetter.Invoke(this, new MySteamInventory()); - RegisterCallbacks(this); - } else - _log.Warn("SteamService isn't initialized; Torch Client won't start"); - } - - _steamPeer2PeerSetter.Invoke(this, new MySteamPeer2Peer()); - } - } -} diff --git a/Torch/Torch.csproj b/Torch/Torch.csproj index e9791ac..a6f394b 100644 --- a/Torch/Torch.csproj +++ b/Torch/Torch.csproj @@ -84,9 +84,8 @@ ..\GameBinaries\SpaceEngineers.ObjectBuilders.XmlSerializers.dll False - - ..\GameBinaries\SteamSDK.dll - False + + C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\DedicatedServer64\Steamworks.NET.dll @@ -259,7 +258,6 @@ - diff --git a/Torch/Utils/MiscExtensions.cs b/Torch/Utils/MiscExtensions.cs index 6f97755..272b20d 100644 --- a/Torch/Utils/MiscExtensions.cs +++ b/Torch/Utils/MiscExtensions.cs @@ -6,7 +6,7 @@ using System.Net; using System.Text; using System.Threading; using System.Threading.Tasks; -using SteamSDK; +using Steamworks; namespace Torch.Utils { @@ -52,10 +52,10 @@ namespace Torch.Utils return result; } - public static IPAddress GetRemoteIP(this P2PSessionState state) + public static IPAddress GetRemoteIP(this P2PSessionState_t state) { // What is endianness anyway? - return new IPAddress(BitConverter.GetBytes(state.RemoteIP).Reverse().ToArray()); + return new IPAddress(BitConverter.GetBytes(state.m_nRemoteIP).Reverse().ToArray()); } } } diff --git a/Torch/Utils/Reflection.cs b/Torch/Utils/Reflection.cs index 5234a29..fbbbb46 100644 --- a/Torch/Utils/Reflection.cs +++ b/Torch/Utils/Reflection.cs @@ -5,7 +5,6 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; using NLog; -using SteamSDK; namespace Torch.Utils { diff --git a/Torch/VRageGame.cs b/Torch/VRageGame.cs index 49dc49d..eafe74a 100644 --- a/Torch/VRageGame.cs +++ b/Torch/VRageGame.cs @@ -35,6 +35,7 @@ using VRage.Plugins; using VRage.Steam; using VRage.Utils; using VRageRender; +using MyRenderProfiler = VRage.Profiler.MyRenderProfiler; namespace Torch { @@ -198,8 +199,8 @@ namespace Torch MySandboxGame.Config.GraphicsRenderer = graphicsRenderer; } MyRenderProxy.Initialize(renderer); - MyRenderProxy.GetRenderProfiler().SetAutocommit(false); - MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint"); + MyRenderProfiler.SetAutocommit(false); + MyRenderProfiler.InitMemoryHack("MainEntryPoint"); } // Loads object builder serializers. Intuitive, right? @@ -276,7 +277,7 @@ namespace Torch MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSize); if (MySession.IsCompatibleVersion(checkpoint)) { - if (MySteamWorkshop.DownloadWorldModsBlocking(checkpoint.Mods).Success) + if (MyWorkshop.DownloadWorldModsBlocking(checkpoint.Mods).Success) { // MySpaceAnalytics.Instance.SetEntry(MyGameEntryEnum.Load); MySession.Load(sessionPath, checkpoint, checkpointSize); diff --git a/Torch/ViewModels/PlayerViewModel.cs b/Torch/ViewModels/PlayerViewModel.cs index c05a64c..857bb41 100644 --- a/Torch/ViewModels/PlayerViewModel.cs +++ b/Torch/ViewModels/PlayerViewModel.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Sandbox.Engine.Multiplayer; -using SteamSDK; using Torch.API; using VRage.Replication; From 4c34a653bdfd6dd050f29de8bb381480721a507f Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 16 May 2018 07:14:10 -0400 Subject: [PATCH 02/16] Let Jenkins download the new branch so the build doesn't blow up --- Jenkins/jenkins-grab-se.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkins/jenkins-grab-se.ps1 b/Jenkins/jenkins-grab-se.ps1 index 7670e02..46daf72 100644 --- a/Jenkins/jenkins-grab-se.ps1 +++ b/Jenkins/jenkins-grab-se.ps1 @@ -17,6 +17,6 @@ if (!(Test-Path $steamCMDPath)) { } cd "$steamData" -& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740" "+quit" +& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 -branch mptest -branchpassword nt7WuDw9kdvB" "+quit" popd \ No newline at end of file From ebc8b7a7fd8a812ef3131caf47273a025a559d2b Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 16 May 2018 07:16:33 -0400 Subject: [PATCH 03/16] SteamCMD is trash --- Jenkins/jenkins-grab-se.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkins/jenkins-grab-se.ps1 b/Jenkins/jenkins-grab-se.ps1 index 46daf72..4720a08 100644 --- a/Jenkins/jenkins-grab-se.ps1 +++ b/Jenkins/jenkins-grab-se.ps1 @@ -17,6 +17,6 @@ if (!(Test-Path $steamCMDPath)) { } cd "$steamData" -& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 -branch mptest -branchpassword nt7WuDw9kdvB" "+quit" +& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 -beta mptest -betapassword nt7WuDw9kdvB" "+quit" popd \ No newline at end of file From 06eca83ff9b4d46b28f51ff4b435d3e25df6c235 Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 16 May 2018 07:18:16 -0400 Subject: [PATCH 04/16] STEAM PLEASE --- Jenkins/jenkins-grab-se.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkins/jenkins-grab-se.ps1 b/Jenkins/jenkins-grab-se.ps1 index 4720a08..74a49c3 100644 --- a/Jenkins/jenkins-grab-se.ps1 +++ b/Jenkins/jenkins-grab-se.ps1 @@ -17,6 +17,6 @@ if (!(Test-Path $steamCMDPath)) { } cd "$steamData" -& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 -beta mptest -betapassword nt7WuDw9kdvB" "+quit" +& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 +beta mptest +betapassword nt7WuDw9kdvB" "+quit" popd \ No newline at end of file From 63f504feb78892038ac6ee4b134e34f93d2ad786 Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 16 May 2018 07:24:33 -0400 Subject: [PATCH 05/16] I don't even know anymore --- Jenkins/jenkins-grab-se.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkins/jenkins-grab-se.ps1 b/Jenkins/jenkins-grab-se.ps1 index 74a49c3..ae3e88d 100644 --- a/Jenkins/jenkins-grab-se.ps1 +++ b/Jenkins/jenkins-grab-se.ps1 @@ -1,6 +1,6 @@ pushd -$steamData = "C:/Steam/Data/" +$steamData = "C:/Steam/DataMP/" $steamCMDPath = "C:/Steam/steamcmd/" $steamCMDZip = "C:/Steam/steamcmd.zip" @@ -17,6 +17,6 @@ if (!(Test-Path $steamCMDPath)) { } cd "$steamData" -& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 +beta mptest +betapassword nt7WuDw9kdvB" "+quit" +& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 -beta mptest -betapassword nt7WuDw9kdvB" "+quit" popd \ No newline at end of file From b89b61496b4316a02099c5206a9a940be248d6c9 Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 16 May 2018 07:29:22 -0400 Subject: [PATCH 06/16] TRY THINGS UNTIL IT WORKS --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 88aadf7..79784cc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,7 +25,7 @@ node { stage('Acquire SE') { bat 'powershell -File Jenkins/jenkins-grab-se.ps1' bat 'IF EXIST GameBinaries RMDIR GameBinaries' - bat 'mklink /J GameBinaries "C:/Steam/Data/DedicatedServer64/"' + bat 'mklink /J GameBinaries "C:/Steam/DataMP/DedicatedServer64/"' } stage('Acquire NuGet Packages') { From ec4572c39043dc4523334594bf99523c396df00d Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 16 May 2018 07:49:58 -0400 Subject: [PATCH 07/16] VS WHY --- Torch/Torch.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Torch/Torch.csproj b/Torch/Torch.csproj index a6f394b..f484a55 100644 --- a/Torch/Torch.csproj +++ b/Torch/Torch.csproj @@ -252,7 +252,6 @@ - From f68be8e4c917a9f3d9f5e51f4c86cbb3ae30f791 Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 16 May 2018 07:55:51 -0400 Subject: [PATCH 08/16] last try --- Torch.Server/Torch.Server.csproj | 2 +- Torch/Torch.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Torch.Server/Torch.Server.csproj b/Torch.Server/Torch.Server.csproj index 032393b..04e32f5 100644 --- a/Torch.Server/Torch.Server.csproj +++ b/Torch.Server/Torch.Server.csproj @@ -118,7 +118,7 @@ False - C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\DedicatedServer64\Steamworks.NET.dll + ..\GameBinaries\Steamworks.NET.dll diff --git a/Torch/Torch.csproj b/Torch/Torch.csproj index f484a55..6af5960 100644 --- a/Torch/Torch.csproj +++ b/Torch/Torch.csproj @@ -85,7 +85,7 @@ False - C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\DedicatedServer64\Steamworks.NET.dll + ..\GameBinaries\Steamworks.NET.dll From f53c9660feb1c5a47d3310632eae23c4f9e55b39 Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 18 Jul 2018 19:35:18 -0400 Subject: [PATCH 09/16] Revert "TRY THINGS UNTIL IT WORKS" This reverts commit b89b61496b4316a02099c5206a9a940be248d6c9. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 79784cc..88aadf7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,7 +25,7 @@ node { stage('Acquire SE') { bat 'powershell -File Jenkins/jenkins-grab-se.ps1' bat 'IF EXIST GameBinaries RMDIR GameBinaries' - bat 'mklink /J GameBinaries "C:/Steam/DataMP/DedicatedServer64/"' + bat 'mklink /J GameBinaries "C:/Steam/Data/DedicatedServer64/"' } stage('Acquire NuGet Packages') { From 45d931b351acb2f1cd8b1ea7b8de0ea50d4c55f5 Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 18 Jul 2018 19:35:20 -0400 Subject: [PATCH 10/16] Revert "I don't even know anymore" This reverts commit 63f504feb78892038ac6ee4b134e34f93d2ad786. --- Jenkins/jenkins-grab-se.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkins/jenkins-grab-se.ps1 b/Jenkins/jenkins-grab-se.ps1 index ae3e88d..74a49c3 100644 --- a/Jenkins/jenkins-grab-se.ps1 +++ b/Jenkins/jenkins-grab-se.ps1 @@ -1,6 +1,6 @@ pushd -$steamData = "C:/Steam/DataMP/" +$steamData = "C:/Steam/Data/" $steamCMDPath = "C:/Steam/steamcmd/" $steamCMDZip = "C:/Steam/steamcmd.zip" @@ -17,6 +17,6 @@ if (!(Test-Path $steamCMDPath)) { } cd "$steamData" -& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 -beta mptest -betapassword nt7WuDw9kdvB" "+quit" +& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 +beta mptest +betapassword nt7WuDw9kdvB" "+quit" popd \ No newline at end of file From aae4ec97a930c8f875255e511c5afe1ffd4fe8f6 Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 18 Jul 2018 19:35:22 -0400 Subject: [PATCH 11/16] Revert "STEAM PLEASE" This reverts commit 06eca83ff9b4d46b28f51ff4b435d3e25df6c235. --- Jenkins/jenkins-grab-se.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkins/jenkins-grab-se.ps1 b/Jenkins/jenkins-grab-se.ps1 index 74a49c3..4720a08 100644 --- a/Jenkins/jenkins-grab-se.ps1 +++ b/Jenkins/jenkins-grab-se.ps1 @@ -17,6 +17,6 @@ if (!(Test-Path $steamCMDPath)) { } cd "$steamData" -& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 +beta mptest +betapassword nt7WuDw9kdvB" "+quit" +& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 -beta mptest -betapassword nt7WuDw9kdvB" "+quit" popd \ No newline at end of file From b4ac097910a089da337774556964a85879a2c7da Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 18 Jul 2018 19:35:23 -0400 Subject: [PATCH 12/16] Revert "SteamCMD is trash" This reverts commit ebc8b7a7fd8a812ef3131caf47273a025a559d2b. --- Jenkins/jenkins-grab-se.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkins/jenkins-grab-se.ps1 b/Jenkins/jenkins-grab-se.ps1 index 4720a08..46daf72 100644 --- a/Jenkins/jenkins-grab-se.ps1 +++ b/Jenkins/jenkins-grab-se.ps1 @@ -17,6 +17,6 @@ if (!(Test-Path $steamCMDPath)) { } cd "$steamData" -& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 -beta mptest -betapassword nt7WuDw9kdvB" "+quit" +& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 -branch mptest -branchpassword nt7WuDw9kdvB" "+quit" popd \ No newline at end of file From b12199c65b1ebc786307e2e2598176c7dc054c53 Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 18 Jul 2018 19:38:04 -0400 Subject: [PATCH 13/16] Revert "Let Jenkins download the new branch so the build doesn't blow up" This reverts commit 4c34a653bdfd6dd050f29de8bb381480721a507f. --- Jenkins/jenkins-grab-se.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkins/jenkins-grab-se.ps1 b/Jenkins/jenkins-grab-se.ps1 index 46daf72..7670e02 100644 --- a/Jenkins/jenkins-grab-se.ps1 +++ b/Jenkins/jenkins-grab-se.ps1 @@ -17,6 +17,6 @@ if (!(Test-Path $steamCMDPath)) { } cd "$steamData" -& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740 -branch mptest -branchpassword nt7WuDw9kdvB" "+quit" +& "$steamCMDPath/steamcmd.exe" "+login anonymous" "+force_install_dir $steamData" "+app_update 298740" "+quit" popd \ No newline at end of file From ec065ec3295c7b9daf09c0ad0ea27f51c60be95e Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 18 Jul 2018 22:34:44 -0400 Subject: [PATCH 14/16] Fix network intercept --- Torch.Server/Managers/InstanceManager.cs | 14 ++++++-------- Torch/Managers/NetworkManager/NetworkManager.cs | 5 ++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Torch.Server/Managers/InstanceManager.cs b/Torch.Server/Managers/InstanceManager.cs index 8778182..82ecd95 100644 --- a/Torch.Server/Managers/InstanceManager.cs +++ b/Torch.Server/Managers/InstanceManager.cs @@ -105,9 +105,9 @@ namespace Torch.Server.Managers var sb = new StringBuilder(); foreach (var mod in world.Checkpoint.Mods) sb.AppendLine(mod.PublishedFileId.ToString()); + + DedicatedConfig.Mods = world.Checkpoint.Mods.Select(x => x.PublishedFileId).ToList(); - //TODO - //DedicatedConfig.Mods = world.Checkpoint.Mods.Select(x => x.PublishedFileId).ToList(); Log.Debug("Loaded mod list from world"); @@ -134,8 +134,7 @@ namespace Torch.Server.Managers return; } - //TODO - //DedicatedConfig.Mods = checkpoint.Mods.Select(x => x.PublishedFileId).ToList(); + DedicatedConfig.Mods = checkpoint.Mods.Select(x => x.PublishedFileId).ToList(); Log.Debug("Loaded mod list from world"); @@ -167,10 +166,9 @@ namespace Torch.Server.Managers checkpoint.SessionName = DedicatedConfig.WorldName; checkpoint.Settings = DedicatedConfig.SessionSettings; checkpoint.Mods.Clear(); - - //TODO: FIXIT - //foreach (var modId in DedicatedConfig.Model.SessionSettings..Mods) - // checkpoint.Mods.Add(new MyObjectBuilder_Checkpoint.ModItem(modId)); + + foreach (var modId in DedicatedConfig.Mods) + checkpoint.Mods.Add(new MyObjectBuilder_Checkpoint.ModItem(modId)); MyObjectBuilderSerializer.SerializeXML(sandboxPath, false, checkpoint); diff --git a/Torch/Managers/NetworkManager/NetworkManager.cs b/Torch/Managers/NetworkManager/NetworkManager.cs index a1873f5..139deaa 100644 --- a/Torch/Managers/NetworkManager/NetworkManager.cs +++ b/Torch/Managers/NetworkManager/NetworkManager.cs @@ -29,6 +29,8 @@ namespace Torch.Managers private static Func _typeTableGetter; [ReflectedGetter(Name = "m_methodInfoLookup")] private static Func> _methodInfoLookupGetter; + [ReflectedMethod(Type = typeof(MyReplicationLayer), Name = "GetObjectByNetworkId")] + private static Func _getObjectByNetworkId; public NetworkManager(ITorchBase torchInstance) : base(torchInstance) { @@ -150,7 +152,8 @@ namespace Torch.Managers } else // Instance event { - var sendAs = ((MyReplicationLayer)MyMultiplayer.ReplicationLayer).GetObjectByNetworkId(networkId); + //var sendAs = ((MyReplicationLayer)MyMultiplayer.ReplicationLayer).GetObjectByNetworkId(networkId); + var sendAs = _getObjectByNetworkId((MyReplicationLayer)MyMultiplayer.ReplicationLayer, networkId); if (sendAs == null) { return; From 0f06ee568857a2aa8ae01aba4b17437652e552d1 Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 18 Jul 2018 22:34:59 -0400 Subject: [PATCH 15/16] Disable client IP stuff because it borked --- Torch.Server/Managers/MultiplayerManagerDedicated.cs | 4 ++-- Torch/Commands/TorchCommands.cs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Torch.Server/Managers/MultiplayerManagerDedicated.cs b/Torch.Server/Managers/MultiplayerManagerDedicated.cs index 8a3eb59..60e1b67 100644 --- a/Torch.Server/Managers/MultiplayerManagerDedicated.cs +++ b/Torch.Server/Managers/MultiplayerManagerDedicated.cs @@ -150,8 +150,8 @@ namespace Torch.Server.Managers //Largely copied from SE private void ValidateAuthTicketResponse(ulong steamId, JoinResult response, ulong steamOwner) { - SteamNetworking.GetP2PSessionState(new CSteamID(steamId), out P2PSessionState_t state); - var ip = state.GetRemoteIP(); + //SteamNetworking.GetP2PSessionState(new CSteamID(steamId), out P2PSessionState_t state); + var ip = "0"; //state.GetRemoteIP(); _log.Debug($"ValidateAuthTicketResponse(user={steamId}, response={response}, owner={steamOwner})"); diff --git a/Torch/Commands/TorchCommands.cs b/Torch/Commands/TorchCommands.cs index 4085ed5..8fb1681 100644 --- a/Torch/Commands/TorchCommands.cs +++ b/Torch/Commands/TorchCommands.cs @@ -30,6 +30,9 @@ namespace Torch.Commands [Permission(MyPromoteLevel.None)] public void GetIP(ulong steamId = 0) { + Context.Respond("Cannot obtain client IP."); + return; + if (steamId == 0) steamId = Context.Player.SteamUserId; From 2b413ef6097721ca86308f43bebd5c6479402032 Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 18 Jul 2018 22:35:11 -0400 Subject: [PATCH 16/16] Fix mod settings --- Torch.Server/ViewModels/ConfigDedicatedViewModel.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs b/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs index 439683d..e0014f1 100644 --- a/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs +++ b/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs @@ -76,9 +76,9 @@ namespace Torch.Server.ViewModels public List Administrators { get => _config.Administrators; set => SetValue(x => _config.Administrators = x, value); } public List Banned { get => _config.Banned; set => SetValue(x => _config.Banned = x, value); } - - //TODO: FIX - //public List Mods { get => _config.Mods; set => SetValue(x => _config.Mods = x, value); } + + private List _mods = new List(); + public List Mods { get => _mods; set => SetValue(x => _mods = x, value); } public int AsteroidAmount { get => _config.AsteroidAmount; set => SetValue(x => _config.AsteroidAmount = x, value); }