From 67b3c08fbb1f6099e6023c5039e1b8ebbde5261d Mon Sep 17 00:00:00 2001 From: pas2704 Date: Fri, 16 May 2025 21:36:52 -0400 Subject: [PATCH] Fix crash when cancelling mod download --- Plugin.ClientModLoader/ModInjector.cs | 5 ++++- Plugin.ClientModLoader/ModListComponent.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Plugin.ClientModLoader/ModInjector.cs b/Plugin.ClientModLoader/ModInjector.cs index d1441fb..839d9f1 100644 --- a/Plugin.ClientModLoader/ModInjector.cs +++ b/Plugin.ClientModLoader/ModInjector.cs @@ -26,8 +26,11 @@ internal static class ModInjector [HarmonyPatch(typeof(MyWorkshop), nameof(MyWorkshop.DownloadWorldModsBlockingInternal))] [HarmonyPostfix] - private static void DownloadModsBlockingPostfix(List mods, List __state) + private static void DownloadModsBlockingPostfix(MyWorkshop.ResultData ret, List mods, List __state) { + if (ret.Result != VRage.GameServices.MyGameServiceCallResult.OK) + return; //world will not load, and mod data isn't loaded + var worldMods = __state.Select(b => b.PublishedFileId).ToImmutableHashSet(); var resolvedMods = mods.ToImmutableDictionary(b => b.PublishedFileId); diff --git a/Plugin.ClientModLoader/ModListComponent.cs b/Plugin.ClientModLoader/ModListComponent.cs index 72bf66d..7cf7540 100644 --- a/Plugin.ClientModLoader/ModListComponent.cs +++ b/Plugin.ClientModLoader/ModListComponent.cs @@ -273,7 +273,7 @@ public class ModListComponent : IRenderComponent var description = details.m_rgchDescription; list.Add(new(details.m_nPublishedFileId.m_PublishedFileId, title, string.IsNullOrEmpty(item.Tooltip) - ? description[..Math.Min(description.Length - 1, 255)] + ? description[..Math.Min(description.Length, 255)] : item.Tooltip, item.Description, description, $"https://steamcommunity.com/sharedfiles/filedetails/?id={details.m_nPublishedFileId.m_PublishedFileId}",