Merge pull request #428 from theltp/fix/cross-play

fix for cross-play update
This commit is contained in:
Jimmacle
2021-02-11 13:34:28 -08:00
committed by GitHub
6 changed files with 45 additions and 9 deletions

View File

@@ -185,6 +185,7 @@
<Compile Include="Session\TorchSessionState.cs" />
<Compile Include="TorchGameState.cs" />
<Compile Include="Utils\ColorUtils.cs" />
<Compile Include="Utils\ModItemUtils.cs" />
<Compile Include="Utils\StringUtils.cs" />
<Compile Include="WebAPI\JenkinsQuery.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)
{
return new MyObjectBuilder_Checkpoint.ModItem(modId, GetDefaultServiceName());
}
//because KEEEN!
public static string GetDefaultServiceName() => "Steam";
}
}

View File

@@ -7,7 +7,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using Sandbox.Engine.Networking;
using Torch.Server.ViewModels;
using Torch.Utils;
using VRage.Game;
namespace Torch.Server.Views.Converters
@@ -67,7 +69,7 @@ namespace Torch.Server.Views.Converters
if (mod != null)
list.Add(mod);
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 VRage.Game;
using NLog;
using Sandbox.Engine.Networking;
using Torch.Server.Managers;
using Torch.API.Managers;
using Torch.Server.ViewModels;
using Torch.Server.Annotations;
using Torch.Collections;
using Torch.Utils;
using Torch.Views;
namespace Torch.Server.Views
@@ -96,7 +98,7 @@ namespace Torch.Server.Views
{
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;
_instanceManager.DedicatedConfig.Mods.Add(mod);
Task.Run(mod.UpdateModInfoAsync)
@@ -262,7 +264,7 @@ namespace Torch.Server.Views
{
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));
modList.Add(mod);
}

View File

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

View File

@@ -146,7 +146,10 @@ namespace Torch
MyPerGameSettings.SendLogToKeen = false;
// SpaceEngineersGame.SetupAnalytics();
MyVRage.Platform.InitScripting(MyVRageScripting.Create());
//not implemented by keen.. removed in cross-play update
//MyVRage.Platform.InitScripting(MyVRageScripting.Create());
_ = MyVRage.Platform.Scripting;
MyFileSystem.ExePath = Path.GetDirectoryName(typeof(SpaceEngineersGame).Assembly.Location);
_tweakGameSettings();
@@ -161,7 +164,7 @@ namespace Torch
var serviceInstance = MySteamUgcService.Create(_appSteamId, service);
MyServiceManager.Instance.AddService<IMyUGCService>(serviceInstance);
MyServiceManager.Instance.AddService(new MyNullMicrophone());
MySteamGameService.InitNetworking(dedicated, service);
MySteamGameService.InitNetworking(dedicated, service, (MyServerDiscoveryAggregator) MyGameService.ServerDiscovery);
if (!MyGameService.HasGameServer)
{
_log.Warn("Steam service is not running! Please reinstall dedicated server.");
@@ -290,14 +293,24 @@ namespace Torch
MyObjectBuilder_Checkpoint checkpoint = MyLocalCache.LoadCheckpoint(sessionPath, out ulong checkpointSize);
if (MySession.IsCompatibleVersion(checkpoint))
{
if (MyWorkshop.DownloadWorldModsBlocking(checkpoint.Mods, null).Success)
var downloadResult = MyWorkshop.DownloadWorldModsBlocking(checkpoint.Mods.Select(b =>
{
b.PublishedServiceName = ModItemUtils.GetDefaultServiceName();
return b;
}).ToList(), null);
if (downloadResult.Success)
{
MyLog.Default.WriteLineAndConsole("Mods Downloaded");
// MySpaceAnalytics.Instance.SetEntry(MyGameEntryEnum.Load);
MySession.Load(sessionPath, checkpoint, checkpointSize);
_hostServerForSession(MySession.Static, MyMultiplayer.Static);
}
else
{
MyLog.Default.WriteLineAndConsole("Unable to download mods");
MyLog.Default.WriteLineAndConsole("Missing Mods:");
downloadResult.MismatchMods?.ForEach(b => MyLog.Default.WriteLineAndConsole($"\t{b.Title} ({b.Id})"));
}
}
else
MyLog.Default.WriteLineAndConsole(MyTexts.Get(MyCommonTexts.DialogTextIncompatibleWorldVersion)