From b8ce385ee5b148641144da6aa25392f68f91c3a0 Mon Sep 17 00:00:00 2001 From: wannkunstbeikor Date: Fri, 13 Jan 2023 16:23:29 +0100 Subject: [PATCH 1/2] [ModSupport] Fixes issue with logging legacy mods --- FrostyModSupport/FrostyModExecutor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FrostyModSupport/FrostyModExecutor.cs b/FrostyModSupport/FrostyModExecutor.cs index 7778e36cf..3769db26e 100644 --- a/FrostyModSupport/FrostyModExecutor.cs +++ b/FrostyModSupport/FrostyModExecutor.cs @@ -1081,7 +1081,7 @@ public int Run(FileSystem inFs, CancellationToken cancelToken, ILogger inLogger, int currentMod = 0; foreach (FrostyMod mod in modList) { - Logger.Log($"Loading Mods ({mod.ModDetails.Title})"); + Logger.Log($"Loading Mods ({mod.ModDetails?.Title ?? mod.Filename.Replace(".fbmod", "")})"); if (mod.NewFormat) { ProcessModResources(mod); From b357e2ffc0aab5534810996d068e03f0b556514f Mon Sep 17 00:00:00 2001 From: wannkunstbeikor Date: Fri, 13 Jan 2023 17:03:14 +0100 Subject: [PATCH 2/2] [ModSupport] Cleans up TryAdd functions --- FrostyModSupport/FrostyModExecutor.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/FrostyModSupport/FrostyModExecutor.cs b/FrostyModSupport/FrostyModExecutor.cs index 3769db26e..cf60df505 100644 --- a/FrostyModSupport/FrostyModExecutor.cs +++ b/FrostyModSupport/FrostyModExecutor.cs @@ -354,9 +354,7 @@ private void ProcessModResources(IResourceContainer fmod) entry.Size = data.Length; modifiedEbx.TryAdd(entry.Name, entry); - if (!archiveData.ContainsKey(entry.Sha1)) - archiveData.GetOrAdd(entry.Sha1, new ArchiveInfo() { Data = data, RefCount = 1 }); - else + if (!archiveData.TryAdd(entry.Sha1, new ArchiveInfo() { Data = data, RefCount = 1 })) archiveData[entry.Sha1].RefCount++; numArchiveEntries++; } @@ -452,9 +450,7 @@ private void ProcessModResources(IResourceContainer fmod) entry.Size = data.Length; modifiedRes.TryAdd(entry.Name, entry); - if (!archiveData.ContainsKey(entry.Sha1)) - archiveData.TryAdd(entry.Sha1, new ArchiveInfo() { Data = data, RefCount = 1 }); - else + if (!archiveData.TryAdd(entry.Sha1, new ArchiveInfo() { Data = data, RefCount = 1 })) archiveData[entry.Sha1].RefCount++; numArchiveEntries++; } @@ -610,9 +606,7 @@ private void ProcessModResources(IResourceContainer fmod) entry.Size = data.Length; modifiedChunks.TryAdd(guid, entry); - if (!archiveData.ContainsKey(entry.Sha1)) - archiveData.TryAdd(entry.Sha1, new ArchiveInfo() { Data = data, RefCount = 1 }); - else + if (!archiveData.TryAdd(entry.Sha1, new ArchiveInfo() { Data = data, RefCount = 1 })) archiveData[entry.Sha1].RefCount++; numArchiveEntries++; } @@ -1455,8 +1449,7 @@ public int Run(FileSystem inFs, CancellationToken cancelToken, ILogger inLogger, // add bundle data to archive for (int i = 0; i < action.BundleRefs.Count; i++) { - if (!archiveData.ContainsKey(action.BundleRefs[i])) - archiveData.TryAdd(action.BundleRefs[i], new ArchiveInfo() { Data = action.BundleBuffers[i] }); + archiveData.TryAdd(action.BundleRefs[i], new ArchiveInfo() { Data = action.BundleBuffers[i] }); } // add refs to be added to cas (and manifest)