Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0c53b2f1d3 | ||
![]() |
b6e88b359f | ||
![]() |
b60100171d | ||
![]() |
65e2f342a3 | ||
![]() |
6a695f2abf | ||
![]() |
9289ab8003 |
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
@@ -140,6 +141,22 @@ namespace Torch.API
|
||||
event Action<ITorchServer> Initialized;
|
||||
|
||||
TimeSpan ElapsedPlayTime { get; set; }
|
||||
|
||||
#region Backwards compat
|
||||
|
||||
/// <summary>
|
||||
/// Path of the dedicated instance folder.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
new string InstancePath => ((ITorchBase)this).InstancePath;
|
||||
|
||||
/// <summary>
|
||||
/// Name of the dedicated instance.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
new string InstanceName => ((ITorchBase)this).InstanceName;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -45,6 +45,12 @@ namespace Torch.Patches
|
||||
private static void WhitelistCtorPrefix(MyScriptCompiler scriptCompiler)
|
||||
{
|
||||
var baseDir = new FileInfo(typeof(Type).Assembly.Location).DirectoryName!;
|
||||
var binDir =
|
||||
#if DEBUG
|
||||
baseDir;
|
||||
#else
|
||||
Path.Join(AppContext.BaseDirectory, "torch64");
|
||||
#endif
|
||||
|
||||
scriptCompiler.AddReferencedAssemblies(
|
||||
typeof(Type).Assembly.Location,
|
||||
@@ -57,22 +63,22 @@ namespace Torch.Patches
|
||||
typeof(TypeConverter).Assembly.Location,
|
||||
typeof(System.Diagnostics.TraceSource).Assembly.Location,
|
||||
typeof(System.Security.Policy.Evidence).Assembly.Location,
|
||||
Path.Combine(baseDir, "System.Xml.ReaderWriter.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "ProtoBuf.Net.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "ProtoBuf.Net.Core.dll"),
|
||||
Path.Combine(baseDir, "netstandard.dll"),
|
||||
Path.Combine(baseDir, "System.Runtime.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "Sandbox.Game.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "Sandbox.Common.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "Sandbox.Graphics.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "VRage.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "VRage.Library.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "VRage.Math.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "VRage.Game.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "VRage.Render.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "VRage.Input.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "SpaceEngineers.ObjectBuilders.dll"),
|
||||
Path.Combine(MyFileSystem.ExePath, "SpaceEngineers.Game.dll"));
|
||||
Path.Join(binDir, "System.Xml.ReaderWriter.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "ProtoBuf.Net.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "ProtoBuf.Net.Core.dll"),
|
||||
Path.Join(binDir, "netstandard.dll"),
|
||||
Path.Join(baseDir, "System.Runtime.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "Sandbox.Game.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "Sandbox.Common.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "Sandbox.Graphics.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "VRage.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "VRage.Library.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "VRage.Math.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "VRage.Game.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "VRage.Render.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "VRage.Input.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "SpaceEngineers.ObjectBuilders.dll"),
|
||||
Path.Join(MyFileSystem.ExePath, "SpaceEngineers.Game.dll"));
|
||||
}
|
||||
|
||||
private static bool InitializePrefix(Thread updateThread, Type[] referencedTypes, string[] symbols)
|
||||
|
@@ -19,8 +19,11 @@ internal static class AssemblyRewriter
|
||||
{
|
||||
_defaultResolver = new();
|
||||
_zipResolver = new(_defaultResolver);
|
||||
_defaultResolver.AddSearchDirectory(Directory.GetCurrentDirectory());
|
||||
_defaultResolver.AddSearchDirectory(AppContext.BaseDirectory);
|
||||
_defaultResolver.AddSearchDirectory(Path.Combine(Directory.GetCurrentDirectory(), "DedicatedServer64"));
|
||||
#if !DEBUG
|
||||
_defaultResolver.AddSearchDirectory(Path.Join(AppContext.BaseDirectory, "torch64"));
|
||||
#endif
|
||||
}
|
||||
|
||||
public static Assembly ProcessWeavers(this Stream stream, ZipArchive archive)
|
||||
@@ -60,17 +63,17 @@ internal static class AssemblyRewriter
|
||||
|
||||
private static Assembly ProcessInternal(Stream inputStream, IAssemblyResolver resolver)
|
||||
{
|
||||
using var module = ModuleDefinition.ReadModule(inputStream, new()
|
||||
using var assembly = AssemblyDefinition.ReadAssembly(inputStream, new()
|
||||
{
|
||||
AssemblyResolver = resolver
|
||||
});
|
||||
foreach (var fieldDefinition in FindAllToRewrite(module))
|
||||
foreach (var fieldDefinition in FindAllToRewrite(assembly.MainModule))
|
||||
{
|
||||
fieldDefinition.IsInitOnly = false;
|
||||
}
|
||||
|
||||
using var memStream = new MemoryStream();
|
||||
module.Assembly.Write(memStream);
|
||||
assembly.Write(memStream);
|
||||
return Assembly.Load(memStream.ToArray());
|
||||
}
|
||||
|
||||
|
@@ -395,5 +395,15 @@ namespace Torch
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event TorchGameStateChangedDel GameStateChanged;
|
||||
|
||||
#region Backwards compat
|
||||
|
||||
[Obsolete("Dont use that", true)]
|
||||
internal static void RegisterAuxAssembly(Assembly assembly)
|
||||
{
|
||||
TorchLauncher.RegisterAssembly(assembly);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -312,7 +312,7 @@ namespace Torch
|
||||
|
||||
private void Destroy()
|
||||
{
|
||||
_game.Dispose();
|
||||
_game?.Dispose();
|
||||
_game = null;
|
||||
|
||||
MyGameService.ShutDown();
|
||||
@@ -462,7 +462,8 @@ namespace Torch
|
||||
public void SignalDestroy()
|
||||
{
|
||||
_destroyGame = true;
|
||||
SignalStop();
|
||||
if (_game is not null)
|
||||
SignalStop();
|
||||
_commandChanged.Set();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user