fix for cross-play update

This commit is contained in:
LTP
2021-02-11 23:15:46 +07:00
parent 8f30b7605b
commit e5cb3e5ae0
6 changed files with 33 additions and 8 deletions

View File

@@ -185,6 +185,7 @@
<Compile Include="Session\TorchSessionState.cs" /> <Compile Include="Session\TorchSessionState.cs" />
<Compile Include="TorchGameState.cs" /> <Compile Include="TorchGameState.cs" />
<Compile Include="Utils\ColorUtils.cs" /> <Compile Include="Utils\ColorUtils.cs" />
<Compile Include="Utils\ModItemUtils.cs" />
<Compile Include="Utils\StringUtils.cs" /> <Compile Include="Utils\StringUtils.cs" />
<Compile Include="WebAPI\JenkinsQuery.cs" /> <Compile Include="WebAPI\JenkinsQuery.cs" />
<Compile Include="WebAPI\PluginQuery.cs" /> <Compile Include="WebAPI\PluginQuery.cs" />

View File

@@ -0,0 +1,16 @@
using Sandbox.Engine.Networking;
using VRage.Game;
namespace Torch.Utils
{
public static class ModItemUtils
{
public static MyObjectBuilder_Checkpoint.ModItem Create(ulong modId)
{
var serviceName = "Steam";
if (MyGameService.IsOnline)
serviceName = MyGameService.GetDefaultUGC().ServiceName;
return new MyObjectBuilder_Checkpoint.ModItem(modId, serviceName);
}
}
}

View File

@@ -7,7 +7,9 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Data; using System.Windows.Data;
using Sandbox.Engine.Networking;
using Torch.Server.ViewModels; using Torch.Server.ViewModels;
using Torch.Utils;
using VRage.Game; using VRage.Game;
namespace Torch.Server.Views.Converters namespace Torch.Server.Views.Converters
@@ -67,7 +69,7 @@ namespace Torch.Server.Views.Converters
if (mod != null) if (mod != null)
list.Add(mod); list.Add(mod);
else else
list.Add(new MyObjectBuilder_Checkpoint.ModItem(id)); list.Add(ModItemUtils.Create(id));
} }
} }

View File

@@ -20,11 +20,13 @@ using System.Runtime.CompilerServices;
using System.Windows.Threading; using System.Windows.Threading;
using VRage.Game; using VRage.Game;
using NLog; using NLog;
using Sandbox.Engine.Networking;
using Torch.Server.Managers; using Torch.Server.Managers;
using Torch.API.Managers; using Torch.API.Managers;
using Torch.Server.ViewModels; using Torch.Server.ViewModels;
using Torch.Server.Annotations; using Torch.Server.Annotations;
using Torch.Collections; using Torch.Collections;
using Torch.Utils;
using Torch.Views; using Torch.Views;
namespace Torch.Server.Views namespace Torch.Server.Views
@@ -96,7 +98,7 @@ namespace Torch.Server.Views
{ {
if (TryExtractId(AddModIDTextBox.Text, out ulong id)) if (TryExtractId(AddModIDTextBox.Text, out ulong id))
{ {
var mod = new ModItemInfo(new MyObjectBuilder_Checkpoint.ModItem(id)); var mod = new ModItemInfo(new MyObjectBuilder_Checkpoint.ModItem(id, MyGameService.GetDefaultUGC().ServiceName));
//mod.PublishedFileId = id; //mod.PublishedFileId = id;
_instanceManager.DedicatedConfig.Mods.Add(mod); _instanceManager.DedicatedConfig.Mods.Add(mod);
Task.Run(mod.UpdateModInfoAsync) Task.Run(mod.UpdateModInfoAsync)
@@ -262,7 +264,7 @@ namespace Torch.Server.Views
{ {
if (!modList.Any(m => m.PublishedFileId == id)) if (!modList.Any(m => m.PublishedFileId == id))
{ {
var mod = new ModItemInfo(new MyObjectBuilder_Checkpoint.ModItem(id)); var mod = new ModItemInfo(ModItemUtils.Create(id));
tasks.Add(Task.Run(mod.UpdateModInfoAsync)); tasks.Add(Task.Run(mod.UpdateModInfoAsync));
modList.Add(mod); modList.Add(mod);
} }

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NLog; using NLog;
using Sandbox.Engine.Networking;
using Sandbox.Game.World; using Sandbox.Game.World;
using Torch.API; using Torch.API;
using Torch.API.Managers; using Torch.API.Managers;
@@ -12,6 +13,7 @@ using Torch.API.Session;
using Torch.Managers; using Torch.Managers;
using Torch.Mod; using Torch.Mod;
using Torch.Session; using Torch.Session;
using Torch.Utils;
using VRage.Game; using VRage.Game;
namespace Torch.Session namespace Torch.Session
@@ -44,7 +46,7 @@ namespace Torch.Session
public TorchSessionManager(ITorchBase torchInstance) : base(torchInstance) public TorchSessionManager(ITorchBase torchInstance) : base(torchInstance)
{ {
_overrideMods = new Dictionary<ulong, MyObjectBuilder_Checkpoint.ModItem>(); _overrideMods = new Dictionary<ulong, MyObjectBuilder_Checkpoint.ModItem>();
_overrideMods.Add(TorchModCore.MOD_ID, new MyObjectBuilder_Checkpoint.ModItem(TorchModCore.MOD_ID)); _overrideMods.Add(TorchModCore.MOD_ID, ModItemUtils.Create(TorchModCore.MOD_ID));
} }
/// <inheritdoc/> /// <inheritdoc/>
@@ -68,7 +70,7 @@ namespace Torch.Session
{ {
if (_overrideMods.ContainsKey(modId)) if (_overrideMods.ContainsKey(modId))
return false; return false;
var item = new MyObjectBuilder_Checkpoint.ModItem(modId); var item = ModItemUtils.Create(modId);
_overrideMods.Add(modId, item); _overrideMods.Add(modId, item);
OverrideModsChanged?.Invoke(new CollectionChangeEventArgs(CollectionChangeAction.Add, item)); OverrideModsChanged?.Invoke(new CollectionChangeEventArgs(CollectionChangeAction.Add, item));

View File

@@ -146,7 +146,9 @@ namespace Torch
MyPerGameSettings.SendLogToKeen = false; MyPerGameSettings.SendLogToKeen = false;
// SpaceEngineersGame.SetupAnalytics(); // SpaceEngineersGame.SetupAnalytics();
MyVRage.Platform.InitScripting(MyVRageScripting.Create()); //not implemented by keen.. removed in cross-play update
//MyVRage.Platform.InitScripting(MyVRageScripting.Create());
MyFileSystem.ExePath = Path.GetDirectoryName(typeof(SpaceEngineersGame).Assembly.Location); MyFileSystem.ExePath = Path.GetDirectoryName(typeof(SpaceEngineersGame).Assembly.Location);
_tweakGameSettings(); _tweakGameSettings();
@@ -161,7 +163,7 @@ namespace Torch
var serviceInstance = MySteamUgcService.Create(_appSteamId, service); var serviceInstance = MySteamUgcService.Create(_appSteamId, service);
MyServiceManager.Instance.AddService<IMyUGCService>(serviceInstance); MyServiceManager.Instance.AddService<IMyUGCService>(serviceInstance);
MyServiceManager.Instance.AddService(new MyNullMicrophone()); MyServiceManager.Instance.AddService(new MyNullMicrophone());
MySteamGameService.InitNetworking(dedicated, service); MySteamGameService.InitNetworking(dedicated, service, (MyServerDiscoveryAggregator) MyGameService.ServerDiscovery);
if (!MyGameService.HasGameServer) if (!MyGameService.HasGameServer)
{ {
_log.Warn("Steam service is not running! Please reinstall dedicated server."); _log.Warn("Steam service is not running! Please reinstall dedicated server.");