diff --git a/Penumbra.GameData/Actors/ActorManager.Identifiers.cs b/Penumbra.GameData/Actors/ActorManager.Identifiers.cs index ad3af449..47c03b82 100644 --- a/Penumbra.GameData/Actors/ActorManager.Identifiers.cs +++ b/Penumbra.GameData/Actors/ActorManager.Identifiers.cs @@ -110,7 +110,7 @@ public partial class ActorManager /// Compute an ActorIdentifier from a GameObject. If check is true, the values are checked for validity. /// public unsafe ActorIdentifier FromObject(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* actor, - out FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* owner, bool check = true) + out FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* owner, bool allowPlayerNpc, bool check) { owner = null; if (actor == null) @@ -150,6 +150,19 @@ public partial class ActorManager ? CreateOwned(name, homeWorld, ObjectKind.BattleNpc, nameId) : CreateIndividualUnchecked(IdentifierType.Owned, name, homeWorld, ObjectKind.BattleNpc, nameId); } + + // Hack to support Anamnesis changing ObjectKind for NPC faces. + if (nameId == 0 && allowPlayerNpc) + { + var name = new ByteString(actor->Name); + if (!name.IsEmpty) + { + var homeWorld = ((Character*)actor)->HomeWorld; + return check + ? CreatePlayer(name, homeWorld) + : CreateIndividualUnchecked(IdentifierType.Player, name, homeWorld, ObjectKind.None, uint.MaxValue); + } + } return check ? CreateNpc(ObjectKind.BattleNpc, nameId, actor->ObjectIndex) @@ -230,11 +243,11 @@ public partial class ActorManager } public unsafe ActorIdentifier FromObject(GameObject? actor, out FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* owner, - bool check = true) - => FromObject((FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)(actor?.Address ?? IntPtr.Zero), out owner, check); + bool allowPlayerNpc, bool check) + => FromObject((FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)(actor?.Address ?? IntPtr.Zero), out owner, allowPlayerNpc, check); - public unsafe ActorIdentifier FromObject(GameObject? actor, bool check = true) - => FromObject(actor, out _, check); + public unsafe ActorIdentifier FromObject(GameObject? actor, bool allowPlayerNpc, bool check) + => FromObject(actor, out _, allowPlayerNpc, check); public ActorIdentifier CreateIndividual(IdentifierType type, ByteString name, ushort homeWorld, ObjectKind kind, uint dataId) => type switch diff --git a/Penumbra/Api/PenumbraApi.cs b/Penumbra/Api/PenumbraApi.cs index 49ad61cd..ebb09ddb 100644 --- a/Penumbra/Api/PenumbraApi.cs +++ b/Penumbra/Api/PenumbraApi.cs @@ -677,7 +677,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi return PenumbraApiEc.InvalidArgument; } - var identifier = Penumbra.Actors.FromObject( Dalamud.Objects[ actorIndex ] ); + var identifier = Penumbra.Actors.FromObject( Dalamud.Objects[ actorIndex ], false, false ); if( !identifier.IsValid ) { return PenumbraApiEc.InvalidArgument; diff --git a/Penumbra/Collections/IndividualCollections.Access.cs b/Penumbra/Collections/IndividualCollections.Access.cs index 1c02c19c..669dd086 100644 --- a/Penumbra/Collections/IndividualCollections.Access.cs +++ b/Penumbra/Collections/IndividualCollections.Access.cs @@ -114,10 +114,10 @@ public sealed partial class IndividualCollections : IReadOnlyList< (string Displ } public bool TryGetCollection( GameObject? gameObject, out ModCollection? collection ) - => TryGetCollection( _actorManager.FromObject( gameObject, false ), out collection ); + => TryGetCollection( _actorManager.FromObject( gameObject, true, false ), out collection ); public unsafe bool TryGetCollection( FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* gameObject, out ModCollection? collection ) - => TryGetCollection( _actorManager.FromObject( gameObject, out _, false ), out collection ); + => TryGetCollection( _actorManager.FromObject( gameObject, out _, true, false ), out collection ); private bool CheckWorlds( ActorIdentifier identifier, out ModCollection? collection ) { diff --git a/Penumbra/Interop/Resolver/PathResolver.Identification.cs b/Penumbra/Interop/Resolver/PathResolver.Identification.cs index 28d9905a..6cb37665 100644 --- a/Penumbra/Interop/Resolver/PathResolver.Identification.cs +++ b/Penumbra/Interop/Resolver/PathResolver.Identification.cs @@ -53,7 +53,7 @@ public unsafe partial class PathResolver return IdentifiedCache.Set( collection2, ActorIdentifier.Invalid, gameObject ); } - var identifier = Penumbra.Actors.FromObject( gameObject, out var owner, false ); + var identifier = Penumbra.Actors.FromObject( gameObject, out var owner, true, false ); identifier = Penumbra.CollectionManager.Individuals.ConvertSpecialIdentifier( identifier ); var collection = CollectionByIdentifier( identifier ) ?? CheckYourself( identifier, gameObject ) diff --git a/Penumbra/Interop/Resolver/PathResolver.cs b/Penumbra/Interop/Resolver/PathResolver.cs index aa1f9055..439040c1 100644 --- a/Penumbra/Interop/Resolver/PathResolver.cs +++ b/Penumbra/Interop/Resolver/PathResolver.cs @@ -1,14 +1,10 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; -using Dalamud.Data; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.Object; using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using FFXIVClientStructs.FFXIV.Client.System.Resource; -using Lumina.Excel.GeneratedSheets; -using OtterGui; using Penumbra.Collections; using Penumbra.GameData.Enums; using Penumbra.Interop.Loader; diff --git a/Penumbra/UI/ConfigWindow.DebugTab.cs b/Penumbra/UI/ConfigWindow.DebugTab.cs index 8036863e..4a234656 100644 --- a/Penumbra/UI/ConfigWindow.DebugTab.cs +++ b/Penumbra/UI/ConfigWindow.DebugTab.cs @@ -192,7 +192,7 @@ public partial class ConfigWindow { ImGuiUtil.DrawTableColumn( $"{( ( GameObject* )obj.Address )->ObjectIndex}" ); ImGuiUtil.DrawTableColumn( $"0x{obj.Address:X}" ); - var identifier = Penumbra.Actors.FromObject( obj, true ); + var identifier = Penumbra.Actors.FromObject( obj, false, true ); ImGuiUtil.DrawTableColumn( Penumbra.Actors.ToString( identifier ) ); var id = obj.ObjectKind == ObjectKind.BattleNpc ? $"{identifier.DataId} | {obj.DataId}" : identifier.DataId.ToString(); ImGuiUtil.DrawTableColumn( id );