diff --git a/Penumbra/Interop/Loader/ResourceLoader.Debug.cs b/Penumbra/Interop/Loader/ResourceLoader.Debug.cs index 87b79fe9..4fb934f4 100644 --- a/Penumbra/Interop/Loader/ResourceLoader.Debug.cs +++ b/Penumbra/Interop/Loader/ResourceLoader.Debug.cs @@ -15,8 +15,8 @@ namespace Penumbra.Interop.Loader; public unsafe partial class ResourceLoader { // If in debug mode, this logs any resource at refcount 0 that gets decremented again, and skips the decrement instead. - private delegate byte ResourceHandleDecRef( ResourceHandle* handle ); - private readonly Hook _decRefHook; + private delegate byte ResourceHandleDecRef( ResourceHandle* handle ); + private readonly Hook< ResourceHandleDecRef > _decRefHook; public delegate IntPtr ResourceHandleDestructor( ResourceHandle* handle ); @@ -146,8 +146,8 @@ public unsafe partial class ResourceLoader // Find a resource in the resource manager by its category, extension and crc-hash public static ResourceHandle* FindResource( ResourceCategory cat, ResourceType ext, uint crc32 ) { - var manager = *ResourceManager; - var catIdx = ( uint )cat >> 0x18; + ref var manager = ref *ResourceManager; + var catIdx = ( uint )cat >> 0x18; cat = ( ResourceCategory )( ushort )cat; var category = ( ResourceGraph.CategoryContainer* )manager->ResourceGraph->ContainerArray + ( int )cat; var extMap = FindInMap( ( StdMap< uint, Pointer< StdMap< uint, Pointer< ResourceHandle > > > >* )category->CategoryMaps[ catIdx ], @@ -161,18 +161,25 @@ public unsafe partial class ResourceLoader return ret == null ? null : ret->Value; } - public delegate void ExtMapAction( ResourceCategory category, StdMap< uint, Pointer< StdMap< uint, Pointer< ResourceHandle > > > >* graph ); + public delegate void ExtMapAction( ResourceCategory category, StdMap< uint, Pointer< StdMap< uint, Pointer< ResourceHandle > > > >* graph, int idx ); public delegate void ResourceMapAction( uint ext, StdMap< uint, Pointer< ResourceHandle > >* graph ); public delegate void ResourceAction( uint crc32, ResourceHandle* graph ); // Iteration functions through the resource manager. public static void IterateGraphs( ExtMapAction action ) { - var manager = *ResourceManager; + ref var manager = ref *ResourceManager; foreach( var resourceType in Enum.GetValues< ResourceCategory >().SkipLast( 1 ) ) { var graph = ( ResourceGraph.CategoryContainer* )manager->ResourceGraph->ContainerArray + ( int )resourceType; - action( resourceType, graph->MainMap ); + for( var i = 0; i < 20; ++i ) + { + var map = ( StdMap< uint, Pointer< StdMap< uint, Pointer< ResourceHandle > > > >* )graph->CategoryMaps[ i ]; + if( map != null ) + { + action( resourceType, map, i ); + } + } } } @@ -184,7 +191,7 @@ public unsafe partial class ResourceLoader public static void IterateResources( ResourceAction action ) { - IterateGraphs( ( _, extMap ) + IterateGraphs( ( _, extMap, _ ) => IterateExtMap( extMap, ( _, resourceMap ) => IterateResourceMap( resourceMap, action ) ) ); } diff --git a/Penumbra/Mods/Editor/Mod.Editor.Duplicates.cs b/Penumbra/Mods/Editor/Mod.Editor.Duplicates.cs index 299d644b..4dbb9bff 100644 --- a/Penumbra/Mods/Editor/Mod.Editor.Duplicates.cs +++ b/Penumbra/Mods/Editor/Mod.Editor.Duplicates.cs @@ -235,7 +235,7 @@ public partial class Mod // Recursively delete all empty directories starting from the given directory. // Deletes inner directories first, so that a tree of empty directories is actually deleted. - private void DeleteEmptyDirectories( DirectoryInfo baseDir ) + private static void DeleteEmptyDirectories( DirectoryInfo baseDir ) { try { diff --git a/Penumbra/UI/ConfigWindow.ModPanel.Edit.cs b/Penumbra/UI/ConfigWindow.ModPanel.Edit.cs index 56b4a58e..2377bb77 100644 --- a/Penumbra/UI/ConfigWindow.ModPanel.Edit.cs +++ b/Penumbra/UI/ConfigWindow.ModPanel.Edit.cs @@ -564,8 +564,8 @@ public partial class ConfigWindow // Move from one group to another by deleting, then adding the option. var sourceGroup = _dragDropGroupIdx; var sourceOption = _dragDropOptionIdx; - var option = @group[ _dragDropOptionIdx ]; - var priority = @group.OptionPriority( _dragDropGroupIdx ); + var option = group[ _dragDropOptionIdx ]; + var priority = group.OptionPriority( _dragDropGroupIdx ); panel._delayedActions.Enqueue( () => { Penumbra.ModManager.DeleteOption( panel._mod, sourceGroup, sourceOption ); diff --git a/Penumbra/UI/ConfigWindow.ResourceTab.cs b/Penumbra/UI/ConfigWindow.ResourceTab.cs index f72a5dc6..801878cf 100644 --- a/Penumbra/UI/ConfigWindow.ResourceTab.cs +++ b/Penumbra/UI/ConfigWindow.ResourceTab.cs @@ -119,14 +119,14 @@ public partial class ConfigWindow // Draw a full category for the resource manager. private unsafe void DrawCategoryContainer( ResourceCategory category, - StdMap< uint, Pointer< StdMap< uint, Pointer< ResourceHandle > > > >* map ) + StdMap< uint, Pointer< StdMap< uint, Pointer< ResourceHandle > > > >* map, int idx ) { if( map == null ) { return; } - using var tree = ImRaii.TreeNode( $"({( uint )category:D2}) {category} - {map->Count}###{( uint )category}" ); + using var tree = ImRaii.TreeNode( $"({( uint )category:D2}) {category} (Ex {idx}) - {map->Count}###{( uint )category}_{idx}" ); if( tree ) { SetTableWidths();