Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
22c4cfb039 | |||
5f0ffb6f9a | |||
1b2a989441 | |||
![]() |
83dfc7152f | ||
d7e5f53e4f | |||
9b08b39a1f | |||
![]() |
8011f9eed7 |
@@ -22,7 +22,7 @@
|
||||
<PackageReference Include="NuGet.Commands" Version="6.6.1" />
|
||||
<PackageReference Include="NuGet.DependencyResolver.Core" Version="6.6.1" />
|
||||
<PackageReference Include="SemanticVersioning" Version="2.0.2" />
|
||||
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.202.124">
|
||||
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.203.22.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>compile</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
@@ -54,9 +54,9 @@
|
||||
},
|
||||
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.202.124, )",
|
||||
"resolved": "1.202.124",
|
||||
"contentHash": "xw8mbJI2WwZcfWvgMf6c6E3agcQ/IQVVdnKZljszQBKq0cjhJG06AoonM+MI74CrYMJxf+wnA+4bzCt4mxy/Qg==",
|
||||
"requested": "[1.203.22.3, )",
|
||||
"resolved": "1.203.22.3",
|
||||
"contentHash": "U7awzB6nGNN3tyZpeWQQjF4MHxJ4CDbvXEuJDkddLa2ellh2SYCV4V3UqukMuVzlrUSC71ITFwDVZZ+uYZYVtw==",
|
||||
"dependencies": {
|
||||
"protobuf-net": "1.0.0"
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<repository type="git" url="https://github.com/PveTeam/Torch" />
|
||||
<dependencies>
|
||||
<group targetFramework="net7.0-windows7.0">
|
||||
<dependency id="SpaceEngineersDedicated.ReferenceAssemblies" version="1.202.120" />
|
||||
<dependency id="SpaceEngineersDedicated.ReferenceAssemblies" version="1.203.22.3" />
|
||||
<dependency id="Torch.Server" version="torchVersion" />
|
||||
</group>
|
||||
</dependencies>
|
||||
|
@@ -30,9 +30,8 @@ namespace Torch.Server
|
||||
private bool _init;
|
||||
private const string TOOL_DIR = "tool";
|
||||
private const string TOOL_ZIP = "temp.zip";
|
||||
private static readonly string TOOL_EXE = "DepotDownloader.exe";
|
||||
private const string TOOL_ARGS = "-app 298740 -depot {1} -dir \"{0}\" -manifest {2}";
|
||||
private static readonly int[] Depots = { 298741, 1004 };
|
||||
private static readonly string TOOL_EXE = "steamcmd.exe";
|
||||
private const string TOOL_ARGS = "+force_install_dir \"{0}\" +login anonymous +app_update 298740 +quit";
|
||||
private TorchServer _server;
|
||||
|
||||
internal Persistent<TorchConfig> ConfigPersistent { get; }
|
||||
@@ -131,7 +130,7 @@ namespace Torch.Server
|
||||
|
||||
public static async Task RunSteamCmdAsync(IConfiguration configuration)
|
||||
{
|
||||
var log = LogManager.GetLogger("SteamTool");
|
||||
var log = LogManager.GetLogger("SteamCMD");
|
||||
|
||||
var path = configuration.GetValue<string>("steamToolPath") ?? ApplicationContext.Current.TorchDirectory
|
||||
.CreateSubdirectory(TOOL_DIR).FullName;
|
||||
@@ -141,49 +140,41 @@ namespace Torch.Server
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
var steamCmdExePath = Path.Combine(path, TOOL_EXE);
|
||||
if (!File.Exists(steamCmdExePath))
|
||||
var toolExe = Path.Combine(path, TOOL_EXE);
|
||||
if (!File.Exists(toolExe))
|
||||
{
|
||||
try
|
||||
{
|
||||
log.Info("Downloading Steam Tool.");
|
||||
log.Info("Downloading SteamCMD.");
|
||||
using (var client = new HttpClient())
|
||||
await using (var file = File.Create(TOOL_ZIP))
|
||||
await using (var stream = await client.GetStreamAsync("https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_2.4.7/depotdownloader-2.4.7.zip"))
|
||||
await using (var stream = await client.GetStreamAsync("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip"))
|
||||
await stream.CopyToAsync(file);
|
||||
|
||||
ZipFile.ExtractToDirectory(TOOL_ZIP, path);
|
||||
File.Delete(TOOL_ZIP);
|
||||
log.Info("Steam Tool downloaded successfully!");
|
||||
log.Info("SteamCMD downloaded successfully!");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.Error(e, "Failed to download Steam Tool, unable to update the DS.");
|
||||
log.Error(e, "Failed to download SteamCMD, unable to update the DS.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log.Info("Checking for DS updates.");
|
||||
foreach (var depot in Depots)
|
||||
var steamCmdProc = new ProcessStartInfo(toolExe)
|
||||
{
|
||||
await DownloadDepot(depot);
|
||||
}
|
||||
Arguments = string.Format(TOOL_ARGS, configuration.GetValue("gamePath", "../")),
|
||||
WorkingDirectory = path,
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
var cmd = Process.Start(steamCmdProc)!;
|
||||
|
||||
async Task DownloadDepot(int depotId)
|
||||
while (!cmd.HasExited)
|
||||
{
|
||||
var steamCmdProc = new ProcessStartInfo(steamCmdExePath)
|
||||
{
|
||||
Arguments = string.Format(TOOL_ARGS, configuration.GetValue("gamePath", "../"), depotId, "14195799952783859"),
|
||||
WorkingDirectory = path,
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
var cmd = Process.Start(steamCmdProc)!;
|
||||
|
||||
while (!cmd.HasExited)
|
||||
{
|
||||
if (await cmd.StandardOutput.ReadLineAsync() is { } line)
|
||||
log.Info(line);
|
||||
}
|
||||
if (await cmd.StandardOutput.ReadLineAsync() is { } line)
|
||||
log.Info(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ using VRage.FileSystem;
|
||||
using VRage.Game;
|
||||
using VRage.Game.ObjectBuilder;
|
||||
using VRage.ObjectBuilders;
|
||||
using VRage.ObjectBuilders.Private;
|
||||
using VRage.Plugins;
|
||||
|
||||
namespace Torch.Server.Managers
|
||||
@@ -363,10 +364,10 @@ namespace Torch.Server.Managers
|
||||
public void SaveSandbox()
|
||||
{
|
||||
using (var f = File.Open(_checkpointPath, FileMode.Create))
|
||||
MyObjectBuilderSerializer.SerializeXML(f, Checkpoint);
|
||||
MyObjectBuilderSerializerKeen.SerializeXML(f, Checkpoint);
|
||||
|
||||
using (var f = File.Open(_worldConfigPath, FileMode.Create))
|
||||
MyObjectBuilderSerializer.SerializeXML(f, WorldConfiguration);
|
||||
MyObjectBuilderSerializerKeen.SerializeXML(f, WorldConfiguration);
|
||||
}
|
||||
|
||||
public void LoadSandbox()
|
||||
|
@@ -50,7 +50,7 @@
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
<PackageReference Include="System.Management" Version="7.0.2" />
|
||||
<PackageReference Include="nulastudio.NetCoreBeauty" Version="1.2.9.5" />
|
||||
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.202.124">
|
||||
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.203.22.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>compile</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
@@ -69,6 +69,14 @@ namespace Torch.Server
|
||||
|
||||
_simUpdateTimer.Elapsed += SimUpdateElapsed;
|
||||
_simUpdateTimer.Start();
|
||||
|
||||
Console.CancelKeyPress += (_, _) =>
|
||||
{
|
||||
if (State == ServerState.Running)
|
||||
Stop();
|
||||
|
||||
Environment.Exit(0);
|
||||
};
|
||||
}
|
||||
|
||||
private void SimUpdateElapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
@@ -239,9 +247,14 @@ namespace Torch.Server
|
||||
StopInternal();
|
||||
LogManager.Flush();
|
||||
|
||||
if (
|
||||
#if DEBUG
|
||||
Environment.Exit(0);
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
true ||
|
||||
#endif
|
||||
ApplicationContext.Current.IsService
|
||||
)
|
||||
Environment.Exit(0);
|
||||
|
||||
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
||||
|
||||
|
@@ -116,7 +116,7 @@ namespace Torch.Server
|
||||
if (_server?.State == ServerState.Running)
|
||||
_server.Stop();
|
||||
|
||||
Process.GetCurrentProcess().Kill();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -113,9 +113,9 @@
|
||||
},
|
||||
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.202.124, )",
|
||||
"resolved": "1.202.124",
|
||||
"contentHash": "xw8mbJI2WwZcfWvgMf6c6E3agcQ/IQVVdnKZljszQBKq0cjhJG06AoonM+MI74CrYMJxf+wnA+4bzCt4mxy/Qg==",
|
||||
"requested": "[1.203.22.3, )",
|
||||
"resolved": "1.203.22.3",
|
||||
"contentHash": "U7awzB6nGNN3tyZpeWQQjF4MHxJ4CDbvXEuJDkddLa2ellh2SYCV4V3UqukMuVzlrUSC71ITFwDVZZ+uYZYVtw==",
|
||||
"dependencies": {
|
||||
"protobuf-net": "1.0.0"
|
||||
}
|
||||
@@ -153,8 +153,8 @@
|
||||
},
|
||||
"HarmonyX": {
|
||||
"type": "Transitive",
|
||||
"resolved": "2.10.2-prerelease.5",
|
||||
"contentHash": "0ae0orZFSOMusmKRWfjcxeJY1rz04GMlTw4FRusljsT5UVZyToIBVZA1F8NVfD+zxCZZ++iNQth5EN0qsKtnLQ==",
|
||||
"resolved": "2.10.2-prerelease.6",
|
||||
"contentHash": "CPCUR/t5AQ5DDs40bTJ5OwUVTCoZONaJGbWKKjAOwg7c7Ct4KEbfybH6T+KvRGVjf5eN1oyGY5BN7EfWxUh9Xg==",
|
||||
"dependencies": {
|
||||
"MonoMod.RuntimeDetour": "25.0.0"
|
||||
}
|
||||
@@ -574,7 +574,7 @@
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"ControlzEx": "[6.0.0, )",
|
||||
"HarmonyX": "[2.10.2-prerelease.5, )",
|
||||
"HarmonyX": "[2.10.2-prerelease.6, )",
|
||||
"MahApps.Metro": "[2.4.9, )",
|
||||
"Microsoft.CodeAnalysis.CSharp": "[4.6.0, )",
|
||||
"Microsoft.CodeAnalysis.Common": "[4.6.0, )",
|
||||
|
@@ -27,6 +27,7 @@ using VRage.Game.ModAPI;
|
||||
using VRage.Groups;
|
||||
using VRage.ModAPI;
|
||||
using VRage.ObjectBuilders;
|
||||
using VRage.ObjectBuilders.Private;
|
||||
using VRage.Sync;
|
||||
using VRageMath;
|
||||
|
||||
@@ -45,14 +46,14 @@ namespace Torch.Managers
|
||||
{
|
||||
var ob = grid.GetObjectBuilder(true);
|
||||
using (var f = File.Open(path, FileMode.CreateNew))
|
||||
MyObjectBuilderSerializer.SerializeXML(f, ob);
|
||||
MyObjectBuilderSerializerKeen.SerializeXML(f, ob);
|
||||
}
|
||||
|
||||
public void ImportGrid(string path, Vector3D position)
|
||||
{
|
||||
MyObjectBuilder_EntityBase gridOb;
|
||||
using (var f = File.OpenRead(path))
|
||||
MyObjectBuilderSerializer.DeserializeXML(f, out gridOb);
|
||||
MyObjectBuilderSerializerKeen.DeserializeXML(f, out gridOb);
|
||||
|
||||
var grid = MyEntities.CreateFromObjectBuilderParallel(gridOb);
|
||||
grid.PositionComp.SetPosition(position);
|
||||
|
@@ -82,7 +82,7 @@ public class ScriptCompilationManager : Manager
|
||||
TerminationReasonSetter(block, MyProgrammableBlock.ScriptTerminationReason.None);
|
||||
|
||||
var component = ScriptComponentGetter(block);
|
||||
component.NextUpdate = UpdateType.None;
|
||||
component.UpdateFrequency = UpdateFrequency.None;
|
||||
component.NeedsUpdate = MyEntityUpdateEnum.NONE;
|
||||
|
||||
try
|
||||
|
@@ -79,6 +79,9 @@ namespace Torch.Patches
|
||||
[ReflectedSetter(Name = "m_enabled")]
|
||||
private static Action<MyLog, bool> _enabledSetter = null!;
|
||||
|
||||
[ReflectedMethod(Type = typeof(MyLog), Name = "LogFlag")]
|
||||
private static Func<MyLog, LoggingOptions, bool> _logFlag = null!;
|
||||
|
||||
private static int GetIndentByCurrentThread()
|
||||
{
|
||||
using var l = _lockGetter(MyLog.Default).AcquireExclusiveUsing();
|
||||
@@ -122,7 +125,7 @@ namespace Torch.Patches
|
||||
}
|
||||
private static bool PrefixWriteLineOptions(MyLog __instance, string message, LoggingOptions option)
|
||||
{
|
||||
if (__instance.LogEnabled && __instance.LogFlag(option) && _log.IsDebugEnabled)
|
||||
if (__instance.LogEnabled && _logFlag(__instance, option) && _log.IsDebugEnabled)
|
||||
_log.Info($"{string.Empty.PadRight(3 * GetIndentByCurrentThread(), ' ')}{message}");
|
||||
return false;
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ControlzEx" Version="6.0.0" />
|
||||
<PackageReference Include="HarmonyX" Version="2.10.2-prerelease.5" />
|
||||
<PackageReference Include="HarmonyX" Version="2.10.2-prerelease.6" />
|
||||
<PackageReference Include="InfoOf.Fody" Version="2.1.1" PrivateAssets="all" />
|
||||
<PackageReference Include="MahApps.Metro" Version="2.4.9" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.6.0" />
|
||||
@@ -35,7 +35,7 @@
|
||||
<PackageReference Include="protobuf-net" Version="3.2.26" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
<PackageReference Include="Torch.SixLabors.ImageSharp" Version="1.0.0-beta6" />
|
||||
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.202.124">
|
||||
<PackageReference Include="SpaceEngineersDedicated.ReferenceAssemblies" Version="1.203.22.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>compile</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
@@ -372,10 +372,10 @@ namespace Torch
|
||||
/// <inheritdoc />
|
||||
public virtual void Stop()
|
||||
{
|
||||
LogManager.Flush();
|
||||
Game.SignalStop();
|
||||
if (!Game.WaitFor(VRageGame.GameState.Stopped))
|
||||
if (!Game.WaitFor(VRageGame.GameState.Stopped, TimeSpan.FromSeconds(Config.TickTimeout)))
|
||||
Log.Warn("Failed to wait for the game to be stopped");
|
||||
LogManager.Flush();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@@ -14,9 +14,9 @@
|
||||
},
|
||||
"HarmonyX": {
|
||||
"type": "Direct",
|
||||
"requested": "[2.10.2-prerelease.5, )",
|
||||
"resolved": "2.10.2-prerelease.5",
|
||||
"contentHash": "0ae0orZFSOMusmKRWfjcxeJY1rz04GMlTw4FRusljsT5UVZyToIBVZA1F8NVfD+zxCZZ++iNQth5EN0qsKtnLQ==",
|
||||
"requested": "[2.10.2-prerelease.6, )",
|
||||
"resolved": "2.10.2-prerelease.6",
|
||||
"contentHash": "CPCUR/t5AQ5DDs40bTJ5OwUVTCoZONaJGbWKKjAOwg7c7Ct4KEbfybH6T+KvRGVjf5eN1oyGY5BN7EfWxUh9Xg==",
|
||||
"dependencies": {
|
||||
"MonoMod.RuntimeDetour": "25.0.0"
|
||||
}
|
||||
@@ -100,9 +100,9 @@
|
||||
},
|
||||
"SpaceEngineersDedicated.ReferenceAssemblies": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.202.124, )",
|
||||
"resolved": "1.202.124",
|
||||
"contentHash": "xw8mbJI2WwZcfWvgMf6c6E3agcQ/IQVVdnKZljszQBKq0cjhJG06AoonM+MI74CrYMJxf+wnA+4bzCt4mxy/Qg==",
|
||||
"requested": "[1.203.22.3, )",
|
||||
"resolved": "1.203.22.3",
|
||||
"contentHash": "U7awzB6nGNN3tyZpeWQQjF4MHxJ4CDbvXEuJDkddLa2ellh2SYCV4V3UqukMuVzlrUSC71ITFwDVZZ+uYZYVtw==",
|
||||
"dependencies": {
|
||||
"protobuf-net": "1.0.0"
|
||||
}
|
||||
|
Reference in New Issue
Block a user