From cee5cb3c4dd0141001a79bd31ce1e5a5eef4cb4c Mon Sep 17 00:00:00 2001 From: LTP Date: Fri, 12 Feb 2021 19:36:28 +0700 Subject: [PATCH] totally fixed --- Torch.Server/Managers/InstanceManager.cs | 8 +++++-- Torch.Server/Views/ModListControl.xaml.cs | 2 +- Torch/Patches/ModsDownloadingPatch.cs | 29 +++++++---------------- Torch/VRageGame.cs | 2 +- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/Torch.Server/Managers/InstanceManager.cs b/Torch.Server/Managers/InstanceManager.cs index 92f14e9..6d71931 100644 --- a/Torch.Server/Managers/InstanceManager.cs +++ b/Torch.Server/Managers/InstanceManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; @@ -19,6 +19,7 @@ using Torch.Collections; using Torch.Managers; using Torch.Mod; using Torch.Server.ViewModels; +using Torch.Utils; using VRage; using VRage.FileSystem; using VRage.Game; @@ -217,8 +218,11 @@ namespace Torch.Server.Managers foreach (var mod in DedicatedConfig.Mods) { - var savedMod = new MyObjectBuilder_Checkpoint.ModItem(mod.Name, mod.PublishedFileId, mod.FriendlyName); + var savedMod = ModItemUtils.Create(mod.PublishedFileId); savedMod.IsDependency = mod.IsDependency; + savedMod.Name = mod.Name; + savedMod.FriendlyName = mod.FriendlyName; + world.WorldConfiguration.Mods.Add(savedMod); } Task.Run(() => DedicatedConfig.UpdateAllModInfosAsync()); diff --git a/Torch.Server/Views/ModListControl.xaml.cs b/Torch.Server/Views/ModListControl.xaml.cs index 31fddc5..f0318a4 100644 --- a/Torch.Server/Views/ModListControl.xaml.cs +++ b/Torch.Server/Views/ModListControl.xaml.cs @@ -98,7 +98,7 @@ namespace Torch.Server.Views { if (TryExtractId(AddModIDTextBox.Text, out ulong id)) { - var mod = new ModItemInfo(new MyObjectBuilder_Checkpoint.ModItem(id, MyGameService.GetDefaultUGC().ServiceName)); + var mod = new ModItemInfo(ModItemUtils.Create(id)); //mod.PublishedFileId = id; _instanceManager.DedicatedConfig.Mods.Add(mod); Task.Run(mod.UpdateModInfoAsync) diff --git a/Torch/Patches/ModsDownloadingPatch.cs b/Torch/Patches/ModsDownloadingPatch.cs index a764db0..d871013 100644 --- a/Torch/Patches/ModsDownloadingPatch.cs +++ b/Torch/Patches/ModsDownloadingPatch.cs @@ -1,9 +1,11 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Reflection; using NLog; using Sandbox; using Sandbox.Engine.Networking; +using Torch.API; using Torch.Managers.PatchManager; using Torch.Managers.PatchManager.MSIL; using Torch.Utils; @@ -12,7 +14,7 @@ using VRage.Game; namespace Torch.Patches { [PatchShim] - internal class ModsDownloadingPatch + internal static class ModsDownloadingPatch { private static readonly Logger _log = LogManager.GetCurrentClassLogger(); #pragma warning disable 649 @@ -23,28 +25,15 @@ namespace Torch.Patches public static void Patch(PatchContext ctx) { _log.Info("Patching mods downloading"); - var pattern = ctx.GetPattern(_downloadWorldModsBlockingMethod); - pattern.Suffixes - .Add(typeof(ModsDownloadingPatch).GetMethod(nameof(Postfix))); - pattern.Prefixes.Add(typeof(ModsDownloadingPatch).GetMethod(nameof(Prefix))); - } - public static void Prefix(ref List mods) - { - var serviceName = MyGameService.GetDefaultUGC().ServiceName; - mods = mods?.Select(b => { - b.PublishedServiceName = serviceName; - return b; - }).ToList(); + ctx.GetPattern(_downloadWorldModsBlockingMethod).Suffixes + .Add(typeof(ModsDownloadingPatch).GetMethod(nameof(Postfix))); } - public static void Postfix(MyWorkshop.ResultData __result) { - if (!__result.Success) - { - _log.Warn("Missing Mods:"); - __result.MismatchMods.ForEach(b => _log.Info($"\t{b.Title} : {b.Id}")); - } + if (__result.Success) return; + _log.Warn("Missing Mods:"); + __result.MismatchMods?.ForEach(b => _log.Info($"\t{b}")); } } } \ No newline at end of file diff --git a/Torch/VRageGame.cs b/Torch/VRageGame.cs index 06304bb..8f7f2e3 100644 --- a/Torch/VRageGame.cs +++ b/Torch/VRageGame.cs @@ -183,7 +183,7 @@ namespace Torch "xyza7891A4WeGrpP85BTlBa3BSfUEABN", "ZdHZVevSVfIajebTnTmh5MVi3KPHflszD9hJB7mRkgg", "24b1cd652a18461fa9b3d533ac8d6b5b", "1958fe26c66d4151a327ec162e4d49c8", "07c169b3b641401496d352cad1c905d6", "https://retail.epicgames.com/", MyEOSService.CreatePlatform(), - MySandboxGame.ConfigDedicated.VerboseNetworkLogging, null, null, null); + MySandboxGame.ConfigDedicated.VerboseNetworkLogging, null, Enumerable.Empty(), null); var mockingInventory = new MyMockingInventory(service); MyServiceManager.Instance.AddService(mockingInventory);