Merge branch 'master' into Patron

This commit is contained in:
John Gross
2019-07-06 17:00:22 -07:00
12 changed files with 102 additions and 26 deletions

View File

@@ -21,7 +21,5 @@ Torch is the successor to SE Server Extender and gives server admins the tools t
# Building # 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. 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. If you have a more enjoyable server experience because of Torch, please consider supporting us on Patreon.
[![Patreon](http://i.imgur.com/VzzIMgn.png)](https://www.patreon.com/bePatron?u=847269)! [![Patreon](http://i.imgur.com/VzzIMgn.png)](https://www.patreon.com/bePatron?u=847269)

View File

@@ -39,8 +39,8 @@
<HintPath>..\GameBinaries\HavokWrapper.dll</HintPath> <HintPath>..\GameBinaries\HavokWrapper.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Mono.TextTransform" version="1.0.0" targetFramework="net461" /> <package id="Mono.TextTransform" version="1.0.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" /> <package id="Newtonsoft.Json" version="12.0.2" targetFramework="net461" />
<package id="NLog" version="4.4.12" targetFramework="net461" /> <package id="NLog" version="4.4.12" targetFramework="net461" />
</packages> </packages>

View File

@@ -71,16 +71,30 @@ quit";
var basePath = new FileInfo(typeof(Program).Assembly.Location).Directory.ToString(); var basePath = new FileInfo(typeof(Program).Assembly.Location).Directory.ToString();
var apiSource = Path.Combine(basePath, "DedicatedServer64", "steam_api64.dll"); var apiSource = Path.Combine(basePath, "DedicatedServer64", "steam_api64.dll");
var apiTarget = Path.Combine(basePath, "steam_api64.dll"); var apiTarget = Path.Combine(basePath, "steam_api64.dll");
if (!File.Exists(apiTarget)) if (!File.Exists(apiTarget))
{
File.Copy(apiSource, 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 havokSource = Path.Combine(basePath, "DedicatedServer64", "Havok.dll");
var havokTarget = Path.Combine(basePath, "Havok.dll"); var havokTarget = Path.Combine(basePath, "Havok.dll");
if (!File.Exists(havokTarget)) if (!File.Exists(havokTarget))
{
File.Copy(havokSource, havokTarget);
}
else if (File.GetLastWriteTime(havokTarget) < File.GetLastWriteTime(havokSource))
{
File.Delete(havokTarget);
File.Copy(havokSource, havokTarget); File.Copy(havokSource, havokTarget);
}
_config = InitConfig(); _config = InitConfig();
if (!_config.Parse(args)) if (!_config.Parse(args))
return false; return false;

View File

@@ -219,7 +219,12 @@ namespace Torch.Server.Managers
_log.Info($"Connection attempt by {steamId} from {ip}"); _log.Info($"Connection attempt by {steamId} from {ip}");
if (Torch.CurrentSession.KeenSession.OnlineMode == MyOnlineModeEnum.OFFLINE && if (Players.ContainsKey(steamId))
{
_log.Warn($"Player {steamId} already has already joined!");
UserRejected(steamId, JoinResult.AlreadyJoined);
}
else if (Torch.CurrentSession.KeenSession.OnlineMode == MyOnlineModeEnum.OFFLINE &&
promoteLevel < MyPromoteLevel.Admin) promoteLevel < MyPromoteLevel.Admin)
{ {
_log.Warn($"Rejecting user {steamId}, world is set to offline and user is not admin."); _log.Warn($"Rejecting user {steamId}, world is set to offline and user is not admin.");
@@ -337,4 +342,4 @@ namespace Torch.Server.Managers
#endregion #endregion
} }
} }

View File

@@ -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
{
/// <inheritdoc />
public RemoteAPIManager(ITorchBase torchInstance) : base(torchInstance)
{
}
/// <inheritdoc />
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();
}
}
}

View File

@@ -34,7 +34,7 @@ namespace Torch.Server
//HACK for block skins update //HACK for block skins update
var badDlls = new[] var badDlls = new[]
{ {
"System.Security.Principal.Windows.dll" "System.Security.Principal.Windows.dll",
}; };
try try
@@ -45,9 +45,11 @@ namespace Torch.Server
File.Delete(file); File.Delete(file);
} }
} }
catch catch (Exception e)
{ {
LogManager.GetCurrentClassLogger().Error($"Error updating. Please delete the following files from the Torch root folder manually:\r\n{string.Join("\r\n", badDlls)}"); var log = LogManager.GetCurrentClassLogger();
log.Error($"Error updating. Please delete the following files from the Torch root folder manually:\r\n{string.Join("\r\n", badDlls)}");
log.Error(e);
return; return;
} }
@@ -71,4 +73,4 @@ namespace Torch.Server
initializer.Run(); initializer.Run();
} }
} }
} }

View File

@@ -90,8 +90,9 @@
<Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"> <Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<HintPath>..\GameBinaries\netstandard.dll</HintPath> <HintPath>..\GameBinaries\netstandard.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net45\NLog.dll</HintPath> <HintPath>..\packages\NLog.4.4.12\lib\net45\NLog.dll</HintPath>
@@ -251,6 +252,7 @@
<Compile Include="Managers\InstanceManager.cs" /> <Compile Include="Managers\InstanceManager.cs" />
<Compile Include="Managers\MultiplayerManagerDedicatedEventShim.cs" /> <Compile Include="Managers\MultiplayerManagerDedicatedEventShim.cs" />
<Compile Include="Managers\MultiplayerManagerDedicatedPatchShim.cs" /> <Compile Include="Managers\MultiplayerManagerDedicatedPatchShim.cs" />
<Compile Include="Managers\RemoteAPIManager.cs" />
<Compile Include="NativeMethods.cs" /> <Compile Include="NativeMethods.cs" />
<Compile Include="Initializer.cs" /> <Compile Include="Initializer.cs" />
<Compile Include="Patches\PromotePatch.cs" /> <Compile Include="Patches\PromotePatch.cs" />

View File

@@ -21,9 +21,38 @@ namespace Torch.Server
[Arg("instancename", "The name of the Torch instance.")] [Arg("instancename", "The name of the Torch instance.")]
public string InstanceName { get; set; } public string InstanceName { get; set; }
private string _instancePath;
/// <inheritdoc /> /// <inheritdoc />
[Arg("instancepath", "Server data folder where saves and mods are stored.")] [Arg("instancepath", "Server data folder where saves and mods are stored.")]
public string InstancePath { get; set; } public string InstancePath
{
get => _instancePath;
set
{
if(String.IsNullOrEmpty(value))
{
_instancePath = value;
return;
}
try
{
if(value.Contains("\""))
throw new InvalidOperationException();
var s = Path.GetFullPath(value);
Console.WriteLine(s); //prevent compiler opitmization - just in case
}
catch (Exception ex)
{
_log.Error(ex, "Invalid path assigned to InstancePath! Please report this immediately! Value: " + value);
//throw;
}
_instancePath = value;
}
}
/// <inheritdoc /> /// <inheritdoc />
[XmlIgnore, Arg("noupdate", "Disable automatically downloading game and plugin updates.")] [XmlIgnore, Arg("noupdate", "Disable automatically downloading game and plugin updates.")]

View File

@@ -54,6 +54,7 @@ namespace Torch.Server
DedicatedInstance = new InstanceManager(this); DedicatedInstance = new InstanceManager(this);
AddManager(DedicatedInstance); AddManager(DedicatedInstance);
AddManager(new EntityControlManager(this)); AddManager(new EntityControlManager(this));
AddManager(new RemoteAPIManager(this));
Config = config ?? new TorchConfig(); Config = config ?? new TorchConfig();
var sessionManager = Managers.GetManager<ITorchSessionManager>(); var sessionManager = Managers.GetManager<ITorchSessionManager>();
@@ -127,13 +128,6 @@ namespace Torch.Server
_hasRun = true; _hasRun = true;
Log.Info("Starting server."); Log.Info("Starting server.");
MySandboxGame.ConfigDedicated = DedicatedInstance.DedicatedConfig.Model; 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(); _uptime = Stopwatch.StartNew();
base.Start(); base.Start();

View File

@@ -5,7 +5,7 @@
<package id="Markdown.Xaml" version="1.0.0" targetFramework="net461" /> <package id="Markdown.Xaml" version="1.0.0" targetFramework="net461" />
<package id="Microsoft.Win32.Registry" version="4.4.0" targetFramework="net461" /> <package id="Microsoft.Win32.Registry" version="4.4.0" targetFramework="net461" />
<package id="Mono.TextTransform" version="1.0.0" targetFramework="net461" /> <package id="Mono.TextTransform" version="1.0.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" /> <package id="Newtonsoft.Json" version="12.0.2" targetFramework="net461" />
<package id="NLog" version="4.4.12" targetFramework="net461" /> <package id="NLog" version="4.4.12" targetFramework="net461" />
<package id="protobuf-net" version="2.4.0" targetFramework="net461" /> <package id="protobuf-net" version="2.4.0" targetFramework="net461" />
<package id="SteamKit2" version="2.1.0" targetFramework="net461" /> <package id="SteamKit2" version="2.1.0" targetFramework="net461" />

View File

@@ -6,12 +6,16 @@ using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Havok;
using NLog;
namespace Torch.Collections namespace Torch.Collections
{ {
public class SortedView<T>: IReadOnlyCollection<T>, INotifyCollectionChanged, INotifyPropertyChanged public class SortedView<T>: IReadOnlyCollection<T>, INotifyCollectionChanged, INotifyPropertyChanged
{ {
private readonly Logger _log = LogManager.GetCurrentClassLogger();
private readonly MtObservableCollectionBase<T> _backing; private readonly MtObservableCollectionBase<T> _backing;
private IComparer<T> _comparer; private IComparer<T> _comparer;
private readonly List<T> _store; private readonly List<T> _store;