@@ -74,11 +74,6 @@
|
|||||||
<HintPath>..\GameBinaries\SpaceEngineers.ObjectBuilders.XmlSerializers.dll</HintPath>
|
<HintPath>..\GameBinaries\SpaceEngineers.ObjectBuilders.XmlSerializers.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="SteamSDK, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
|
||||||
<SpecificVersion>False</SpecificVersion>
|
|
||||||
<HintPath>..\GameBinaries\SteamSDK.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
@@ -105,9 +105,10 @@ namespace Torch.Server.Managers
|
|||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
foreach (var mod in world.Checkpoint.Mods)
|
foreach (var mod in world.Checkpoint.Mods)
|
||||||
sb.AppendLine(mod.PublishedFileId.ToString());
|
sb.AppendLine(mod.PublishedFileId.ToString());
|
||||||
|
|
||||||
DedicatedConfig.Mods = world.Checkpoint.Mods.Select(x => x.PublishedFileId).ToList();
|
DedicatedConfig.Mods = world.Checkpoint.Mods.Select(x => x.PublishedFileId).ToList();
|
||||||
|
|
||||||
|
|
||||||
Log.Debug("Loaded mod list from world");
|
Log.Debug("Loaded mod list from world");
|
||||||
|
|
||||||
if (!modsOnly)
|
if (!modsOnly)
|
||||||
@@ -165,7 +166,8 @@ namespace Torch.Server.Managers
|
|||||||
checkpoint.SessionName = DedicatedConfig.WorldName;
|
checkpoint.SessionName = DedicatedConfig.WorldName;
|
||||||
checkpoint.Settings = DedicatedConfig.SessionSettings;
|
checkpoint.Settings = DedicatedConfig.SessionSettings;
|
||||||
checkpoint.Mods.Clear();
|
checkpoint.Mods.Clear();
|
||||||
foreach (var modId in DedicatedConfig.Model.Mods)
|
|
||||||
|
foreach (var modId in DedicatedConfig.Mods)
|
||||||
checkpoint.Mods.Add(new MyObjectBuilder_Checkpoint.ModItem(modId));
|
checkpoint.Mods.Add(new MyObjectBuilder_Checkpoint.ModItem(modId));
|
||||||
|
|
||||||
MyObjectBuilderSerializer.SerializeXML(sandboxPath, false, checkpoint);
|
MyObjectBuilderSerializer.SerializeXML(sandboxPath, false, checkpoint);
|
||||||
|
@@ -11,7 +11,7 @@ using Sandbox;
|
|||||||
using Sandbox.Engine.Multiplayer;
|
using Sandbox.Engine.Multiplayer;
|
||||||
using Sandbox.Engine.Networking;
|
using Sandbox.Engine.Networking;
|
||||||
using Sandbox.Game.World;
|
using Sandbox.Game.World;
|
||||||
using SteamSDK;
|
using Steamworks;
|
||||||
using Torch.API;
|
using Torch.API;
|
||||||
using Torch.API.Managers;
|
using Torch.API.Managers;
|
||||||
using Torch.Managers;
|
using Torch.Managers;
|
||||||
@@ -150,9 +150,8 @@ namespace Torch.Server.Managers
|
|||||||
//Largely copied from SE
|
//Largely copied from SE
|
||||||
private void ValidateAuthTicketResponse(ulong steamId, JoinResult response, ulong steamOwner)
|
private void ValidateAuthTicketResponse(ulong steamId, JoinResult response, ulong steamOwner)
|
||||||
{
|
{
|
||||||
var state = new P2PSessionState();
|
//SteamNetworking.GetP2PSessionState(new CSteamID(steamId), out P2PSessionState_t state);
|
||||||
Peer2Peer.GetSessionState(steamId, ref state);
|
var ip = "0"; //state.GetRemoteIP();
|
||||||
var ip = state.GetRemoteIP();
|
|
||||||
|
|
||||||
_log.Debug($"ValidateAuthTicketResponse(user={steamId}, response={response}, owner={steamOwner})");
|
_log.Debug($"ValidateAuthTicketResponse(user={steamId}, response={response}, owner={steamOwner})");
|
||||||
|
|
||||||
|
@@ -117,10 +117,8 @@
|
|||||||
<HintPath>..\GameBinaries\SpaceEngineers.ObjectBuilders.XmlSerializers.dll</HintPath>
|
<HintPath>..\GameBinaries\SpaceEngineers.ObjectBuilders.XmlSerializers.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="SteamSDK, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
|
<Reference Include="Steamworks.NET">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>..\GameBinaries\Steamworks.NET.dll</HintPath>
|
||||||
<HintPath>..\GameBinaries\SteamSDK.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
|
@@ -76,8 +76,9 @@ namespace Torch.Server.ViewModels
|
|||||||
public List<string> Administrators { get => _config.Administrators; set => SetValue(x => _config.Administrators = x, value); }
|
public List<string> Administrators { get => _config.Administrators; set => SetValue(x => _config.Administrators = x, value); }
|
||||||
|
|
||||||
public List<ulong> Banned { get => _config.Banned; set => SetValue(x => _config.Banned = x, value); }
|
public List<ulong> Banned { get => _config.Banned; set => SetValue(x => _config.Banned = x, value); }
|
||||||
|
|
||||||
public List<ulong> Mods { get => _config.Mods; set => SetValue(x => _config.Mods = x, value); }
|
private List<ulong> _mods = new List<ulong>();
|
||||||
|
public List<ulong> Mods { get => _mods; set => SetValue(x => _mods = x, value); }
|
||||||
|
|
||||||
public int AsteroidAmount { get => _config.AsteroidAmount; set => SetValue(x => _config.AsteroidAmount = x, value); }
|
public int AsteroidAmount { get => _config.AsteroidAmount; set => SetValue(x => _config.AsteroidAmount = x, value); }
|
||||||
|
|
||||||
|
@@ -59,7 +59,7 @@ namespace Torch.Server.ViewModels
|
|||||||
|
|
||||||
/// <see cref="VRage.Game.MyObjectBuilder_SessionSettings.EnableBlockLimits" />
|
/// <see cref="VRage.Game.MyObjectBuilder_SessionSettings.EnableBlockLimits" />
|
||||||
[Display(Name = "Enable block limits")]
|
[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); }
|
||||||
|
|
||||||
/// <see cref="VRage.Game.MyObjectBuilder_SessionSettings.EnableRemoteBlockRemoval" />
|
/// <see cref="VRage.Game.MyObjectBuilder_SessionSettings.EnableRemoteBlockRemoval" />
|
||||||
[Display(Name = "Enable remote removal of owned blocks")]
|
[Display(Name = "Enable remote removal of owned blocks")]
|
||||||
|
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using SteamSDK;
|
using Steamworks;
|
||||||
|
|
||||||
namespace Torch.Server.ViewModels
|
namespace Torch.Server.ViewModels
|
||||||
{
|
{
|
||||||
@@ -15,7 +15,7 @@ namespace Torch.Server.ViewModels
|
|||||||
public SteamUserViewModel(ulong id)
|
public SteamUserViewModel(ulong id)
|
||||||
{
|
{
|
||||||
SteamId = id;
|
SteamId = id;
|
||||||
Name = SteamAPI.Instance.Friends.GetPersonaName(id);
|
Name = SteamFriends.GetFriendPersonaName(new CSteamID(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SteamUserViewModel() : this(0) { }
|
public SteamUserViewModel() : this(0) { }
|
||||||
|
@@ -19,7 +19,6 @@ using Torch;
|
|||||||
using Sandbox;
|
using Sandbox;
|
||||||
using Sandbox.Engine.Multiplayer;
|
using Sandbox.Engine.Multiplayer;
|
||||||
using Sandbox.Game.World;
|
using Sandbox.Game.World;
|
||||||
using SteamSDK;
|
|
||||||
using Torch.API;
|
using Torch.API;
|
||||||
using Torch.API.Managers;
|
using Torch.API.Managers;
|
||||||
using Torch.API.Session;
|
using Torch.API.Session;
|
||||||
|
@@ -15,7 +15,6 @@ using System.Windows.Media.Imaging;
|
|||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using Sandbox.Engine.Networking;
|
using Sandbox.Engine.Networking;
|
||||||
using SteamSDK;
|
|
||||||
using VRage.Game;
|
using VRage.Game;
|
||||||
|
|
||||||
namespace Torch.Server
|
namespace Torch.Server
|
||||||
@@ -45,16 +44,16 @@ namespace Torch.Server
|
|||||||
mods = dialog.Result;
|
mods = dialog.Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var id in mods)
|
//foreach (var id in mods)
|
||||||
{
|
//{
|
||||||
var details = SteamHelper.GetItemDetails(id);
|
// var details = SteamHelper.GetItemDetails(id);
|
||||||
if (details.FileType != WorkshopFileType.Community)
|
// if (details.FileType != WorkshopFileType.Community)
|
||||||
continue;
|
// continue;
|
||||||
|
|
||||||
var item = SteamHelper.GetModItem(details);
|
// var item = SteamHelper.GetModItem(details);
|
||||||
var desc = details.Description.Length < 500 ? details.Description : details.Description.Substring(0, 500);
|
// var desc = details.Description.Length < 500 ? details.Description : details.Description.Substring(0, 500);
|
||||||
ModList.Items.Add(new ModViewModel(item, desc));
|
// ModList.Items.Add(new ModViewModel(item, desc));
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void modList_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
private void modList_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
|
@@ -19,7 +19,6 @@ using Sandbox.Engine.Multiplayer;
|
|||||||
using Sandbox.Game.Multiplayer;
|
using Sandbox.Game.Multiplayer;
|
||||||
using Sandbox.Game.World;
|
using Sandbox.Game.World;
|
||||||
using Sandbox.ModAPI;
|
using Sandbox.ModAPI;
|
||||||
using SteamSDK;
|
|
||||||
using Torch.API;
|
using Torch.API;
|
||||||
using Torch.API.Managers;
|
using Torch.API.Managers;
|
||||||
using Torch.API.Session;
|
using Torch.API.Session;
|
||||||
|
@@ -10,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
using System.Timers;
|
using System.Timers;
|
||||||
using Sandbox.Game.Multiplayer;
|
using Sandbox.Game.Multiplayer;
|
||||||
using Sandbox.ModAPI;
|
using Sandbox.ModAPI;
|
||||||
using SteamSDK;
|
using Steamworks;
|
||||||
using Torch;
|
using Torch;
|
||||||
using Torch.API;
|
using Torch.API;
|
||||||
using Torch.API.Managers;
|
using Torch.API.Managers;
|
||||||
@@ -33,11 +33,14 @@ namespace Torch.Commands
|
|||||||
[Permission(MyPromoteLevel.None)]
|
[Permission(MyPromoteLevel.None)]
|
||||||
public void GetIP(ulong steamId = 0)
|
public void GetIP(ulong steamId = 0)
|
||||||
{
|
{
|
||||||
var state = new P2PSessionState();
|
Context.Respond("Cannot obtain client IP.");
|
||||||
|
return;
|
||||||
|
|
||||||
if (steamId == 0)
|
if (steamId == 0)
|
||||||
steamId = Context.Player.SteamUserId;
|
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}");
|
Context.Respond($"Your IP is {ip}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,6 @@ using Sandbox.Game.Entities.Character;
|
|||||||
using Sandbox.Game.Multiplayer;
|
using Sandbox.Game.Multiplayer;
|
||||||
using Sandbox.Game.World;
|
using Sandbox.Game.World;
|
||||||
using Sandbox.ModAPI;
|
using Sandbox.ModAPI;
|
||||||
using SteamSDK;
|
|
||||||
using Torch.API;
|
using Torch.API;
|
||||||
using Torch.API.Managers;
|
using Torch.API.Managers;
|
||||||
using Torch.Collections;
|
using Torch.Collections;
|
||||||
|
@@ -29,6 +29,8 @@ namespace Torch.Managers
|
|||||||
private static Func<MyReplicationLayerBase, MyTypeTable> _typeTableGetter;
|
private static Func<MyReplicationLayerBase, MyTypeTable> _typeTableGetter;
|
||||||
[ReflectedGetter(Name = "m_methodInfoLookup")]
|
[ReflectedGetter(Name = "m_methodInfoLookup")]
|
||||||
private static Func<MyEventTable, Dictionary<MethodInfo, CallSite>> _methodInfoLookupGetter;
|
private static Func<MyEventTable, Dictionary<MethodInfo, CallSite>> _methodInfoLookupGetter;
|
||||||
|
[ReflectedMethod(Type = typeof(MyReplicationLayer), Name = "GetObjectByNetworkId")]
|
||||||
|
private static Func<MyReplicationLayer, NetworkId, IMyNetObject> _getObjectByNetworkId;
|
||||||
|
|
||||||
public NetworkManager(ITorchBase torchInstance) : base(torchInstance)
|
public NetworkManager(ITorchBase torchInstance) : base(torchInstance)
|
||||||
{
|
{
|
||||||
@@ -133,7 +135,7 @@ namespace Torch.Managers
|
|||||||
}
|
}
|
||||||
|
|
||||||
var stream = new BitStream();
|
var stream = new BitStream();
|
||||||
stream.ResetRead(packet);
|
stream.ResetRead(packet.BitStream);
|
||||||
|
|
||||||
var networkId = stream.ReadNetworkId();
|
var networkId = stream.ReadNetworkId();
|
||||||
//this value is unused, but removing this line corrupts the rest of the stream
|
//this value is unused, but removing this line corrupts the rest of the stream
|
||||||
@@ -150,7 +152,8 @@ namespace Torch.Managers
|
|||||||
}
|
}
|
||||||
else // Instance event
|
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)
|
if (sendAs == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@@ -11,7 +11,6 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NLog;
|
using NLog;
|
||||||
using Octokit;
|
using Octokit;
|
||||||
using SteamSDK;
|
|
||||||
using Torch.API;
|
using Torch.API;
|
||||||
|
|
||||||
namespace Torch.Managers
|
namespace Torch.Managers
|
||||||
|
@@ -31,6 +31,7 @@ namespace Torch.Patches
|
|||||||
|
|
||||||
internal static void ForceRegisterAssemblies()
|
internal static void ForceRegisterAssemblies()
|
||||||
{
|
{
|
||||||
|
var userAssemblies = MyPlugins.UserAssemblies;
|
||||||
// static MyEntities() called by MySandboxGame.ForceStaticCtor
|
// static MyEntities() called by MySandboxGame.ForceStaticCtor
|
||||||
RuntimeHelpers.RunClassConstructor(typeof(MyEntities).TypeHandle);
|
RuntimeHelpers.RunClassConstructor(typeof(MyEntities).TypeHandle);
|
||||||
{
|
{
|
||||||
@@ -38,7 +39,14 @@ namespace Torch.Patches
|
|||||||
ObjectFactory_RegisterFromAssemblySafe(factory, typeof(MySandboxGame).Assembly); // calling assembly
|
ObjectFactory_RegisterFromAssemblySafe(factory, typeof(MySandboxGame).Assembly); // calling assembly
|
||||||
ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.GameAssembly);
|
ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.GameAssembly);
|
||||||
ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.SandboxAssembly);
|
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():
|
// static MyGuiManager():
|
||||||
@@ -51,7 +59,14 @@ namespace Torch.Patches
|
|||||||
ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.SandboxAssembly);
|
ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.SandboxAssembly);
|
||||||
ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.GameAssembly);
|
ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.GameAssembly);
|
||||||
ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.SandboxGameAssembly);
|
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()
|
// static MyObjectPoolManager()
|
||||||
|
@@ -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<string>();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 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.
|
|
||||||
/// </summary>
|
|
||||||
public class SteamService : MySteamService
|
|
||||||
{
|
|
||||||
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
|
|
||||||
|
|
||||||
#pragma warning disable 649
|
|
||||||
[ReflectedSetter(Name = nameof(SteamServerAPI))]
|
|
||||||
private static Action<MySteamService, SteamServerAPI> _steamServerAPISetter;
|
|
||||||
[ReflectedSetter(Name = "m_gameServer")]
|
|
||||||
private static Action<MySteamService, MySteamGameServer> _steamGameServerSetter;
|
|
||||||
[ReflectedSetter(Name = nameof(AppId))]
|
|
||||||
private static Action<MySteamService, uint> _steamAppIdSetter;
|
|
||||||
[ReflectedSetter(Name = nameof(API))]
|
|
||||||
private static Action<MySteamService, SteamAPI> _steamApiSetter;
|
|
||||||
[ReflectedSetter(Name = nameof(IsActive))]
|
|
||||||
private static Action<MySteamService, bool> _steamIsActiveSetter;
|
|
||||||
[ReflectedSetter(Name = nameof(UserId))]
|
|
||||||
private static Action<MySteamService, ulong> _steamUserIdSetter;
|
|
||||||
[ReflectedSetter(Name = nameof(UserName))]
|
|
||||||
private static Action<MySteamService, string> _steamUserNameSetter;
|
|
||||||
[ReflectedSetter(Name = nameof(OwnsGame))]
|
|
||||||
private static Action<MySteamService, bool> _steamOwnsGameSetter;
|
|
||||||
[ReflectedSetter(Name = nameof(UserUniverse))]
|
|
||||||
private static Action<MySteamService, MyGameServiceUniverse> _steamUserUniverseSetter;
|
|
||||||
[ReflectedSetter(Name = nameof(BranchName))]
|
|
||||||
private static Action<MySteamService, string> _steamBranchNameSetter;
|
|
||||||
[ReflectedSetter(Name = nameof(InventoryAPI))]
|
|
||||||
private static Action<MySteamService, MySteamInventory> _steamInventoryAPISetter;
|
|
||||||
[ReflectedMethod]
|
|
||||||
private static Action<MySteamService> RegisterCallbacks;
|
|
||||||
[ReflectedSetter(Name = nameof(Peer2Peer))]
|
|
||||||
private static Action<MySteamService, IMyPeer2Peer> _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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -84,9 +84,8 @@
|
|||||||
<HintPath>..\GameBinaries\SpaceEngineers.ObjectBuilders.XmlSerializers.dll</HintPath>
|
<HintPath>..\GameBinaries\SpaceEngineers.ObjectBuilders.XmlSerializers.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="SteamSDK">
|
<Reference Include="Steamworks.NET">
|
||||||
<HintPath>..\GameBinaries\SteamSDK.dll</HintPath>
|
<HintPath>..\GameBinaries\Steamworks.NET.dll</HintPath>
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
@@ -254,13 +253,11 @@
|
|||||||
<Compile Include="Utils\Reflected\ReflectedManager.cs" />
|
<Compile Include="Utils\Reflected\ReflectedManager.cs" />
|
||||||
<Compile Include="Session\TorchSessionManager.cs" />
|
<Compile Include="Session\TorchSessionManager.cs" />
|
||||||
<Compile Include="TorchBase.cs" />
|
<Compile Include="TorchBase.cs" />
|
||||||
<Compile Include="SteamService.cs" />
|
|
||||||
<Compile Include="TorchPluginBase.cs" />
|
<Compile Include="TorchPluginBase.cs" />
|
||||||
<Compile Include="Session\TorchSession.cs" />
|
<Compile Include="Session\TorchSession.cs" />
|
||||||
<Compile Include="Utils\TorchLauncher.cs" />
|
<Compile Include="Utils\TorchLauncher.cs" />
|
||||||
<Compile Include="ViewModels\ModViewModel.cs" />
|
<Compile Include="ViewModels\ModViewModel.cs" />
|
||||||
<Compile Include="Extensions\MyPlayerCollectionExtensions.cs" />
|
<Compile Include="Extensions\MyPlayerCollectionExtensions.cs" />
|
||||||
<Compile Include="SteamHelper.cs" />
|
|
||||||
<Compile Include="Extensions\StringExtensions.cs" />
|
<Compile Include="Extensions\StringExtensions.cs" />
|
||||||
<Compile Include="ViewModels\PlayerViewModel.cs" />
|
<Compile Include="ViewModels\PlayerViewModel.cs" />
|
||||||
<Compile Include="ViewModels\ViewModel.cs" />
|
<Compile Include="ViewModels\ViewModel.cs" />
|
||||||
|
@@ -6,7 +6,7 @@ using System.Net;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using SteamSDK;
|
using Steamworks;
|
||||||
|
|
||||||
namespace Torch.Utils
|
namespace Torch.Utils
|
||||||
{
|
{
|
||||||
@@ -52,10 +52,10 @@ namespace Torch.Utils
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IPAddress GetRemoteIP(this P2PSessionState state)
|
public static IPAddress GetRemoteIP(this P2PSessionState_t state)
|
||||||
{
|
{
|
||||||
// What is endianness anyway?
|
// What is endianness anyway?
|
||||||
return new IPAddress(BitConverter.GetBytes(state.RemoteIP).Reverse().ToArray());
|
return new IPAddress(BitConverter.GetBytes(state.m_nRemoteIP).Reverse().ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@ using System.Reflection;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NLog;
|
using NLog;
|
||||||
using SteamSDK;
|
|
||||||
|
|
||||||
namespace Torch.Utils
|
namespace Torch.Utils
|
||||||
{
|
{
|
||||||
|
@@ -35,6 +35,7 @@ using VRage.Plugins;
|
|||||||
using VRage.Steam;
|
using VRage.Steam;
|
||||||
using VRage.Utils;
|
using VRage.Utils;
|
||||||
using VRageRender;
|
using VRageRender;
|
||||||
|
using MyRenderProfiler = VRage.Profiler.MyRenderProfiler;
|
||||||
|
|
||||||
namespace Torch
|
namespace Torch
|
||||||
{
|
{
|
||||||
@@ -198,8 +199,8 @@ namespace Torch
|
|||||||
MySandboxGame.Config.GraphicsRenderer = graphicsRenderer;
|
MySandboxGame.Config.GraphicsRenderer = graphicsRenderer;
|
||||||
}
|
}
|
||||||
MyRenderProxy.Initialize(renderer);
|
MyRenderProxy.Initialize(renderer);
|
||||||
MyRenderProxy.GetRenderProfiler().SetAutocommit(false);
|
MyRenderProfiler.SetAutocommit(false);
|
||||||
MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint");
|
MyRenderProfiler.InitMemoryHack("MainEntryPoint");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loads object builder serializers. Intuitive, right?
|
// Loads object builder serializers. Intuitive, right?
|
||||||
@@ -276,7 +277,7 @@ namespace Torch
|
|||||||
MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSize);
|
MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out checkpointSize);
|
||||||
if (MySession.IsCompatibleVersion(checkpoint))
|
if (MySession.IsCompatibleVersion(checkpoint))
|
||||||
{
|
{
|
||||||
if (MySteamWorkshop.DownloadWorldModsBlocking(checkpoint.Mods).Success)
|
if (MyWorkshop.DownloadWorldModsBlocking(checkpoint.Mods).Success)
|
||||||
{
|
{
|
||||||
// MySpaceAnalytics.Instance.SetEntry(MyGameEntryEnum.Load);
|
// MySpaceAnalytics.Instance.SetEntry(MyGameEntryEnum.Load);
|
||||||
MySession.Load(sessionPath, checkpoint, checkpointSize);
|
MySession.Load(sessionPath, checkpoint, checkpointSize);
|
||||||
|
@@ -4,7 +4,6 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Sandbox.Engine.Multiplayer;
|
using Sandbox.Engine.Multiplayer;
|
||||||
using SteamSDK;
|
|
||||||
using Torch.API;
|
using Torch.API;
|
||||||
using VRage.Replication;
|
using VRage.Replication;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user