Compare commits

..

8 Commits

Author SHA1 Message Date
Bishbash777
5804165d2b 205 fixes. (#590)
All checks were successful
Release / Get Version (push) Successful in 7s
Release / Build and Publish Nuget (push) Successful in 2m33s
Release / Build and Publish Package (push) Successful in 3m9s
(cherry picked from commit e41a26dbd2fb966b21757fa0248f6b4a4e716aad)
2024-10-15 01:18:02 +07:00
zznty
1960d2a0de fix world path being truncated if missing trailing slash
Some checks failed
Release / Get Version (push) Failing after 1s
Release / Build and Publish Nuget (push) Has been skipped
Release / Build and Publish Package (push) Has been skipped
2024-10-14 23:20:49 +07:00
zznty
0c53b2f1d3 add RegisterAuxAssembly for compat with loader wrapper
All checks were successful
Release / Get Version (push) Successful in 8s
Release / Build and Publish Nuget (push) Successful in 1m51s
Release / Build and Publish Package (push) Successful in 13m54s
2024-10-14 18:18:21 +07:00
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
13 changed files with 84 additions and 46 deletions

View File

@@ -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>

View File

@@ -18,7 +18,7 @@
<PackageReference Include="NuGet.Commands" Version="6.11.0" />
<PackageReference Include="NuGet.DependencyResolver.Core" Version="6.11.0" />
<PackageReference Include="SemanticVersioning" Version="2.0.2" />
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.204.18">
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.*">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="System.Linq.Async" Version="6.0.1" />

View File

@@ -54,9 +54,9 @@
},
"SpaceEngineersDedicated.ReferenceAssemblies": {
"type": "Direct",
"requested": "[1.204.18, )",
"resolved": "1.204.18",
"contentHash": "GT7/9CBMx4jjor41zLOOl87YYM/JdJD8xp9ccXyuhP2oUaz25H3ZmCQuGeAuZNENKru1a/7hZrId4PwlMDGoew==",
"requested": "[1.*, )",
"resolved": "1.205.23",
"contentHash": "J7mF5hY39PzzCZps6vhIRzKiq8vD6Af9TgumTJR068vjEi+BzyeEFhqX+cl2Dd1ngOmsBtGWc5m+vxgTfs5YuA==",
"dependencies": {
"SharpDX": "4.2.0-keen-cringe",
"protobuf-net": "1.0.0"

View File

@@ -468,8 +468,8 @@
},
"SpaceEngineersDedicated.ReferenceAssemblies": {
"type": "Transitive",
"resolved": "1.204.18",
"contentHash": "GT7/9CBMx4jjor41zLOOl87YYM/JdJD8xp9ccXyuhP2oUaz25H3ZmCQuGeAuZNENKru1a/7hZrId4PwlMDGoew==",
"resolved": "1.205.23",
"contentHash": "J7mF5hY39PzzCZps6vhIRzKiq8vD6Af9TgumTJR068vjEi+BzyeEFhqX+cl2Dd1ngOmsBtGWc5m+vxgTfs5YuA==",
"dependencies": {
"SharpDX": "4.2.0-keen-cringe",
"protobuf-net": "1.0.0"
@@ -630,7 +630,7 @@
"NuGet.Commands": "[6.11.0, )",
"NuGet.DependencyResolver.Core": "[6.11.0, )",
"SemanticVersioning": "[2.0.2, )",
"SpaceEngineersDedicated.ReferenceAssemblies": "[1.204.18, )",
"SpaceEngineersDedicated.ReferenceAssemblies": "[1.*, )",
"System.Linq.Async": "[6.0.1, )"
}
},

View File

@@ -134,7 +134,7 @@ namespace Torch.Server.Managers
worldPath = DedicatedConfig.Worlds.First().WorldPath;
else
// make sure we won't end up with a file path when we expect it to be a directory
worldPath = Path.EndsInDirectorySeparator(worldPath) ? worldPath : Path.GetDirectoryName(worldPath);
worldPath = worldPath.EndsWith(".sbc") ? Path.GetDirectoryName(worldPath) : worldPath;
SelectWorld(worldPath, false);
@@ -235,7 +235,7 @@ namespace Torch.Server.Managers
try
{
MyObjectBuilderSerializer.DeserializeXML(sandboxPath, out MyObjectBuilder_Checkpoint checkpoint, out ulong sizeInBytes);
MyObjectBuilderSerializerKeen.DeserializeXML(sandboxPath, out MyObjectBuilder_Checkpoint checkpoint, out ulong sizeInBytes);
if (checkpoint == null)
{
Log.Error($"Failed to load {DedicatedConfig.LoadWorld}, checkpoint null ({sizeInBytes} bytes, instance {Torch.Config.InstancePath})");
@@ -368,14 +368,14 @@ namespace Torch.Server.Managers
public void LoadSandbox()
{
if (!MyObjectBuilderSerializer.DeserializeXML(_checkpointPath, out MyObjectBuilder_Checkpoint checkpoint))
if (!MyObjectBuilderSerializerKeen.DeserializeXML(_checkpointPath, out MyObjectBuilder_Checkpoint checkpoint))
throw new SerializationException("Error reading checkpoint, see keen log for details");
Checkpoint = new CheckpointViewModel(checkpoint);
// migrate old saves
if (File.Exists(_worldConfigPath))
{
if (!MyObjectBuilderSerializer.DeserializeXML(_worldConfigPath, out MyObjectBuilder_WorldConfiguration worldConfig))
if (!MyObjectBuilderSerializerKeen.DeserializeXML(_worldConfigPath, out MyObjectBuilder_WorldConfiguration worldConfig))
throw new SerializationException("Error reading settings, see keen log for details");
WorldConfiguration = new WorldConfigurationViewModel(worldConfig);
}

View File

@@ -472,8 +472,8 @@
},
"SpaceEngineersDedicated.ReferenceAssemblies": {
"type": "Transitive",
"resolved": "1.204.18",
"contentHash": "GT7/9CBMx4jjor41zLOOl87YYM/JdJD8xp9ccXyuhP2oUaz25H3ZmCQuGeAuZNENKru1a/7hZrId4PwlMDGoew==",
"resolved": "1.205.23",
"contentHash": "J7mF5hY39PzzCZps6vhIRzKiq8vD6Af9TgumTJR068vjEi+BzyeEFhqX+cl2Dd1ngOmsBtGWc5m+vxgTfs5YuA==",
"dependencies": {
"SharpDX": "4.2.0-keen-cringe",
"protobuf-net": "1.0.0"
@@ -581,7 +581,7 @@
"NuGet.Commands": "[6.11.0, )",
"NuGet.DependencyResolver.Core": "[6.11.0, )",
"SemanticVersioning": "[2.0.2, )",
"SpaceEngineersDedicated.ReferenceAssemblies": "[1.204.18, )",
"SpaceEngineersDedicated.ReferenceAssemblies": "[1.*, )",
"System.Linq.Async": "[6.0.1, )"
}
}

View File

@@ -313,8 +313,8 @@
},
"SpaceEngineersDedicated.ReferenceAssemblies": {
"type": "Transitive",
"resolved": "1.204.18",
"contentHash": "GT7/9CBMx4jjor41zLOOl87YYM/JdJD8xp9ccXyuhP2oUaz25H3ZmCQuGeAuZNENKru1a/7hZrId4PwlMDGoew==",
"resolved": "1.205.23",
"contentHash": "J7mF5hY39PzzCZps6vhIRzKiq8vD6Af9TgumTJR068vjEi+BzyeEFhqX+cl2Dd1ngOmsBtGWc5m+vxgTfs5YuA==",
"dependencies": {
"SharpDX": "4.2.0-keen-cringe",
"protobuf-net": "1.0.0"
@@ -454,7 +454,7 @@
"NuGet.Commands": "[6.11.0, )",
"NuGet.DependencyResolver.Core": "[6.11.0, )",
"SemanticVersioning": "[2.0.2, )",
"SpaceEngineersDedicated.ReferenceAssemblies": "[1.204.18, )",
"SpaceEngineersDedicated.ReferenceAssemblies": "[1.*, )",
"System.Linq.Async": "[6.0.1, )"
}
}

View File

@@ -10,6 +10,7 @@ using Torch.API;
using Torch.API.Managers;
using Torch.Utils;
using VRage.Game;
using VRage.GameServices;
using Color = VRageMath.Color;
namespace Torch.Managers.ChatManager
@@ -76,7 +77,7 @@ namespace Torch.Managers.ChatManager
_chatMessageRecievedReplacer = _chatMessageReceivedFactory.Invoke();
_scriptedChatMessageRecievedReplacer = _scriptedChatMessageReceivedFactory.Invoke();
_chatMessageRecievedReplacer.Replace(
new Action<ulong, string, ChatChannel, long, string, ulong?>(Multiplayer_ChatMessageReceived),
new Action<ulong, string, ChatChannel, long, ChatMessageCustomData?>(Multiplayer_ChatMessageReceived),
MyMultiplayer.Static);
_scriptedChatMessageRecievedReplacer.Replace(
new Action<string, string, string, Color>(Multiplayer_ScriptedChatMessageReceived),
@@ -133,14 +134,14 @@ namespace Torch.Managers.ChatManager
}
private void Multiplayer_ChatMessageReceived(ulong steamUserId, string messageText, ChatChannel channel, long targetId, string customAuthorName, ulong? customSenderId = null)
private void Multiplayer_ChatMessageReceived(ulong steamUserId, string messageText, ChatChannel channel, long targetId, ChatMessageCustomData? customData )
{
#pragma warning disable CS0612
var torchMsg = new TorchChatMessage(steamUserId, messageText, channel, targetId,
#pragma warning restore CS0612
(steamUserId == MyGameService.UserId) ? MyFontEnum.DarkBlue : MyFontEnum.Blue);
if (!RaiseMessageRecieved(torchMsg) && HasHud)
_hudChatMessageReceived.Invoke(MyHud.Chat, steamUserId, messageText, channel, targetId, customAuthorName, customSenderId);
_hudChatMessageReceived.Invoke(MyHud.Chat, steamUserId, messageText, channel, targetId, customData);
}
private void Multiplayer_ScriptedChatMessageReceived(string message, string author, string font, Color color)
@@ -165,7 +166,7 @@ namespace Torch.Managers.ChatManager
protected static bool HasHud => !Sandbox.Engine.Platform.Game.IsDedicated;
[ReflectedMethod(Name = _hudChatMessageReceivedName)]
private static Action<MyHudChat, ulong, string, ChatChannel, long, string, ulong?> _hudChatMessageReceived = null!;
private static Action<MyHudChat, ulong, string, ChatChannel, long, ChatMessageCustomData?> _hudChatMessageReceived = null!;
[ReflectedMethod(Name = _hudChatScriptedMessageReceivedName)]
private static Action<MyHudChat, string, string, string, Color> _hudChatScriptedMessageReceived = null!;

View File

@@ -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)

View File

@@ -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());
}

View File

@@ -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
}
}

View File

@@ -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();
}

View File

@@ -314,8 +314,8 @@
},
"SpaceEngineersDedicated.ReferenceAssemblies": {
"type": "Transitive",
"resolved": "1.204.18",
"contentHash": "GT7/9CBMx4jjor41zLOOl87YYM/JdJD8xp9ccXyuhP2oUaz25H3ZmCQuGeAuZNENKru1a/7hZrId4PwlMDGoew==",
"resolved": "1.205.23",
"contentHash": "J7mF5hY39PzzCZps6vhIRzKiq8vD6Af9TgumTJR068vjEi+BzyeEFhqX+cl2Dd1ngOmsBtGWc5m+vxgTfs5YuA==",
"dependencies": {
"SharpDX": "4.2.0-keen-cringe",
"protobuf-net": "1.0.0"
@@ -387,7 +387,7 @@
"NuGet.Commands": "[6.11.0, )",
"NuGet.DependencyResolver.Core": "[6.11.0, )",
"SemanticVersioning": "[2.0.2, )",
"SpaceEngineersDedicated.ReferenceAssemblies": "[1.204.18, )",
"SpaceEngineersDedicated.ReferenceAssemblies": "[1.*, )",
"System.Linq.Async": "[6.0.1, )"
}
}