From 347e4b202372617f78bf9c0d68ff38ffb1f2b63c Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 20 Dec 2022 21:18:37 +0100 Subject: [PATCH] Add changed item for meta manipulations to effective changes. --- Penumbra/Collections/ModCollection.Cache.cs | 27 ++++++++++++++++----- Penumbra/CommandHandler.cs | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Penumbra/Collections/ModCollection.Cache.cs b/Penumbra/Collections/ModCollection.Cache.cs index 055d9f43..46d049e8 100644 --- a/Penumbra/Collections/ModCollection.Cache.cs +++ b/Penumbra/Collections/ModCollection.Cache.cs @@ -474,25 +474,40 @@ public partial class ModCollection // 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. var identifier = Penumbra.Identifier; - foreach( var (resolved, modPath) in ResolvedFiles.Where( file => !file.Key.Path.EndsWith( "imc"u8 ) ) ) + var items = new SortedList< string, object? >(512); + + void AddItems( IMod mod ) { - foreach( var (name, obj) in identifier.Identify( resolved.ToString() ) ) + foreach( var (name, obj) in items ) { if( !_changedItems.TryGetValue( name, out var data ) ) { - _changedItems.Add( name, ( new SingleArray< IMod >( modPath.Mod ), obj ) ); + _changedItems.Add( name, ( new SingleArray< IMod >( mod ), obj ) ); } - else if( !data.Item1.Contains( modPath.Mod ) ) + else if( !data.Item1.Contains( mod ) ) { - _changedItems[ name ] = ( data.Item1.Append( modPath.Mod ), obj is int x && data.Item2 is int y ? x + y : obj ); + _changedItems[ name ] = ( data.Item1.Append( mod ), obj is int x && data.Item2 is int y ? x + y : obj ); } else if( obj is int x && data.Item2 is int y ) { _changedItems[ name ] = ( data.Item1, x + y ); } } + + items.Clear(); + } + + foreach( var (resolved, modPath) in ResolvedFiles.Where( file => !file.Key.Path.EndsWith( "imc"u8 ) ) ) + { + identifier.Identify( items, resolved.ToString() ); + AddItems( modPath.Mod ); + } + + foreach( var (manip, mod) in MetaManipulations ) + { + Mod.ComputeChangedItems( items, manip ); + AddItems( mod ); } - // TODO: Meta Manipulations } catch( Exception e ) { diff --git a/Penumbra/CommandHandler.cs b/Penumbra/CommandHandler.cs index 2498fa9d..3ab97d9c 100644 --- a/Penumbra/CommandHandler.cs +++ b/Penumbra/CommandHandler.cs @@ -397,7 +397,7 @@ public class CommandHandler : IDisposable return false; } - var settings = collection.Settings[ mod.Index ]; + var settings = collection!.Settings[ mod.Index ]; switch( state ) { case 0: