Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/AcDream.Core/Items/ClientObjectTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ public IReadOnlyList<ClientObject> GetEquippedBy(uint wielderId) =>
.ToArray()
: Array.Empty<ClientObject>();

/// <summary>Whether server listings cover the owner and every nested pack.</summary>
/// <summary>Whether server listings cover the owner and every nested pack (a focus needs none).</summary>
public bool HasCompleteInventory(uint ownerId)
{
if (ownerId == 0 || _pendingMoves.Count != 0)
Expand All @@ -1225,7 +1225,10 @@ public bool HasCompleteInventory(uint ownerId)
{
if (!_objects.TryGetValue(id, out ClientObject? item))
return false;
if (IsContainerListMember(item))
// A focus takes a container slot but holds nothing, and the
// server never sends a listing for one.
if (IsContainerListMember(item)
&& !InventoryContainerPlacementPolicy.IsFocus(item))
pending.Push(id);
}
}
Expand Down
13 changes: 13 additions & 0 deletions tests/AcDream.Core.Tests/Items/InventoryCompletenessTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,17 @@ public void EmptyAuthoritativeInventoryIsComplete()
table.InitializeInventoryManifest(1, Array.Empty<ContainerContentEntry>());
Assert.True(table.HasCompleteInventory(1));
}

[Fact]
public void SpellFocusNeverListedDoesNotBlockCompleteness()
{
// ACE lists a focus (container type 2) in the container slots but
// never sends its contents, since a focus holds nothing.
var table = new ClientObjectTable();
table.InitializeInventoryManifest(1,
[new ContainerContentEntry(2, 1), new ContainerContentEntry(3, 2)]);
Assert.False(table.HasCompleteInventory(1));
table.ReplaceContents(2, Array.Empty<uint>());
Assert.True(table.HasCompleteInventory(1));
}
}