Compare commits

...

5 Commits
2.1.5 ... 2.1.8

Author SHA1 Message Date
zznty
b6e88b359f fix assembly rewriter stripping assembly resources
All checks were successful
Release / Get Version (push) Successful in 11s
Release / Build and Publish Nuget (push) Successful in 2m14s
Release / Build and Publish Package (push) Successful in 19m29s
2024-10-14 00:15:05 +07:00
zznty
b60100171d fix assembly rewriter paths on publish
All checks were successful
Release / Get Version (push) Successful in 10s
Release / Build and Publish Nuget (push) Successful in 8m54s
Release / Build and Publish Package (push) Successful in 17m25s
2024-10-13 22:46:22 +07:00
zznty
65e2f342a3 fix exception when destruction occurs before game has been initialized
All checks were successful
Release / Get Version (push) Successful in 15s
Release / Build and Publish Nuget (push) Successful in 2m21s
Release / Build and Publish Package (push) Successful in 2m51s
2024-10-13 22:29:05 +07:00
zznty
6a695f2abf fix backwards compat with some plugins 2024-10-13 22:26:09 +07:00
zznty
9289ab8003 fix compiler paths on publish 2024-10-13 22:17:07 +07:00
4 changed files with 49 additions and 22 deletions

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@@ -140,6 +141,22 @@ namespace Torch.API
event Action<ITorchServer> Initialized; event Action<ITorchServer> Initialized;
TimeSpan ElapsedPlayTime { get; set; } 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> /// <summary>

View File

@@ -45,6 +45,12 @@ namespace Torch.Patches
private static void WhitelistCtorPrefix(MyScriptCompiler scriptCompiler) private static void WhitelistCtorPrefix(MyScriptCompiler scriptCompiler)
{ {
var baseDir = new FileInfo(typeof(Type).Assembly.Location).DirectoryName!; var baseDir = new FileInfo(typeof(Type).Assembly.Location).DirectoryName!;
var binDir =
#if DEBUG
baseDir;
#else
Path.Join(AppContext.BaseDirectory, "torch64");
#endif
scriptCompiler.AddReferencedAssemblies( scriptCompiler.AddReferencedAssemblies(
typeof(Type).Assembly.Location, typeof(Type).Assembly.Location,
@@ -57,22 +63,22 @@ namespace Torch.Patches
typeof(TypeConverter).Assembly.Location, typeof(TypeConverter).Assembly.Location,
typeof(System.Diagnostics.TraceSource).Assembly.Location, typeof(System.Diagnostics.TraceSource).Assembly.Location,
typeof(System.Security.Policy.Evidence).Assembly.Location, typeof(System.Security.Policy.Evidence).Assembly.Location,
Path.Combine(baseDir, "System.Xml.ReaderWriter.dll"), Path.Join(binDir, "System.Xml.ReaderWriter.dll"),
Path.Combine(MyFileSystem.ExePath, "ProtoBuf.Net.dll"), Path.Join(MyFileSystem.ExePath, "ProtoBuf.Net.dll"),
Path.Combine(MyFileSystem.ExePath, "ProtoBuf.Net.Core.dll"), Path.Join(MyFileSystem.ExePath, "ProtoBuf.Net.Core.dll"),
Path.Combine(baseDir, "netstandard.dll"), Path.Join(binDir, "netstandard.dll"),
Path.Combine(baseDir, "System.Runtime.dll"), Path.Join(baseDir, "System.Runtime.dll"),
Path.Combine(MyFileSystem.ExePath, "Sandbox.Game.dll"), Path.Join(MyFileSystem.ExePath, "Sandbox.Game.dll"),
Path.Combine(MyFileSystem.ExePath, "Sandbox.Common.dll"), Path.Join(MyFileSystem.ExePath, "Sandbox.Common.dll"),
Path.Combine(MyFileSystem.ExePath, "Sandbox.Graphics.dll"), Path.Join(MyFileSystem.ExePath, "Sandbox.Graphics.dll"),
Path.Combine(MyFileSystem.ExePath, "VRage.dll"), Path.Join(MyFileSystem.ExePath, "VRage.dll"),
Path.Combine(MyFileSystem.ExePath, "VRage.Library.dll"), Path.Join(MyFileSystem.ExePath, "VRage.Library.dll"),
Path.Combine(MyFileSystem.ExePath, "VRage.Math.dll"), Path.Join(MyFileSystem.ExePath, "VRage.Math.dll"),
Path.Combine(MyFileSystem.ExePath, "VRage.Game.dll"), Path.Join(MyFileSystem.ExePath, "VRage.Game.dll"),
Path.Combine(MyFileSystem.ExePath, "VRage.Render.dll"), Path.Join(MyFileSystem.ExePath, "VRage.Render.dll"),
Path.Combine(MyFileSystem.ExePath, "VRage.Input.dll"), Path.Join(MyFileSystem.ExePath, "VRage.Input.dll"),
Path.Combine(MyFileSystem.ExePath, "SpaceEngineers.ObjectBuilders.dll"), Path.Join(MyFileSystem.ExePath, "SpaceEngineers.ObjectBuilders.dll"),
Path.Combine(MyFileSystem.ExePath, "SpaceEngineers.Game.dll")); Path.Join(MyFileSystem.ExePath, "SpaceEngineers.Game.dll"));
} }
private static bool InitializePrefix(Thread updateThread, Type[] referencedTypes, string[] symbols) private static bool InitializePrefix(Thread updateThread, Type[] referencedTypes, string[] symbols)

View File

@@ -19,8 +19,11 @@ internal static class AssemblyRewriter
{ {
_defaultResolver = new(); _defaultResolver = new();
_zipResolver = new(_defaultResolver); _zipResolver = new(_defaultResolver);
_defaultResolver.AddSearchDirectory(Directory.GetCurrentDirectory()); _defaultResolver.AddSearchDirectory(AppContext.BaseDirectory);
_defaultResolver.AddSearchDirectory(Path.Combine(Directory.GetCurrentDirectory(), "DedicatedServer64")); _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) 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) private static Assembly ProcessInternal(Stream inputStream, IAssemblyResolver resolver)
{ {
using var module = ModuleDefinition.ReadModule(inputStream, new() using var assembly = AssemblyDefinition.ReadAssembly(inputStream, new()
{ {
AssemblyResolver = resolver AssemblyResolver = resolver
}); });
foreach (var fieldDefinition in FindAllToRewrite(module)) foreach (var fieldDefinition in FindAllToRewrite(assembly.MainModule))
{ {
fieldDefinition.IsInitOnly = false; fieldDefinition.IsInitOnly = false;
} }
using var memStream = new MemoryStream(); using var memStream = new MemoryStream();
module.Assembly.Write(memStream); assembly.Write(memStream);
return Assembly.Load(memStream.ToArray()); return Assembly.Load(memStream.ToArray());
} }

View File

@@ -312,7 +312,7 @@ namespace Torch
private void Destroy() private void Destroy()
{ {
_game.Dispose(); _game?.Dispose();
_game = null; _game = null;
MyGameService.ShutDown(); MyGameService.ShutDown();
@@ -462,7 +462,8 @@ namespace Torch
public void SignalDestroy() public void SignalDestroy()
{ {
_destroyGame = true; _destroyGame = true;
SignalStop(); if (_game is not null)
SignalStop();
_commandChanged.Set(); _commandChanged.Set();
} }