From 2358eb378deebd960b16619f243e16fc9a86e845 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 30 Oct 2024 17:31:38 +0100 Subject: [PATCH] Fix issue with characters in login screen, maybe. --- .../PathResolving/CollectionResolver.cs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Penumbra/Interop/PathResolving/CollectionResolver.cs b/Penumbra/Interop/PathResolving/CollectionResolver.cs index 313c4f8b..1705f871 100644 --- a/Penumbra/Interop/PathResolving/CollectionResolver.cs +++ b/Penumbra/Interop/PathResolving/CollectionResolver.cs @@ -1,6 +1,7 @@ using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using FFXIVClientStructs.FFXIV.Client.UI.Agent; +using OtterGui; using OtterGui.Services; using Penumbra.Collections; using Penumbra.Collections.Manager; @@ -62,10 +63,11 @@ public sealed unsafe class CollectionResolver( try { - if (useCache && cache.TryGetValue(gameObject, out var data)) + // Login screen reuses the same actors and can not be cached. + if (LoginScreen(gameObject, out var data)) return data; - if (LoginScreen(gameObject, out data)) + if (useCache && cache.TryGetValue(gameObject, out data)) return data; if (Aesthetician(gameObject, out data)) @@ -116,16 +118,17 @@ public sealed unsafe class CollectionResolver( return true; } - var notYetReady = false; - var lobby = AgentLobby.Instance(); - if (lobby != null) + var notYetReady = false; + var lobby = AgentLobby.Instance(); + var characterList = CharaSelectCharacterList.Instance(); + if (lobby != null && characterList != null) { - var span = lobby->LobbyData.CharaSelectEntries.AsSpan(); // The lobby uses the first 8 cutscene actors. var idx = gameObject->ObjectIndex - ObjectIndex.CutsceneStart.Index; - if (idx >= 0 && idx < span.Length && span[idx].Value != null) + if (characterList->CharacterMapping.FindFirst(m => m.ClientObjectIndex == idx, out var mapping) + && lobby->LobbyData.CharaSelectEntries.FindFirst(e => e.Value->ContentId == mapping.ContentId, out var charaEntry)) { - var item = span[idx].Value; + var item = charaEntry.Value; var identifier = actors.CreatePlayer(new ByteString(item->Name), item->HomeWorldId); Penumbra.Log.Verbose( $"Identified {identifier.Incognito(null)} in cutscene for actor {idx + 200} at 0x{(ulong)gameObject:X} of race {(gameObject->IsCharacter() ? ((Character*)gameObject)->DrawData.CustomizeData.Race.ToString() : "Unknown")}."); @@ -141,7 +144,7 @@ public sealed unsafe class CollectionResolver( var collection = collectionManager.Active.ByType(CollectionType.Yourself) ?? CollectionByAttributes(gameObject, ref notYetReady) ?? collectionManager.Active.Default; - ret = notYetReady ? collection.ToResolveData(gameObject) : cache.Set(collection, ActorIdentifier.Invalid, gameObject); + ret = collection.ToResolveData(gameObject); return true; }