diff --git a/Penumbra/Collections/Cache/EqdpCache.cs b/Penumbra/Collections/Cache/EqdpCache.cs index 3937fa72..ddc161cd 100644 --- a/Penumbra/Collections/Cache/EqdpCache.cs +++ b/Penumbra/Collections/Cache/EqdpCache.cs @@ -31,12 +31,22 @@ public readonly struct EqdpCache : IDisposable manager.SetFile(_eqdpFiles[i], index); } - public MetaList.MetaReverter TemporarilySetFiles(MetaFileManager manager, GenderRace genderRace, bool accessory) + public MetaList.MetaReverter? TemporarilySetFiles(MetaFileManager manager, GenderRace genderRace, bool accessory) { var idx = CharacterUtilityData.EqdpIdx(genderRace, accessory); - Debug.Assert(idx >= 0, $"Invalid Gender, Race or Accessory for EQDP file {genderRace}, {accessory}."); + if (idx < 0) + { + Penumbra.Log.Warning($"Invalid Gender, Race or Accessory for EQDP file {genderRace}, {accessory}."); + return null; + } + var i = CharacterUtilityData.EqdpIndices.IndexOf(idx); - Debug.Assert(i >= 0, $"Invalid Gender, Race or Accessory for EQDP file {genderRace}, {accessory}."); + if (i < 0) + { + Penumbra.Log.Warning($"Invalid Gender, Race or Accessory for EQDP file {genderRace}, {accessory}."); + return null; + } + return manager.TemporarilySetFile(_eqdpFiles[i], idx); } diff --git a/Penumbra/Collections/Cache/MetaCache.cs b/Penumbra/Collections/Cache/MetaCache.cs index d5acf249..0fc665ed 100644 --- a/Penumbra/Collections/Cache/MetaCache.cs +++ b/Penumbra/Collections/Cache/MetaCache.cs @@ -170,7 +170,7 @@ public class MetaCache : IDisposable, IEnumerable _eqpCache.TemporarilySetFiles(_manager); - public MetaList.MetaReverter TemporarilySetEqdpFile(GenderRace genderRace, bool accessory) + public MetaList.MetaReverter? TemporarilySetEqdpFile(GenderRace genderRace, bool accessory) => _eqdpCache.TemporarilySetFiles(_manager, genderRace, accessory); public MetaList.MetaReverter TemporarilySetGmpFile() diff --git a/Penumbra/Collections/ModCollection.Cache.Access.cs b/Penumbra/Collections/ModCollection.Cache.Access.cs index a695c463..5d1d10e2 100644 --- a/Penumbra/Collections/ModCollection.Cache.Access.cs +++ b/Penumbra/Collections/ModCollection.Cache.Access.cs @@ -89,9 +89,14 @@ public partial class ModCollection } // Used for short periods of changed files. - public MetaList.MetaReverter TemporarilySetEqdpFile(CharacterUtility utility, GenderRace genderRace, bool accessory) - => _cache?.Meta.TemporarilySetEqdpFile(genderRace, accessory) - ?? utility.TemporarilyResetResource(CharacterUtilityData.EqdpIdx(genderRace, accessory)); + public MetaList.MetaReverter? TemporarilySetEqdpFile(CharacterUtility utility, GenderRace genderRace, bool accessory) + { + if (_cache != null) + return _cache?.Meta.TemporarilySetEqdpFile(genderRace, accessory); + + var idx = CharacterUtilityData.EqdpIdx(genderRace, accessory); + return idx >= 0 ? utility.TemporarilyResetResource(idx) : null; + } public MetaList.MetaReverter TemporarilySetEqpFile(CharacterUtility utility) => _cache?.Meta.TemporarilySetEqpFile() diff --git a/Penumbra/Collections/ModCollection.cs b/Penumbra/Collections/ModCollection.cs index a9f565c6..b63be6cd 100644 --- a/Penumbra/Collections/ModCollection.cs +++ b/Penumbra/Collections/ModCollection.cs @@ -7,7 +7,7 @@ using Penumbra.Services; namespace Penumbra.Collections; /// -/// A ModCollection is a named set of ModSettings to all of the users' installed mods. +/// A ModCollection is a named set of ModSettings to all the users' installed mods. /// Settings to mods that are not installed anymore are kept as long as no call to CleanUnavailableSettings is made. /// Invariants: /// - Index is the collections index in the ModCollection.Manager @@ -113,7 +113,7 @@ public partial class ModCollection { Debug.Assert(index > 0, "Collection duplicated with non-positive index."); return new ModCollection(name, index, 0, CurrentVersion, Settings.Select(s => s?.DeepCopy()).ToList(), - DirectlyInheritsFrom.ToList(), UnusedSettings.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.DeepCopy())); + [.. DirectlyInheritsFrom], UnusedSettings.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.DeepCopy())); } /// Constructor for reading from files.