diff --git a/Penumbra/Interop/Resolver/PathResolver.Data.cs b/Penumbra/Interop/Resolver/PathResolver.Data.cs index 57d55935..9701cd2a 100644 --- a/Penumbra/Interop/Resolver/PathResolver.Data.cs +++ b/Penumbra/Interop/Resolver/PathResolver.Data.cs @@ -24,15 +24,16 @@ public unsafe partial class PathResolver [Signature( "E8 ?? ?? ?? ?? 48 85 C0 74 21 C7 40" )] public Hook< CharacterBaseCreateDelegate >? CharacterBaseCreateHook; + private ModCollection? _lastCreatedCollection; + private IntPtr CharacterBaseCreateDetour( uint a, IntPtr b, IntPtr c, byte d ) { - using var cmp = MetaChanger.ChangeCmp( this, out var collection ); + using var cmp = MetaChanger.ChangeCmp( this, out _lastCreatedCollection ); var ret = CharacterBaseCreateHook!.Original( a, b, c, d ); if( LastGameObject != null ) { - DrawObjectToObject[ ret ] = ( collection!, LastGameObject->ObjectIndex ); + DrawObjectToObject[ ret ] = (_lastCreatedCollection!, LastGameObject->ObjectIndex ); } - return ret; } diff --git a/Penumbra/Interop/Resolver/PathResolver.Meta.cs b/Penumbra/Interop/Resolver/PathResolver.Meta.cs index 5ac6dd0e..5267ba89 100644 --- a/Penumbra/Interop/Resolver/PathResolver.Meta.cs +++ b/Penumbra/Interop/Resolver/PathResolver.Meta.cs @@ -110,7 +110,7 @@ public unsafe partial class PathResolver // RSP public delegate void RspSetupCharacterDelegate( IntPtr drawObject, IntPtr unk2, float unk3, IntPtr unk4, byte unk5 ); - [Signature( "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 88 54 24 ?? 57 41 56 ", DetourName = "RspSetupCharacterDetour" )] + [Signature( "48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 88 54 24 ?? 57 41 56", DetourName = "RspSetupCharacterDetour" )] public Hook< RspSetupCharacterDelegate >? RspSetupCharacterHook; private void RspSetupCharacterDetour( IntPtr drawObject, IntPtr unk2, float unk3, IntPtr unk4, byte unk5 ) diff --git a/Penumbra/Interop/Resolver/PathResolver.Resolve.cs b/Penumbra/Interop/Resolver/PathResolver.Resolve.cs index ebdb9ff0..c283e9ce 100644 --- a/Penumbra/Interop/Resolver/PathResolver.Resolve.cs +++ b/Penumbra/Interop/Resolver/PathResolver.Resolve.cs @@ -12,7 +12,6 @@ public unsafe partial class PathResolver // Humans private IntPtr ResolveDecalDetour( IntPtr drawObject, IntPtr path, IntPtr unk3, uint unk4 ) => ResolvePathDetour( drawObject, ResolveDecalPathHook!.Original( drawObject, path, unk3, unk4 ) ); - private IntPtr ResolveEidDetour( IntPtr drawObject, IntPtr path, IntPtr unk3 ) => ResolvePathDetour( drawObject, ResolveEidPathHook!.Original( drawObject, path, unk3 ) ); diff --git a/Penumbra/Interop/Resolver/PathResolver.cs b/Penumbra/Interop/Resolver/PathResolver.cs index d25517da..4f73e762 100644 --- a/Penumbra/Interop/Resolver/PathResolver.cs +++ b/Penumbra/Interop/Resolver/PathResolver.cs @@ -32,11 +32,14 @@ public partial class PathResolver : IDisposable private bool CharacterResolver( Utf8GamePath gamePath, ResourceCategory _1, ResourceType type, int _2, out (FullPath?, object?) data ) { // Check if the path was marked for a specific collection, - // or if it is a file loaded by a material, and if we are currently in a material load. + // or if it is a file loaded by a material, and if we are currently in a material load, + // or if it is a face decal path and the current mod collection is set. // If not use the default collection. // We can remove paths after they have actually been loaded. // A potential next request will add the path anew. - var nonDefault = HandleMaterialSubFiles( type, out var collection ) || PathCollections.TryRemove( gamePath.Path, out collection ); + var nonDefault = HandleMaterialSubFiles( type, out var collection ) + || PathCollections.TryRemove( gamePath.Path, out collection ) + || HandleDecalFile( type, gamePath, out collection ); if( !nonDefault ) { collection = Penumbra.CollectionManager.Default; @@ -53,6 +56,20 @@ public partial class PathResolver : IDisposable return true; } + private bool HandleDecalFile( ResourceType type, Utf8GamePath gamePath, out ModCollection? collection ) + { + if( type == ResourceType.Tex + && _lastCreatedCollection != null + && gamePath.Path.Substring( "chara/common/texture/".Length ).StartsWith( 'd', 'e', 'c', 'a', 'l', '_', 'f', 'a', 'c', 'e' ) ) + { + collection = _lastCreatedCollection; + return true; + } + + collection = null; + return false; + } + public void Enable() { if( Enabled )