Fix crash when cancelling mod download
All checks were successful
Build / Compute Version (push) Successful in 5s
Build / Build Nuget package (push) Successful in 54s

This commit is contained in:
2025-05-16 21:36:52 -04:00
parent 28b82c7c96
commit 67b3c08fbb
2 changed files with 5 additions and 2 deletions

View File

@@ -26,8 +26,11 @@ internal static class ModInjector
[HarmonyPatch(typeof(MyWorkshop), nameof(MyWorkshop.DownloadWorldModsBlockingInternal))]
[HarmonyPostfix]
private static void DownloadModsBlockingPostfix(List<MyObjectBuilder_Checkpoint.ModItem> mods, List<MyObjectBuilder_Checkpoint.ModItem> __state)
private static void DownloadModsBlockingPostfix(MyWorkshop.ResultData ret, List<MyObjectBuilder_Checkpoint.ModItem> mods, List<MyObjectBuilder_Checkpoint.ModItem> __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);

View File

@@ -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}",