Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
32d318be5e | ||
![]() |
f349366b58 | ||
![]() |
73ce979b54 | ||
![]() |
73b95472bc | ||
![]() |
9b832a998d |
@@ -21,7 +21,7 @@
|
|||||||
<PackageReference Include="NuGet.Commands" Version="6.4.0" />
|
<PackageReference Include="NuGet.Commands" Version="6.4.0" />
|
||||||
<PackageReference Include="NuGet.DependencyResolver.Core" Version="6.4.0" />
|
<PackageReference Include="NuGet.DependencyResolver.Core" Version="6.4.0" />
|
||||||
<PackageReference Include="SemanticVersioning" Version="2.0.2" />
|
<PackageReference Include="SemanticVersioning" Version="2.0.2" />
|
||||||
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.201.13">
|
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.202.48">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>compile</IncludeAssets>
|
<IncludeAssets>compile</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
@@ -43,9 +43,9 @@
|
|||||||
},
|
},
|
||||||
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[1.201.13, )",
|
"requested": "[1.202.48, )",
|
||||||
"resolved": "1.201.13",
|
"resolved": "1.202.48",
|
||||||
"contentHash": "FRXuNLENsz5jGQvL0QkogAGsxEJyUQlXhvWHBWfZiHCnCrAWMD60nEis6yt0xCQpazszfMtHonbxz72XMxnFoQ==",
|
"contentHash": "iP34MZD14Z/4HTg8rcKQlzJ+azM8/9HVScMJqdYejYbSDAiZzaZS6wlbPkDOKGhbLV2+iW7N5Ix/hCUATBYGuw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"protobuf-net": "1.0.0"
|
"protobuf-net": "1.0.0"
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ namespace Torch.Server
|
|||||||
private const string STEAMCMD_DIR = "steamcmd";
|
private const string STEAMCMD_DIR = "steamcmd";
|
||||||
private const string STEAMCMD_ZIP = "temp.zip";
|
private const string STEAMCMD_ZIP = "temp.zip";
|
||||||
private static readonly string STEAMCMD_EXE = "steamcmd.exe";
|
private static readonly string STEAMCMD_EXE = "steamcmd.exe";
|
||||||
private const string STEAMCMD_ARGS = "+force_install_dir \"{0}\" +login anonymous +app_update 298740 +quit";
|
private const string STEAMCMD_ARGS = "+force_install_dir \"{0}\" +login anonymous +app_update 298740 -beta automtatons-beta +quit";
|
||||||
private TorchServer _server;
|
private TorchServer _server;
|
||||||
|
|
||||||
internal Persistent<TorchConfig> ConfigPersistent { get; }
|
internal Persistent<TorchConfig> ConfigPersistent { get; }
|
||||||
@@ -56,7 +56,7 @@ namespace Torch.Server
|
|||||||
Log.Debug("Debug logging enabled.");
|
Log.Debug("Debug logging enabled.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!configuration.GetValue("noupdate", false))
|
if (configuration.GetValue("getGameUpdates", true) && !configuration.GetValue("noupdate", false))
|
||||||
RunSteamCmd(configuration);
|
RunSteamCmd(configuration);
|
||||||
|
|
||||||
var processPid = configuration.GetValue<int>("waitForPid");
|
var processPid = configuration.GetValue<int>("waitForPid");
|
||||||
|
@@ -51,7 +51,7 @@
|
|||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
<PackageReference Include="System.Management" Version="7.0.0" />
|
<PackageReference Include="System.Management" Version="7.0.0" />
|
||||||
<PackageReference Include="nulastudio.NetCoreBeauty" Version="1.2.9.3" />
|
<PackageReference Include="nulastudio.NetCoreBeauty" Version="1.2.9.3" />
|
||||||
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.201.13">
|
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.202.48">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>compile</IncludeAssets>
|
<IncludeAssets>compile</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
@@ -32,9 +32,25 @@ internal class UnhandledExceptionHandler
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Restarting in 5 seconds.");
|
Console.WriteLine("Restarting in 5 seconds.");
|
||||||
Thread.Sleep(5000);
|
Thread.Sleep(5000);
|
||||||
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
|
||||||
|
|
||||||
Process.Start(exe, $"-waitForPid {Environment.ProcessId} {_config}");
|
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
||||||
|
|
||||||
|
var args = Environment.GetCommandLineArgs();
|
||||||
|
|
||||||
|
for (var i = 0; i < args.Length; i++)
|
||||||
|
{
|
||||||
|
if (args[i].Contains(' '))
|
||||||
|
args[i] = $"\"{args[i]}\"";
|
||||||
|
|
||||||
|
if (!args[i].Contains("--tempAutostart", StringComparison.InvariantCultureIgnoreCase) &&
|
||||||
|
!args[i].Contains("--waitForPid", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
args[i] = string.Empty;
|
||||||
|
args[++i] = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
Process.Start(exe, $"--waitForPid {Environment.ProcessId} --tempAutostart true {string.Join(" ", args)}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -122,9 +122,9 @@
|
|||||||
},
|
},
|
||||||
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[1.201.13, )",
|
"requested": "[1.202.48, )",
|
||||||
"resolved": "1.201.13",
|
"resolved": "1.202.48",
|
||||||
"contentHash": "FRXuNLENsz5jGQvL0QkogAGsxEJyUQlXhvWHBWfZiHCnCrAWMD60nEis6yt0xCQpazszfMtHonbxz72XMxnFoQ==",
|
"contentHash": "iP34MZD14Z/4HTg8rcKQlzJ+azM8/9HVScMJqdYejYbSDAiZzaZS6wlbPkDOKGhbLV2+iW7N5Ix/hCUATBYGuw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"protobuf-net": "1.0.0"
|
"protobuf-net": "1.0.0"
|
||||||
}
|
}
|
||||||
|
@@ -57,22 +57,19 @@ namespace Torch.Managers
|
|||||||
var source = Path.Combine(path, file);
|
var source = Path.Combine(path, file);
|
||||||
if (!File.Exists(source))
|
if (!File.Exists(source))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var tempFilePath = Path.Combine(path, file + ".old");
|
|
||||||
if (File.Exists(tempFilePath))
|
|
||||||
File.Delete(tempFilePath);
|
|
||||||
|
|
||||||
var errorCode = Rename(source, tempFilePath);
|
try
|
||||||
if (Marshal.GetExceptionForHR(errorCode) is { } exception)
|
{
|
||||||
throw exception;
|
File.Delete(source);
|
||||||
|
}
|
||||||
|
catch (IOException)
|
||||||
|
{
|
||||||
|
var tempFilePath = Path.Combine(path, file + ".old");
|
||||||
|
if (File.Exists(tempFilePath))
|
||||||
|
File.Delete(tempFilePath);
|
||||||
|
|
||||||
|
File.Move(source, tempFilePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[LibraryImport("msvcrt", SetLastError = true, EntryPoint = "rename")]
|
|
||||||
[UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
|
|
||||||
private static partial int Rename(
|
|
||||||
[MarshalAs(UnmanagedType.LPWStr)]
|
|
||||||
string oldpath,
|
|
||||||
[MarshalAs(UnmanagedType.LPWStr)]
|
|
||||||
string newpath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,139 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using Sandbox;
|
|
||||||
using Sandbox.Game.Entities;
|
|
||||||
using Torch.Utils;
|
|
||||||
using VRage.Game.Common;
|
|
||||||
using VRage.Game.Components;
|
|
||||||
using VRage.Game.Entity;
|
|
||||||
using VRage.ObjectBuilders;
|
|
||||||
using VRage.Plugins;
|
|
||||||
using VRage.Utils;
|
|
||||||
|
|
||||||
namespace Torch.Patches
|
|
||||||
{
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// There are places in static ctors where the registered assembly depends on the <see cref="Assembly.GetCallingAssembly"/>
|
|
||||||
/// or <see cref="MyPlugins"/>. Here we force those registrations with the proper assemblies to ensure they work correctly.
|
|
||||||
/// </summary>
|
|
||||||
internal static class ObjectFactoryInitPatch
|
|
||||||
{
|
|
||||||
#pragma warning disable 649
|
|
||||||
[ReflectedGetter(Name = "m_objectFactory", TypeName = "Sandbox.Game.Entities.MyEntityFactory, Sandbox.Game")]
|
|
||||||
private static Func<MyObjectFactory<MyEntityTypeAttribute, MyEntity>> EntityFactoryObjectFactory;
|
|
||||||
#pragma warning restore 649
|
|
||||||
|
|
||||||
internal static void ForceRegisterAssemblies()
|
|
||||||
{
|
|
||||||
var userAssemblies = MyPlugins.UserAssemblies;
|
|
||||||
// static MyEntities() called by MySandboxGame.ForceStaticCtor
|
|
||||||
RuntimeHelpers.RunClassConstructor(typeof(MyEntities).TypeHandle);
|
|
||||||
{
|
|
||||||
MyObjectFactory<MyEntityTypeAttribute, MyEntity> factory = EntityFactoryObjectFactory();
|
|
||||||
ObjectFactory_RegisterFromAssemblySafe(factory, typeof(MySandboxGame).Assembly); // calling assembly
|
|
||||||
ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.GameAssembly);
|
|
||||||
ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.SandboxAssembly);
|
|
||||||
//ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.UserAssembly);
|
|
||||||
if (userAssemblies != null)
|
|
||||||
{
|
|
||||||
foreach (var assembly in userAssemblies)
|
|
||||||
{
|
|
||||||
ObjectFactory_RegisterFromAssemblySafe(factory, assembly);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// static MyGuiManager():
|
|
||||||
// MyGuiControlsFactory.RegisterDescriptorsFromAssembly();
|
|
||||||
|
|
||||||
// static MyComponentTypeFactory() called by MyComponentContainer.Add
|
|
||||||
RuntimeHelpers.RunClassConstructor(typeof(MyComponentTypeFactory).TypeHandle);
|
|
||||||
{
|
|
||||||
ComponentTypeFactory_RegisterFromAssemblySafe(typeof(MyComponentContainer).Assembly); // calling assembly
|
|
||||||
ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.SandboxAssembly);
|
|
||||||
ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.GameAssembly);
|
|
||||||
ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.SandboxGameAssembly);
|
|
||||||
//ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.UserAssembly);
|
|
||||||
if (userAssemblies != null)
|
|
||||||
{
|
|
||||||
foreach (var assembly in userAssemblies)
|
|
||||||
{
|
|
||||||
ComponentTypeFactory_RegisterFromAssemblySafe(assembly);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MyEntities.Orchestrator = new MyParallelEntityUpdateOrchestrator();
|
|
||||||
|
|
||||||
// static MyObjectPoolManager()
|
|
||||||
// Render, so should be fine.
|
|
||||||
}
|
|
||||||
|
|
||||||
#region MyObjectFactory Adders
|
|
||||||
private static void ObjectFactory_RegisterDescriptorSafe<TAttribute, TCreatedObjectBase>(
|
|
||||||
MyObjectFactory<TAttribute, TCreatedObjectBase> factory, TAttribute descriptor, Type type) where TAttribute : MyFactoryTagAttribute where TCreatedObjectBase : class
|
|
||||||
{
|
|
||||||
if (factory.Attributes.TryGetValue(type, out _))
|
|
||||||
return;
|
|
||||||
if (descriptor.ObjectBuilderType != null && factory.TryGetProducedType(descriptor.ObjectBuilderType) != null)
|
|
||||||
return;
|
|
||||||
if (typeof(MyObjectBuilder_Base).IsAssignableFrom(descriptor.ProducedType) &&
|
|
||||||
factory.TryGetProducedType(descriptor.ProducedType) != null)
|
|
||||||
return;
|
|
||||||
factory.RegisterDescriptor(descriptor, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ObjectFactory_RegisterFromAssemblySafe<TAttribute, TCreatedObjectBase>(MyObjectFactory<TAttribute, TCreatedObjectBase> factory, Assembly assembly) where TAttribute : MyFactoryTagAttribute where TCreatedObjectBase : class
|
|
||||||
{
|
|
||||||
if (assembly == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
foreach (Type type in assembly.GetTypes())
|
|
||||||
{
|
|
||||||
foreach (TAttribute descriptor in type.GetCustomAttributes<TAttribute>())
|
|
||||||
{
|
|
||||||
ObjectFactory_RegisterDescriptorSafe(factory, descriptor, type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#region MyComponentTypeFactory Adders
|
|
||||||
|
|
||||||
[ReflectedGetter(Name = "m_idToType", Type = typeof(MyComponentTypeFactory))]
|
|
||||||
private static Func<Dictionary<MyStringId, Type>> ComponentTypeFactoryIdToType = null!;
|
|
||||||
[ReflectedGetter(Name = "m_typeToId", Type = typeof(MyComponentTypeFactory))]
|
|
||||||
private static Func<Dictionary<Type, MyStringId>> ComponentTypeFactoryTypeToId = null!;
|
|
||||||
[ReflectedGetter(Name = "m_typeToContainerComponentType", Type = typeof(MyComponentTypeFactory))]
|
|
||||||
private static Func<Dictionary<Type, Type>> ComponentTypeFactoryContainerComponentType = null!;
|
|
||||||
|
|
||||||
private static void ComponentTypeFactory_RegisterFromAssemblySafe(Assembly assembly)
|
|
||||||
{
|
|
||||||
if (assembly == null)
|
|
||||||
return;
|
|
||||||
foreach (Type type in assembly.GetTypes())
|
|
||||||
if (typeof(MyComponentBase).IsAssignableFrom(type))
|
|
||||||
{
|
|
||||||
ComponentTypeFactory_AddIdSafe(type, MyStringId.GetOrCompute(type.Name));
|
|
||||||
ComponentTypeFactory_RegisterComponentTypeAttributeSafe(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ComponentTypeFactory_RegisterComponentTypeAttributeSafe(Type type)
|
|
||||||
{
|
|
||||||
Type componentType = type.GetCustomAttribute<MyComponentTypeAttribute>(true)?.ComponentType;
|
|
||||||
if (componentType != null)
|
|
||||||
ComponentTypeFactoryContainerComponentType()[type] = componentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ComponentTypeFactory_AddIdSafe(Type type, MyStringId id)
|
|
||||||
{
|
|
||||||
ComponentTypeFactoryIdToType()[id] = type;
|
|
||||||
ComponentTypeFactoryTypeToId()[type] = id;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@@ -386,12 +386,8 @@ namespace Torch.Managers
|
|||||||
}
|
}
|
||||||
|
|
||||||
var harmonyAssembly = assemblies.FirstOrDefault(b => b.FullName?.StartsWith("0Harmony") == true);
|
var harmonyAssembly = assemblies.FirstOrDefault(b => b.FullName?.StartsWith("0Harmony") == true);
|
||||||
if (harmonyAssembly is { })
|
if (harmonyAssembly is { }) assemblies.Remove(harmonyAssembly);
|
||||||
{
|
|
||||||
_log.Warn($"Plugin {item.Manifest.Name} is using harmony library, logic collision between plugins could be encountered!");
|
|
||||||
assemblies.Remove(harmonyAssembly);
|
|
||||||
}
|
|
||||||
|
|
||||||
RegisterAllAssemblies(assemblies);
|
RegisterAllAssemblies(assemblies);
|
||||||
InstantiatePlugin(item.Manifest, assemblies);
|
InstantiatePlugin(item.Manifest, assemblies);
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
<PackageReference Include="protobuf-net" Version="3.1.26" />
|
<PackageReference Include="protobuf-net" Version="3.1.26" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
<PackageReference Include="Torch.SixLabors.ImageSharp" Version="1.0.0-beta6" />
|
<PackageReference Include="Torch.SixLabors.ImageSharp" Version="1.0.0-beta6" />
|
||||||
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.201.13">
|
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.202.48">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>compile</IncludeAssets>
|
<IncludeAssets>compile</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
@@ -132,14 +132,8 @@ namespace Torch
|
|||||||
|
|
||||||
GameStateChanged += (game, state) =>
|
GameStateChanged += (game, state) =>
|
||||||
{
|
{
|
||||||
if (state == TorchGameState.Created)
|
if (state == TorchGameState.Created)
|
||||||
{
|
|
||||||
// If the attached assemblies change (MySandboxGame.ctor => MySandboxGame.ParseArgs => MyPlugins.RegisterFromArgs)
|
|
||||||
// attach assemblies to object factories again.
|
|
||||||
ObjectFactoryInitPatch.ForceRegisterAssemblies();
|
|
||||||
// safe to commit here; all important static ctors have run
|
|
||||||
PatchManager.CommitInternal();
|
PatchManager.CommitInternal();
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var harmonyLog = LogManager.GetLogger("HarmonyX");
|
var harmonyLog = LogManager.GetLogger("HarmonyX");
|
||||||
@@ -259,7 +253,6 @@ namespace Torch
|
|||||||
public virtual void Init()
|
public virtual void Init()
|
||||||
{
|
{
|
||||||
Debug.Assert(!_init, "Torch instance is already initialized.");
|
Debug.Assert(!_init, "Torch instance is already initialized.");
|
||||||
ObjectFactoryInitPatch.ForceRegisterAssemblies();
|
|
||||||
VRageGame.SetupVersionInfo();
|
VRageGame.SetupVersionInfo();
|
||||||
|
|
||||||
Debug.Assert(MyPerGameSettings.BasicGameInfo.GameVersion != null, "MyPerGameSettings.BasicGameInfo.GameVersion != null");
|
Debug.Assert(MyPerGameSettings.BasicGameInfo.GameVersion != null, "MyPerGameSettings.BasicGameInfo.GameVersion != null");
|
||||||
|
@@ -102,9 +102,9 @@
|
|||||||
},
|
},
|
||||||
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
||||||
"type": "Direct",
|
"type": "Direct",
|
||||||
"requested": "[1.201.13, )",
|
"requested": "[1.202.48, )",
|
||||||
"resolved": "1.201.13",
|
"resolved": "1.202.48",
|
||||||
"contentHash": "FRXuNLENsz5jGQvL0QkogAGsxEJyUQlXhvWHBWfZiHCnCrAWMD60nEis6yt0xCQpazszfMtHonbxz72XMxnFoQ==",
|
"contentHash": "iP34MZD14Z/4HTg8rcKQlzJ+azM8/9HVScMJqdYejYbSDAiZzaZS6wlbPkDOKGhbLV2+iW7N5Ix/hCUATBYGuw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"protobuf-net": "1.0.0"
|
"protobuf-net": "1.0.0"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user