diff --git a/Penumbra/Collections/ModCollection.Cache.Access.cs b/Penumbra/Collections/ModCollection.Cache.Access.cs index b5ea41f1..e289096b 100644 --- a/Penumbra/Collections/ModCollection.Cache.Access.cs +++ b/Penumbra/Collections/ModCollection.Cache.Access.cs @@ -18,8 +18,9 @@ public partial class ModCollection public bool HasCache => _cache != null; - public int RecomputeCounter - => _cache?.ChangeCounter ?? 0; + // Count the number of changes of the effective file list. + // This is used for material and imc changes. + public int ChangeCounter { get; private set; } // Only create, do not update. private void CreateCache() diff --git a/Penumbra/Collections/ModCollection.Cache.cs b/Penumbra/Collections/ModCollection.Cache.cs index fa9669b6..332d0fa5 100644 --- a/Penumbra/Collections/ModCollection.Cache.cs +++ b/Penumbra/Collections/ModCollection.Cache.cs @@ -32,9 +32,6 @@ public partial class ModCollection public SingleArray< ModConflicts > Conflicts( IMod mod ) => _conflicts.TryGetValue( mod, out var c ) ? c : new SingleArray< ModConflicts >(); - // Count the number of changes of the effective file list. - // This is used for material and imc changes. - public int ChangeCounter { get; private set; } private int _changedItemsSaveCounter = -1; // Obtain currently changed items. Computes them if they haven't been computed before. @@ -55,7 +52,9 @@ public partial class ModCollection _collection.ModSettingChanged += OnModSettingChange; _collection.InheritanceChanged += OnInheritanceChange; if( !Penumbra.CharacterUtility.Ready ) + { Penumbra.CharacterUtility.LoadingFinished += IncrementCounter; + } } public void Dispose() @@ -176,7 +175,7 @@ public partial class ModCollection AddMetaFiles(); - ++ChangeCounter; + ++_collection.ChangeCounter; if( _collection == Penumbra.CollectionManager.Default && Penumbra.CharacterUtility.Ready ) { @@ -239,7 +238,7 @@ public partial class ModCollection if( addMetaChanges ) { - ++ChangeCounter; + ++_collection.ChangeCounter; if( _collection == Penumbra.CollectionManager.Default && Penumbra.CharacterUtility.Ready ) { Penumbra.ResidentResources.Reload(); @@ -292,7 +291,7 @@ public partial class ModCollection if( addMetaChanges ) { - ++ChangeCounter; + ++_collection.ChangeCounter; if( mod.TotalManipulations > 0 ) { AddMetaFiles(); @@ -449,7 +448,7 @@ public partial class ModCollection // Increment the counter to ensure new files are loaded after applying meta changes. private void IncrementCounter() { - ++ChangeCounter; + ++_collection.ChangeCounter; Penumbra.CharacterUtility.LoadingFinished -= IncrementCounter; } @@ -457,14 +456,14 @@ public partial class ModCollection // Identify and record all manipulated objects for this entire collection. private void SetChangedItems() { - if( _changedItemsSaveCounter == ChangeCounter ) + if( _changedItemsSaveCounter == _collection.ChangeCounter ) { return; } try { - _changedItemsSaveCounter = ChangeCounter; + _changedItemsSaveCounter = _collection.ChangeCounter; _changedItems.Clear(); // Skip IMCs because they would result in far too many false-positive items, // since they are per set instead of per item-slot/item/variant. diff --git a/Penumbra/Interop/Resolver/PathResolver.Material.cs b/Penumbra/Interop/Resolver/PathResolver.Material.cs index 64e82ab7..f52b4389 100644 --- a/Penumbra/Interop/Resolver/PathResolver.Material.cs +++ b/Penumbra/Interop/Resolver/PathResolver.Material.cs @@ -113,7 +113,7 @@ public unsafe partial class PathResolver { if( nonDefault && type == ResourceType.Mtrl ) { - var fullPath = new FullPath( $"|{collection.Name}_{collection.RecomputeCounter}|{path}" ); + var fullPath = new FullPath( $"|{collection.Name}_{collection.ChangeCounter}|{path}" ); data = ( fullPath, collection ); } else diff --git a/Penumbra/Meta/Manager/MetaManager.Imc.cs b/Penumbra/Meta/Manager/MetaManager.Imc.cs index 96ff29f6..2c6f656c 100644 --- a/Penumbra/Meta/Manager/MetaManager.Imc.cs +++ b/Penumbra/Meta/Manager/MetaManager.Imc.cs @@ -145,7 +145,7 @@ public partial class MetaManager } private FullPath CreateImcPath( Utf8GamePath path ) - => new($"|{_collection.Name}_{_collection.RecomputeCounter}|{path}"); + => new($"|{_collection.Name}_{_collection.ChangeCounter}|{path}"); private static unsafe bool ImcLoadHandler( Utf8String split, Utf8String path, ResourceManager* resourceManager,