@@ -9,6 +9,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Havok;
|
||||
using NLog;
|
||||
using Sandbox;
|
||||
using Sandbox.Engine.Networking;
|
||||
using Sandbox.Engine.Utils;
|
||||
using Sandbox.Game;
|
||||
@@ -56,17 +57,19 @@ namespace Torch.Server.Managers
|
||||
//Initializes saves path. Why this isn't in Init() we may never know.
|
||||
MyFileSystem.InitUserSpecific(null);
|
||||
|
||||
var configPath = Path.Combine(path, CONFIG_NAME);
|
||||
if (!File.Exists(configPath))
|
||||
{
|
||||
Log.Error($"Failed to load dedicated config at {path}");
|
||||
return;
|
||||
}
|
||||
// why?....
|
||||
// var configPath = Path.Combine(path, CONFIG_NAME);
|
||||
// if (!File.Exists(configPath))
|
||||
// {
|
||||
// Log.Error($"Failed to load dedicated config at {path}");
|
||||
// return;
|
||||
// }
|
||||
|
||||
var config = new MyConfigDedicated<MyObjectBuilder_SessionSettings>(configPath);
|
||||
config.Load(configPath);
|
||||
|
||||
DedicatedConfig = new ConfigDedicatedViewModel(config);
|
||||
// var config = new MyConfigDedicated<MyObjectBuilder_SessionSettings>(configPath);
|
||||
// config.Load(configPath);
|
||||
|
||||
DedicatedConfig = new ConfigDedicatedViewModel((MyConfigDedicated<MyObjectBuilder_SessionSettings>) MySandboxGame.ConfigDedicated);
|
||||
|
||||
var worldFolders = Directory.EnumerateDirectories(Path.Combine(Torch.Config.InstancePath, "Saves"));
|
||||
|
||||
|
@@ -134,13 +134,21 @@ namespace Torch.Server.Managers
|
||||
public override void Attach()
|
||||
{
|
||||
base.Attach();
|
||||
_gameServerValidateAuthTicketReplacer = _gameServerValidateAuthTicketFactory.Invoke();
|
||||
_gameServerUserGroupStatusReplacer = _gameServerUserGroupStatusFactory.Invoke();
|
||||
if (Torch.Config.UgcServiceType == UGCServiceType.Steam)
|
||||
{
|
||||
_gameServerValidateAuthTicketReplacer = _gameServerValidateAuthTicketFactory.Invoke();
|
||||
_gameServerUserGroupStatusReplacer = _gameServerUserGroupStatusFactory.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
_gameServerValidateAuthTicketReplacer = _eosServerValidateAuthTicketFactory.Invoke();
|
||||
_gameServerUserGroupStatusReplacer = _eosServerUserGroupStatusFactory.Invoke();
|
||||
}
|
||||
_gameServerValidateAuthTicketReplacer.Replace(
|
||||
new Action<ulong, JoinResult, ulong, string>(ValidateAuthTicketResponse), MyGameService.GameServer);
|
||||
_gameServerUserGroupStatusReplacer.Replace(new Action<ulong, ulong, bool, bool>(UserGroupStatusResponse),
|
||||
MyGameService.GameServer);
|
||||
_log.Info("Inserted steam authentication intercept");
|
||||
_log.Info("Inserted authentication intercept");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -150,7 +158,7 @@ namespace Torch.Server.Managers
|
||||
_gameServerValidateAuthTicketReplacer.Restore(MyGameService.GameServer);
|
||||
if (_gameServerUserGroupStatusReplacer != null && _gameServerUserGroupStatusReplacer.Replaced)
|
||||
_gameServerUserGroupStatusReplacer.Restore(MyGameService.GameServer);
|
||||
_log.Info("Removed steam authentication intercept");
|
||||
_log.Info("Removed authentication intercept");
|
||||
base.Detach();
|
||||
}
|
||||
|
||||
@@ -164,6 +172,14 @@ namespace Torch.Server.Managers
|
||||
typeof(MyDedicatedServerBase), "GameServer_UserGroupStatus")]
|
||||
private static Func<ReflectedEventReplacer> _gameServerUserGroupStatusFactory;
|
||||
|
||||
[ReflectedEventReplace("VRage.EOS.MyEOSGameServer, VRage.EOS", "ValidateAuthTicketResponse",
|
||||
typeof(MyDedicatedServerBase), "GameServer_ValidateAuthTicketResponse")]
|
||||
private static Func<ReflectedEventReplacer> _eosServerValidateAuthTicketFactory;
|
||||
|
||||
[ReflectedEventReplace("VRage.EOS.MyEOSGameServer, VRage.EOS", "UserGroupStatusResponse",
|
||||
typeof(MyDedicatedServerBase), "GameServer_UserGroupStatus")]
|
||||
private static Func<ReflectedEventReplacer> _eosServerUserGroupStatusFactory;
|
||||
|
||||
private ReflectedEventReplacer _gameServerValidateAuthTicketReplacer;
|
||||
private ReflectedEventReplacer _gameServerUserGroupStatusReplacer;
|
||||
#pragma warning restore 649
|
||||
|
@@ -7,8 +7,10 @@ using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
using System.Runtime.CompilerServices;
|
||||
using NLog;
|
||||
using Sandbox.Engine.Networking;
|
||||
using VRage.Game;
|
||||
using Torch.Server.Annotations;
|
||||
using Torch.Utils;
|
||||
using Torch.Utils.SteamWorkshopTools;
|
||||
|
||||
namespace Torch.Server.ViewModels
|
||||
@@ -84,6 +86,15 @@ namespace Torch.Server.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public string UgcService
|
||||
{
|
||||
get { return _modItem.PublishedServiceName; }
|
||||
set
|
||||
{
|
||||
SetValue(ref _modItem.PublishedServiceName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, returns a new ModItemInfo instance
|
||||
/// </summary>
|
||||
@@ -101,6 +112,9 @@ namespace Torch.Server.ViewModels
|
||||
/// <returns></returns>
|
||||
public async Task<bool> UpdateModInfoAsync()
|
||||
{
|
||||
if (UgcService.ToLower() == "mod.io")
|
||||
return true;
|
||||
|
||||
var msg = "";
|
||||
var workshopService = WebAPI.Instance;
|
||||
PublishedItemDetails modInfo = null;
|
||||
@@ -127,5 +141,10 @@ namespace Torch.Server.ViewModels
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{PublishedFileId}-{UgcService}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -103,6 +103,7 @@
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
@@ -115,10 +116,11 @@
|
||||
VerticalAlignment="Center" Grid.Column="0" Grid.Row="1"/>
|
||||
<TextBox Name="AddModIDTextBox" Grid.Column="1" VerticalContentAlignment="Center"
|
||||
HorizontalAlignment="Stretch" MinWidth="100px" Margin="6px 4px" Grid.Row="1"/>
|
||||
<Button Content="Add" Grid.Column="2" Margin="6px 0" Width="60px" Height="40px" Click="AddBtn_OnClick" Grid.Row="1"/>
|
||||
<Button Content="Remove" Grid.Column="3" Margin="6px 0" Width="60px" Height="40px" Click="RemoveBtn_OnClick" Grid.Row="1"
|
||||
<ComboBox Grid.Column="2" Grid.Row="1" x:Name="UgcServiceTypeBox" SelectionChanged="UgcServiceTypeBox_OnSelectionChanged" SelectedValuePath="Value" DisplayMemberPath="Key"/>
|
||||
<Button Content="Add" Grid.Column="3" Margin="6px 0" Width="60px" Height="40px" Click="AddBtn_OnClick" Grid.Row="1"/>
|
||||
<Button Content="Remove" Grid.Column="4" Margin="6px 0" Width="60px" Height="40px" Click="RemoveBtn_OnClick" Grid.Row="1"
|
||||
IsEnabled="{Binding ElementName=ModList, Path=SelectedItems.Count}"/>
|
||||
<Button Content="Bulk Edit" Grid.Column="4" Margin="6px 0" Width="60px" Height="40px" Click="BulkButton_OnClick" Grid.Row="1"/>
|
||||
<Button Content="Bulk Edit" Grid.Column="5" Margin="6px 0" Width="60px" Height="40px" Click="BulkButton_OnClick" Grid.Row="1"/>
|
||||
</Grid>
|
||||
|
||||
<Button Content="Save Config" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="6px" Grid.Column="3" Width="80px" Height="40px" Click="SaveBtn_OnClick"/>
|
||||
|
@@ -21,6 +21,7 @@ using System.Windows.Threading;
|
||||
using VRage.Game;
|
||||
using NLog;
|
||||
using Sandbox.Engine.Networking;
|
||||
using Torch.API;
|
||||
using Torch.Server.Managers;
|
||||
using Torch.API.Managers;
|
||||
using Torch.Server.ViewModels;
|
||||
@@ -41,6 +42,7 @@ namespace Torch.Server.Views
|
||||
ModItemInfo _draggedMod;
|
||||
bool _hasOrderChanged = false;
|
||||
bool _isSortedByLoadOrder = true;
|
||||
private readonly ITorchConfig _config;
|
||||
|
||||
//private List<BindingExpression> _bindingExpressions = new List<BindingExpression>();
|
||||
/// <summary>
|
||||
@@ -51,11 +53,16 @@ namespace Torch.Server.Views
|
||||
InitializeComponent();
|
||||
_instanceManager = TorchBase.Instance.Managers.GetManager<InstanceManager>();
|
||||
_instanceManager.InstanceLoaded += _instanceManager_InstanceLoaded;
|
||||
_config = TorchBase.Instance.Config;
|
||||
//var mods = _instanceManager.DedicatedConfig?.Mods;
|
||||
//if( mods != null)
|
||||
// DataContext = new ObservableCollection<MyObjectBuilder_Checkpoint.ModItem>();
|
||||
DataContext = _instanceManager.DedicatedConfig?.Mods;
|
||||
|
||||
UgcServiceTypeBox.ItemsSource = new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("Steam", "steam"),
|
||||
new KeyValuePair<string, string>("Mod.Io", "mod.io")
|
||||
};
|
||||
// Gets called once all children are loaded
|
||||
//Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(ApplyStyles));
|
||||
}
|
||||
@@ -98,8 +105,8 @@ namespace Torch.Server.Views
|
||||
{
|
||||
if (TryExtractId(AddModIDTextBox.Text, out ulong id))
|
||||
{
|
||||
var mod = new ModItemInfo(ModItemUtils.Create(id));
|
||||
//mod.PublishedFileId = id;
|
||||
var mod = new ModItemInfo(ModItemUtils.Create(id, UgcServiceTypeBox.SelectedValue?.ToString()));
|
||||
|
||||
_instanceManager.DedicatedConfig.Mods.Add(mod);
|
||||
Task.Run(mod.UpdateModInfoAsync)
|
||||
.ContinueWith((t) =>
|
||||
@@ -254,21 +261,22 @@ namespace Torch.Server.Views
|
||||
|
||||
//let's see just how poorly we can do this
|
||||
var modList = ((MtObservableList<ModItemInfo>)DataContext).ToList();
|
||||
var idList = modList.Select(m => m.PublishedFileId).ToList();
|
||||
var idList = modList.Select(m => m.ToString()).ToList();
|
||||
var tasks = new List<Task>();
|
||||
//blocking
|
||||
editor.Edit<ulong>(idList, "Mods");
|
||||
editor.Edit<string>(idList, "Mods");
|
||||
|
||||
modList.RemoveAll(m => !idList.Contains(m.PublishedFileId));
|
||||
foreach (var id in idList)
|
||||
modList.RemoveAll(m =>
|
||||
{
|
||||
if (!modList.Any(m => m.PublishedFileId == id))
|
||||
{
|
||||
var mod = new ModItemInfo(ModItemUtils.Create(id));
|
||||
tasks.Add(Task.Run(mod.UpdateModInfoAsync));
|
||||
modList.Add(mod);
|
||||
}
|
||||
}
|
||||
var mod = m.ToString();
|
||||
return idList.Any(mod.Equals);
|
||||
});
|
||||
modList.AddRange(idList.Select(id =>
|
||||
{
|
||||
var info = new ModItemInfo(ModItemUtils.Create(id));
|
||||
tasks.Add(Task.Run(info.UpdateModInfoAsync));
|
||||
return info;
|
||||
}));
|
||||
_instanceManager.DedicatedConfig.Mods.Clear();
|
||||
foreach (var mod in modList)
|
||||
_instanceManager.DedicatedConfig.Mods.Add(mod);
|
||||
@@ -282,5 +290,12 @@ namespace Torch.Server.Views
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void UgcServiceTypeBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if ((string) UgcServiceTypeBox.SelectedValue == UGCServiceType.Steam.ToString() &&
|
||||
_config.UgcServiceType == UGCServiceType.EOS)
|
||||
MessageBox.Show("Steam workshop is not available with current ugc service!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -46,7 +46,8 @@ namespace Torch.Session
|
||||
public TorchSessionManager(ITorchBase torchInstance) : base(torchInstance)
|
||||
{
|
||||
_overrideMods = new Dictionary<ulong, MyObjectBuilder_Checkpoint.ModItem>();
|
||||
_overrideMods.Add(TorchModCore.MOD_ID, ModItemUtils.Create(TorchModCore.MOD_ID));
|
||||
if (Torch.Config.UgcServiceType == UGCServiceType.Steam)
|
||||
_overrideMods.Add(TorchModCore.MOD_ID, ModItemUtils.Create(TorchModCore.MOD_ID));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
|
@@ -1,13 +1,22 @@
|
||||
using Sandbox.Engine.Networking;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Sandbox.Engine.Networking;
|
||||
using Torch.API;
|
||||
using VRage.Game;
|
||||
|
||||
namespace Torch.Utils
|
||||
{
|
||||
public static class ModItemUtils
|
||||
{
|
||||
public static MyObjectBuilder_Checkpoint.ModItem Create(ulong modId)
|
||||
public static MyObjectBuilder_Checkpoint.ModItem Create(ulong modId, string serviceType = null)
|
||||
{
|
||||
return new MyObjectBuilder_Checkpoint.ModItem(modId, GetDefaultServiceName());
|
||||
return new MyObjectBuilder_Checkpoint.ModItem(modId, serviceType ?? GetDefaultServiceName());
|
||||
}
|
||||
|
||||
public static MyObjectBuilder_Checkpoint.ModItem Create(string str)
|
||||
{
|
||||
var arr = str.Split('-');
|
||||
return new MyObjectBuilder_Checkpoint.ModItem(ulong.Parse(arr[0]), arr[1]);
|
||||
}
|
||||
|
||||
//because KEEEN!
|
||||
|
@@ -160,30 +160,32 @@ namespace Torch
|
||||
MyFileSystem.Reset();
|
||||
MyInitializer.InvokeBeforeRun(_appSteamId, _appName, _userDataPath);
|
||||
|
||||
_log.Info("Loading Dedicated Config");
|
||||
// object created in SpaceEngineersGame.SetupPerGameSettings()
|
||||
MySandboxGame.ConfigDedicated.Load();
|
||||
MyPlatformGameSettings.CONSOLE_COMPATIBLE = MySandboxGame.ConfigDedicated.ConsoleCompatibility;
|
||||
|
||||
//Type.GetType("VRage.Steam.MySteamService, VRage.Steam").GetProperty("IsActive").GetSetMethod(true).Invoke(service, new object[] {SteamAPI.Init()});
|
||||
_log.Info("Initializing UGC services");
|
||||
IMyGameService service;
|
||||
IMyUGCService serviceInstance;
|
||||
var aggregator = new MyServerDiscoveryAggregator();
|
||||
if (TorchBase.Instance.Config.UgcServiceType == UGCServiceType.Steam)
|
||||
_log.Info("Initializing network services");
|
||||
|
||||
var isEos = TorchBase.Instance.Config.UgcServiceType == UGCServiceType.EOS;
|
||||
|
||||
if (isEos)
|
||||
{
|
||||
service = MySteamGameService.Create(dedicated, _appSteamId);
|
||||
serviceInstance = MySteamUgcService.Create(_appSteamId, service);
|
||||
MySteamGameService.InitNetworking(dedicated,
|
||||
service,
|
||||
"Space Engineers",
|
||||
aggregator);
|
||||
_log.Info("Running on Epic Online Services.");
|
||||
_log.Warn("Steam workshop will not work with current settings. Some functions might not work properly!");
|
||||
}
|
||||
else
|
||||
|
||||
var aggregator = new MyServerDiscoveryAggregator();
|
||||
MyServiceManager.Instance.AddService<IMyServerDiscovery>(aggregator);
|
||||
|
||||
IMyGameService service;
|
||||
if (isEos)
|
||||
{
|
||||
service = MyEOSService.Create();
|
||||
|
||||
serviceInstance = MyModIoService.Create(service, "spaceengineers", "264",
|
||||
"1fb4489996a5e8ffc6ec1135f9985b5b", "331", "f2b64abe55452252b030c48adc0c1f0e",
|
||||
MyPlatformGameSettings.UGC_TEST_ENVIRONMENT, true);
|
||||
|
||||
MyEOSService.InitNetworking(dedicated,
|
||||
dedicated ? MyPerServerSettings.GameDSName : MyPerServerSettings.GameNameSafe,
|
||||
"Space Engineers",
|
||||
service,
|
||||
"xyza7891A4WeGrpP85BTlBa3BSfUEABN",
|
||||
"ZdHZVevSVfIajebTnTmh5MVi3KPHflszD9hJB7mRkgg",
|
||||
@@ -194,25 +196,39 @@ namespace Torch
|
||||
MyEOSService.CreatePlatform(),
|
||||
MySandboxGame.ConfigDedicated.VerboseNetworkLogging,
|
||||
Enumerable.Empty<string>(),
|
||||
(MyServerDiscoveryAggregator) MyGameService.ServerDiscovery,
|
||||
null);
|
||||
aggregator,
|
||||
MyMultiplayer.Channels);
|
||||
|
||||
var mockingInventory = new MyMockingInventory(service);
|
||||
MyServiceManager.Instance.AddService<IMyInventoryService>(mockingInventory);
|
||||
}
|
||||
MyServiceManager.Instance.AddService<IMyGameService>(service);
|
||||
MyServiceManager.Instance.AddService<IMyUGCService>(serviceInstance);
|
||||
MyGameService.WorkshopService.AddAggregate(serviceInstance);
|
||||
else
|
||||
{
|
||||
service = MySteamGameService.Create(dedicated, _appSteamId);
|
||||
MyGameService.WorkshopService.AddAggregate(MySteamUgcService.Create(_appSteamId, service));
|
||||
MySteamGameService.InitNetworking(dedicated,
|
||||
service,
|
||||
"Space Engineers",
|
||||
aggregator);
|
||||
}
|
||||
|
||||
_log.Info("Initializing services");
|
||||
MyServiceManager.Instance.AddService(new MyNullMicrophone());
|
||||
MyServiceManager.Instance.AddService(service);
|
||||
|
||||
if (!MyGameService.HasGameServer)
|
||||
MyGameService.WorkshopService.AddAggregate(MyModIoService.Create(service, "spaceengineers", "264",
|
||||
"1fb4489996a5e8ffc6ec1135f9985b5b", "331", "f2b64abe55452252b030c48adc0c1f0e",
|
||||
MyPlatformGameSettings.UGC_TEST_ENVIRONMENT, true));
|
||||
|
||||
if (!isEos && !MyGameService.HasGameServer)
|
||||
{
|
||||
_log.Warn("Network service is not running! Please reinstall dedicated server.");
|
||||
return;
|
||||
}
|
||||
|
||||
_log.Info("Initializing services");
|
||||
MyServiceManager.Instance.AddService<IMyMicrophoneService>(new MyNullMicrophone());
|
||||
|
||||
MyNetworkMonitor.Init();
|
||||
|
||||
_log.Info("Services initialized");
|
||||
MySandboxGame.InitMultithreading();
|
||||
// MyInitializer.InitCheckSum();
|
||||
|
Reference in New Issue
Block a user