From c4f6038d1ef629515e830e316ef11dc4871868da Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 30 Oct 2024 20:40:10 +0100 Subject: [PATCH] Make temporary collection always respect ownership. --- .../PathResolving/CollectionResolver.cs | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Penumbra/Interop/PathResolving/CollectionResolver.cs b/Penumbra/Interop/PathResolving/CollectionResolver.cs index 1705f871..36c31af3 100644 --- a/Penumbra/Interop/PathResolving/CollectionResolver.cs +++ b/Penumbra/Interop/PathResolving/CollectionResolver.cs @@ -126,7 +126,7 @@ public sealed unsafe class CollectionResolver( // The lobby uses the first 8 cutscene actors. var idx = gameObject->ObjectIndex - ObjectIndex.CutsceneStart.Index; if (characterList->CharacterMapping.FindFirst(m => m.ClientObjectIndex == idx, out var mapping) - && lobby->LobbyData.CharaSelectEntries.FindFirst(e => e.Value->ContentId == mapping.ContentId, out var charaEntry)) + && lobby->LobbyData.CharaSelectEntries.FindFirst(e => e.Value->ContentId == mapping.ContentId, out var charaEntry)) { var item = charaEntry.Value; var identifier = actors.CreatePlayer(new ByteString(item->Name), item->HomeWorldId); @@ -199,10 +199,24 @@ public sealed unsafe class CollectionResolver( /// Check both temporary and permanent character collections. Temporary first. private ModCollection? CollectionByIdentifier(ActorIdentifier identifier) - => tempCollections.Collections.TryGetCollection(identifier, out var collection) - || collectionManager.Active.Individuals.TryGetCollection(identifier, out collection) - ? collection - : null; + { + if (tempCollections.Collections.TryGetCollection(identifier, out var collection)) + return collection; + + // Always inherit ownership for temporary collections. + if (identifier.Type is IdentifierType.Owned) + { + var playerIdentifier = actors.CreateIndividualUnchecked(IdentifierType.Player, identifier.PlayerName, + identifier.HomeWorld.Id, ObjectKind.None, uint.MaxValue); + if (tempCollections.Collections.TryGetCollection(playerIdentifier, out collection)) + return collection; + } + + if (collectionManager.Active.Individuals.TryGetCollection(identifier, out collection)) + return collection; + + return null; + } /// Check for the Yourself collection. private ModCollection? CheckYourself(ActorIdentifier identifier, Actor actor)