Make temporary collection always respect ownership.

This commit is contained in:
Ottermandias 2024-10-30 20:40:10 +01:00
parent 2358eb378d
commit ed717c69f9
2 changed files with 21 additions and 9 deletions

View file

@ -48,8 +48,7 @@ public sealed partial class IndividualCollections : IReadOnlyList<(string Displa
// Handle generic NPC // Handle generic NPC
var npcIdentifier = _actors.CreateIndividualUnchecked(IdentifierType.Npc, ByteString.Empty, var npcIdentifier = _actors.CreateIndividualUnchecked(IdentifierType.Npc, ByteString.Empty,
ushort.MaxValue, ushort.MaxValue, identifier.Kind, identifier.DataId);
identifier.Kind, identifier.DataId);
if (npcIdentifier.IsValid && _individuals.TryGetValue(npcIdentifier, out collection)) if (npcIdentifier.IsValid && _individuals.TryGetValue(npcIdentifier, out collection))
return true; return true;
@ -58,8 +57,7 @@ public sealed partial class IndividualCollections : IReadOnlyList<(string Displa
return false; return false;
identifier = _actors.CreateIndividualUnchecked(IdentifierType.Player, identifier.PlayerName, identifier = _actors.CreateIndividualUnchecked(IdentifierType.Player, identifier.PlayerName,
identifier.HomeWorld.Id, identifier.HomeWorld.Id, ObjectKind.None, uint.MaxValue);
ObjectKind.None, uint.MaxValue);
return CheckWorlds(identifier, out collection); return CheckWorlds(identifier, out collection);
} }
case IdentifierType.Npc: return _individuals.TryGetValue(identifier, out collection); case IdentifierType.Npc: return _individuals.TryGetValue(identifier, out collection);

View file

@ -126,7 +126,7 @@ public sealed unsafe class CollectionResolver(
// The lobby uses the first 8 cutscene actors. // The lobby uses the first 8 cutscene actors.
var idx = gameObject->ObjectIndex - ObjectIndex.CutsceneStart.Index; var idx = gameObject->ObjectIndex - ObjectIndex.CutsceneStart.Index;
if (characterList->CharacterMapping.FindFirst(m => m.ClientObjectIndex == idx, out var mapping) 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 item = charaEntry.Value;
var identifier = actors.CreatePlayer(new ByteString(item->Name), item->HomeWorldId); var identifier = actors.CreatePlayer(new ByteString(item->Name), item->HomeWorldId);
@ -199,10 +199,24 @@ public sealed unsafe class CollectionResolver(
/// <summary> Check both temporary and permanent character collections. Temporary first. </summary> /// <summary> Check both temporary and permanent character collections. Temporary first. </summary>
private ModCollection? CollectionByIdentifier(ActorIdentifier identifier) private ModCollection? CollectionByIdentifier(ActorIdentifier identifier)
=> tempCollections.Collections.TryGetCollection(identifier, out var collection) {
|| collectionManager.Active.Individuals.TryGetCollection(identifier, out collection) if (tempCollections.Collections.TryGetCollection(identifier, out var collection))
? collection return collection;
: null;
// 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;
}
/// <summary> Check for the Yourself collection. </summary> /// <summary> Check for the Yourself collection. </summary>
private ModCollection? CheckYourself(ActorIdentifier identifier, Actor actor) private ModCollection? CheckYourself(ActorIdentifier identifier, Actor actor)