Compare commits

..

4 Commits

Author SHA1 Message Date
zznty
67bb3fd00c update autoupdate default config
All checks were successful
Release / Get Version (push) Successful in 6s
Release / Build and Publish Package (push) Successful in 8m10s
Release / Build and Publish Nuget (push) Successful in 2m1s
2024-11-01 07:15:49 +07:00
90546a78c2 Update README.md
Some checks failed
Release / Build and Publish Nuget (push) Has been cancelled
Release / Build and Publish Package (push) Has been cancelled
Release / Get Version (push) Has been cancelled
2024-10-27 13:54:31 +00:00
zznty
d301955609 move ui lifetime to a manager for better lifetime control
All checks were successful
Release / Get Version (push) Successful in 4s
Release / Build and Publish Nuget (push) Successful in 2m21s
Release / Build and Publish Package (push) Successful in 2m58s
2024-10-23 16:52:10 +07:00
zznty
264daf7515 fix torch not restarting when start occurs second time 2024-10-23 16:51:41 +07:00
7 changed files with 58 additions and 27 deletions

View File

@@ -11,7 +11,7 @@ Torch is the successor to SE Server Extender and gives server admins the tools t
* Extensible using the Torch plugin system * Extensible using the Torch plugin system
### Fork Difference ### Fork Difference
* .NET 6.0 runtime * .NET 8.0 runtime
* Optimized in-game scripts (also newer compiler & language versions) * Optimized in-game scripts (also newer compiler & language versions)
* Better configuration via cli arguments, environment variables or xml config * Better configuration via cli arguments, environment variables or xml config
* Designed to run multiple instance from same install directory without having you to waste disk space * Designed to run multiple instance from same install directory without having you to waste disk space
@@ -19,7 +19,9 @@ Torch is the successor to SE Server Extender and gives server admins the tools t
### Discord ### Discord
If you have any questions or issues please join our [discord](https://discord.gg/UyYFSe3TyQ) If you have any questions or issues please join our discord
[![](https://dcbadge.vercel.app/api/server/VAb2zgXHAN)](https://discord.gg/VAb2zgXHAN)
### Installation ### Installation
@@ -30,7 +32,7 @@ If you have any questions or issues please join our [discord](https://discord.gg
# Building # Building
As a regular dotnet project with cli by running `dotnet build Torch.Server/Torch.Server.csproj`, with VS 2022 or higher, with JB Rider or Fleet. As a regular dotnet project with cli by running `dotnet build Torch.Server/Torch.Server.csproj`, with VS 2022 or higher or JB Rider.
If you have a more enjoyable server experience because of Torch, please consider supporting us on Patreon. (https://www.patreon.com/TorchSE) If you have a more enjoyable server experience because of Torch, please consider supporting us on Patreon. (https://www.patreon.com/TorchSE)

View File

@@ -94,27 +94,11 @@ namespace Torch.Server
_server.Init(); _server.Init();
var uiThread = new Thread(() => if (!Config.Autostart && !Config.TempAutostart) return;
{
var ui = new TorchUI(_server);
SynchronizationContext.SetSynchronizationContext(
new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
ui.ShowDialog();
});
uiThread.SetApartmentState(ApartmentState.STA);
uiThread.Start();
if (Config.Autostart || Config.TempAutostart)
{
Config.TempAutostart = false; Config.TempAutostart = false;
_server.Start(); _server.Start();
} }
uiThread.Join();
}
} }
public static async Task RunSteamCmdAsync(IConfiguration configuration) public static async Task RunSteamCmdAsync(IConfiguration configuration)

View File

@@ -0,0 +1,37 @@
using System.Threading;
using System.Windows.Threading;
using JetBrains.Annotations;
using Torch.Managers;
namespace Torch.Server.Managers;
public class UiManager(TorchServer torchInstance) : Manager(torchInstance)
{
[CanBeNull] private Thread _uiThread;
[CanBeNull] private Dispatcher _dispatcher;
public override void Attach()
{
_uiThread = new Thread(() =>
{
var ui = new TorchUI(torchInstance);
_dispatcher = Dispatcher.CurrentDispatcher;
SynchronizationContext.SetSynchronizationContext(
new DispatcherSynchronizationContext(_dispatcher));
ui.ShowDialog();
});
_uiThread.SetApartmentState(ApartmentState.STA);
_uiThread.Start();
}
public override void Detach()
{
_dispatcher?.InvokeShutdown();
if (Thread.CurrentThread != _uiThread)
_uiThread?.Join();
}
}

View File

@@ -114,8 +114,8 @@ public class TorchConfig : ViewModel, ITorchConfig
public UpdateSource UpdateSource { get; set; } = new() public UpdateSource UpdateSource { get; set; } = new()
{ {
Repository = "PveTeam/Torch", Repository = "PvE/Torch",
Url = "https://api.github.com", Url = "https://git.zznty.ru/api/v1",
SourceType = UpdateSourceType.Github SourceType = UpdateSourceType.Github
}; };

View File

@@ -56,6 +56,8 @@ namespace Torch.Server
if (config.EntityManagerEnabled) if (config.EntityManagerEnabled)
AddManager(new EntityControlManager(this)); AddManager(new EntityControlManager(this));
AddManager(new RemoteAPIManager(this)); AddManager(new RemoteAPIManager(this));
if (!ApplicationContext.Current.IsService && !config.NoGui)
AddManager(new UiManager(this));
var sessionManager = Managers.GetManager<ITorchSessionManager>(); var sessionManager = Managers.GetManager<ITorchSessionManager>();
sessionManager.AddFactory(_ => new MultiplayerManagerDedicated(this)); sessionManager.AddFactory(_ => new MultiplayerManagerDedicated(this));
@@ -185,7 +187,7 @@ namespace Torch.Server
if (IsRunning || HasRun) if (IsRunning || HasRun)
{ {
Restart(); Restart(false);
return; return;
} }

View File

@@ -65,7 +65,8 @@ internal static class AssemblyRewriter
{ {
using var assembly = AssemblyDefinition.ReadAssembly(inputStream, new() using var assembly = AssemblyDefinition.ReadAssembly(inputStream, new()
{ {
AssemblyResolver = resolver AssemblyResolver = resolver,
ReadSymbols = true
}); });
foreach (var fieldDefinition in FindAllToRewrite(assembly.MainModule)) foreach (var fieldDefinition in FindAllToRewrite(assembly.MainModule))
{ {

View File

@@ -293,15 +293,20 @@ namespace Torch
{ {
} }
private bool _disposed = false;
/// <inheritdoc /> /// <inheritdoc />
public virtual void Destroy() public virtual void Destroy()
{ {
if (_disposed) return;
Game.SignalDestroy(); Game.SignalDestroy();
if (!Game.WaitFor(VRageGame.GameState.Destroyed)) if (!Game.WaitFor(VRageGame.GameState.Destroyed))
Log.Warn("Failed to wait for the game to be destroyed"); Log.Warn("Failed to wait for the game to be destroyed");
Game = null; Game = null;
Managers.Detach(); Managers.Detach();
_disposed = true;
} }
#endregion #endregion