diff --git a/README.md b/README.md
index f553aaa..35ed4cd 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,5 @@ Torch is the successor to SE Server Extender and gives server admins the tools t
# Building
To build Torch you must first have a complete SE Dedicated installation somewhere. Before you open the solution, run the Setup batch file and enter the path of that installation's DedicatedServer64 folder. The script will make a symlink to that folder so the Torch solution can find the DLL references it needs.
-In both cases you will need to set the InstancePath in TorchConfig.xml to an existing dedicated server instance as Torch can't fully generate it on its own yet.
-
If you have a more enjoyable server experience because of Torch, please consider supporting us on Patreon.
-[](https://www.patreon.com/bePatron?u=847269)!
+[](https://www.patreon.com/bePatron?u=847269)
diff --git a/Torch.API/Torch.API.csproj b/Torch.API/Torch.API.csproj
index aa0dea8..028a6bb 100644
--- a/Torch.API/Torch.API.csproj
+++ b/Torch.API/Torch.API.csproj
@@ -39,8 +39,8 @@
..\GameBinaries\HavokWrapper.dll
False
-
- ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll
+
+ ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll
True
diff --git a/Torch.API/packages.config b/Torch.API/packages.config
index 5221eb5..fbd3f14 100644
--- a/Torch.API/packages.config
+++ b/Torch.API/packages.config
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/Torch.Server/Initializer.cs b/Torch.Server/Initializer.cs
index 8c1c4d4..e152373 100644
--- a/Torch.Server/Initializer.cs
+++ b/Torch.Server/Initializer.cs
@@ -62,16 +62,30 @@ quit";
var basePath = new FileInfo(typeof(Program).Assembly.Location).Directory.ToString();
var apiSource = Path.Combine(basePath, "DedicatedServer64", "steam_api64.dll");
var apiTarget = Path.Combine(basePath, "steam_api64.dll");
-
- if (!File.Exists(apiTarget) || File.GetLastWriteTime(apiTarget) < File.GetLastWriteTime(apiSource))
+
+ if (!File.Exists(apiTarget))
+ {
File.Copy(apiSource, apiTarget);
+ }
+ else if (File.GetLastWriteTime(apiTarget) < File.GetLastWriteTime(apiSource))
+ {
+ File.Delete(apiTarget);
+ File.Copy(apiSource, apiTarget);
+ }
var havokSource = Path.Combine(basePath, "DedicatedServer64", "Havok.dll");
var havokTarget = Path.Combine(basePath, "Havok.dll");
-
- if (!File.Exists(havokTarget) || File.GetLastWriteTime(havokTarget) < File.GetLastWriteTime(havokSource))
+
+ if (!File.Exists(havokTarget))
+ {
+ File.Copy(havokSource, havokTarget);
+ }
+ else if (File.GetLastWriteTime(havokTarget) < File.GetLastWriteTime(havokSource))
+ {
+ File.Delete(havokTarget);
File.Copy(havokSource, havokTarget);
-
+ }
+
_config = InitConfig();
if (!_config.Parse(args))
return false;
diff --git a/Torch.Server/Managers/RemoteAPIManager.cs b/Torch.Server/Managers/RemoteAPIManager.cs
new file mode 100644
index 0000000..4d7fe1c
--- /dev/null
+++ b/Torch.Server/Managers/RemoteAPIManager.cs
@@ -0,0 +1,28 @@
+using NLog;
+using Sandbox;
+using Torch.API;
+using Torch.Managers;
+using VRage.Dedicated.RemoteAPI;
+
+namespace Torch.Server.Managers
+{
+ public class RemoteAPIManager : Manager
+ {
+ ///
+ public RemoteAPIManager(ITorchBase torchInstance) : base(torchInstance)
+ {
+
+ }
+
+ ///
+ public override void Attach()
+ {
+ if (MySandboxGame.ConfigDedicated.RemoteApiEnabled && !string.IsNullOrEmpty(MySandboxGame.ConfigDedicated.RemoteSecurityKey))
+ {
+ var myRemoteServer = new MyRemoteServer(MySandboxGame.ConfigDedicated.RemoteApiPort, MySandboxGame.ConfigDedicated.RemoteSecurityKey);
+ LogManager.GetCurrentClassLogger().Info($"Remote API started on port {myRemoteServer.Port}");
+ }
+ base.Attach();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Torch.Server/Torch.Server.csproj b/Torch.Server/Torch.Server.csproj
index 798c6a8..2265911 100644
--- a/Torch.Server/Torch.Server.csproj
+++ b/Torch.Server/Torch.Server.csproj
@@ -90,8 +90,9 @@
..\GameBinaries\netstandard.dll
-
- ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll
+
+ ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll
+ True
..\packages\NLog.4.4.12\lib\net45\NLog.dll
@@ -251,6 +252,7 @@
+
diff --git a/Torch.Server/TorchServer.cs b/Torch.Server/TorchServer.cs
index 30c177d..7835f39 100644
--- a/Torch.Server/TorchServer.cs
+++ b/Torch.Server/TorchServer.cs
@@ -54,6 +54,7 @@ namespace Torch.Server
DedicatedInstance = new InstanceManager(this);
AddManager(DedicatedInstance);
AddManager(new EntityControlManager(this));
+ AddManager(new RemoteAPIManager(this));
Config = config ?? new TorchConfig();
var sessionManager = Managers.GetManager();
@@ -127,13 +128,6 @@ namespace Torch.Server
_hasRun = true;
Log.Info("Starting server.");
MySandboxGame.ConfigDedicated = DedicatedInstance.DedicatedConfig.Model;
- //Are you serious, Keen? This is going away until it stops hanging.
- //if (MySandboxGame.ConfigDedicated.RemoteApiEnabled && !string.IsNullOrEmpty(MySandboxGame.ConfigDedicated.RemoteSecurityKey))
- //{
- // var myRemoteServer = new MyRemoteServer(MySandboxGame.ConfigDedicated.RemoteApiPort, MySandboxGame.ConfigDedicated.RemoteSecurityKey);
- // Log.Info($"Remote API started on port {myRemoteServer.Port}");
- //}
- Log.Warn("Remote API is disabled because it hangs the server start process. Blame Keen.");
_uptime = Stopwatch.StartNew();
base.Start();
diff --git a/Torch.Server/packages.config b/Torch.Server/packages.config
index 24c621a..b1ff266 100644
--- a/Torch.Server/packages.config
+++ b/Torch.Server/packages.config
@@ -5,7 +5,7 @@
-
+
diff --git a/Torch/Collections/SortedView.cs b/Torch/Collections/SortedView.cs
index bfa5953..d76fa5e 100644
--- a/Torch/Collections/SortedView.cs
+++ b/Torch/Collections/SortedView.cs
@@ -4,12 +4,16 @@ using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
+using Havok;
+using NLog;
namespace Torch.Collections
{
public class SortedView: IReadOnlyCollection, INotifyCollectionChanged
{
+ private readonly Logger _log = LogManager.GetCurrentClassLogger();
private readonly MtObservableCollectionBase _backing;
private IComparer _comparer;
private readonly List _store;
@@ -106,9 +110,19 @@ namespace Torch.Collections
public void Refresh()
{
- _store.Clear();
- _store.AddRange(_backing);
- Sort();
+ //HACK, fix the multithreading
+ try
+ {
+ _store.Clear();
+ _store.AddRange(_backing);
+ Sort();
+ }
+ catch (IndexOutOfRangeException e)
+ {
+ _log.Error(e);
+ Thread.Sleep(10);
+ Refresh();
+ }
}
public void SetComparer(IComparer comparer, bool resort = true)