feat(vendor): Slice 6 buy arc — shop items are real objects, vendor selection is THE selection, and Buy works (0x005F)
Some checks are pending
Headless portability / portable-headless (ubuntu-latest) (push) Waiting to run
Headless portability / portable-headless (windows-latest) (push) Waiting to run
Headless portability / linux-graphical (push) Waiting to run
Headless portability / linux-vulkan (push) Waiting to run

Three ordered pieces in one landing (the shared controller/composition
files carry all three; the internal order was 6.1 -> 6.2 -> 6.3):

6.1 VendorShopItemMaterializer diff-merges the shop list into the live
ClientObjectTable on VendorState transitions (so client-local close and
session teardown retire the entries too) and never claims a guid it did
not add — ACE's UniqueItemsForSale can re-list a guid a player once
held (AP-163 files the collision-skip; no retail counterpart traced).
Right-click examine on shop items now routes through the ordinary
appraisal path — the 5.4 F7c blocker dissolves with the table entries.

6.2 SelectionChangeSource.Vendor: row clicks, auto-select, and examine
all flow through the canonical SelectionState; the status bar and the
existing byte-faithful StackSplitQuantityState slider light up
unmodified. VendorSplitPolicy is the single 0xDC41CB0 mask owner; the
slider VALUE seeds to 1 for exempt items while maxSplitSize keeps the
stack (the splitSize/maxSplitSize distinction, research §B.3).
Selection clears at retail's actual site — VendorItemsUI::RemoveFromShop
(pc:202848), not a CloseVendor-level clear that does not exist.

6.3 BuildBuy (0x005F): vendorGuid, count, (i32 amount, u32 guid) pairs,
and the trailing alternateCurrencyId the REAL client sends
(CM_Vendor::Event_Buy pc:689288) though ACE's reader ignores it.
TryBuy rides the EXISTING J5.2 one-request-at-a-time reservation and
completes on UseDone; the Buy button disables while a request is in
flight. The reconciliation round-trip (money property update, inventory
CreateObject, ApproachVendor refresh -> panel rebuild) is proven by a
synthetic-inbound test against existing machinery — no new owner.

Register: AP-161 narrowed (selection + examine residuals close;
staging/Sell remain; double-click-to-buy confirmed ABSENT from retail
with negative evidence cited — we match retail). AP-162 files the
conscious no-client-side-affordability-precheck deferral.

Clean-room complete solution: 11,368 passed / 4 skipped / 0 failed.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-07 20:28:26 +02:00
parent c884a938e0
commit 97cf873870
19 changed files with 1577 additions and 65 deletions

View file

@ -93,6 +93,7 @@ public sealed class SelectedObjectController : IRetainedPanelController
private readonly Action<uint> _sendQueryItemMana;
private readonly StackSplitQuantityState _splitQuantity;
private readonly SelectionState _selection;
private readonly Func<uint, bool> _isVendorSplitExempt;
private readonly Action<Action<uint, float>> _unsubscribeHealthChanged;
private readonly Action<Action<uint, float, bool>> _unsubscribeItemManaChanged;
private readonly Action<Action<ClientObject>> _unsubscribeObjectUpdated;
@ -126,7 +127,8 @@ public sealed class SelectedObjectController : IRetainedPanelController
UiDatFont? datFont,
StackSplitQuantityState splitQuantity,
Action<Action<ClientObject>> subscribeObjectUpdated,
Action<Action<ClientObject>> unsubscribeObjectUpdated)
Action<Action<ClientObject>> unsubscribeObjectUpdated,
Func<uint, bool> isVendorSplitExempt)
{
_isHealthTarget = isHealthTarget;
_isOwnedByPlayer = isOwnedByPlayer;
@ -139,6 +141,8 @@ public sealed class SelectedObjectController : IRetainedPanelController
_sendQueryItemMana = sendQueryItemMana;
_splitQuantity = splitQuantity ?? throw new ArgumentNullException(nameof(splitQuantity));
_selection = selection ?? throw new ArgumentNullException(nameof(selection));
_isVendorSplitExempt = isVendorSplitExempt
?? throw new ArgumentNullException(nameof(isVendorSplitExempt));
_unsubscribeHealthChanged = unsubscribeHealthChanged;
_unsubscribeItemManaChanged = unsubscribeItemManaChanged;
_unsubscribeObjectUpdated = unsubscribeObjectUpdated;
@ -250,6 +254,18 @@ public sealed class SelectedObjectController : IRetainedPanelController
/// <param name="stackSize">Returns the stack size for a guid (0 or 1 = non-stacked).</param>
/// <param name="sendQueryHealth">Sends retail <c>QueryHealth (0x01BF)</c>; may be a no-op offline.</param>
/// <param name="datFont">Dat font for the name label; null = debug bitmap font fallback.</param>
/// <param name="isVendorSplitExempt">
/// Slice 6.2: retail's <c>gmToolbarUI::HandleSelectionChanged</c> vendor
/// branch (<c>pc:198779-198790</c>) — true when the selected guid is
/// owned by the currently-open vendor (its <c>ClientObject.ContainerId</c>
/// equals <c>VendorState.VendorId</c>) AND its type intersects
/// <see cref="VendorSplitPolicy.SplitExemptMask"/>. When true, a stack
/// seeds to quantity 1 instead of the full authored stack size — see
/// <see cref="ApplySelection"/>. <c>VendorUiController.VendorSplitSize</c>
/// answers the SAME question for vendor's own display text via the SAME
/// <see cref="VendorSplitPolicy"/> helper, so the mask exists in exactly
/// one place (composed at <c>InteractionRetainedUiComposition</c>).
/// </param>
public static SelectedObjectController Bind(
ImportedLayout layout,
SelectionState selection,
@ -269,14 +285,16 @@ public sealed class SelectedObjectController : IRetainedPanelController
UiDatFont? datFont,
StackSplitQuantityState splitQuantity,
Action<Action<ClientObject>> subscribeObjectUpdated,
Action<Action<ClientObject>> unsubscribeObjectUpdated)
Action<Action<ClientObject>> unsubscribeObjectUpdated,
Func<uint, bool> isVendorSplitExempt)
=> new SelectedObjectController(
layout, selection,
subscribeHealthChanged, unsubscribeHealthChanged,
subscribeItemManaChanged, unsubscribeItemManaChanged,
isHealthTarget, isOwnedByPlayer, name, healthPercent, hasHealth, stackSize,
sendQueryHealth, manaPercent, sendQueryItemMana, datFont,
splitQuantity, subscribeObjectUpdated, unsubscribeObjectUpdated);
splitQuantity, subscribeObjectUpdated, unsubscribeObjectUpdated,
isVendorSplitExempt);
/// <summary>
/// Port of <c>gmToolbarUI::HandleSelectionChanged</c> (<c>:198635</c>):
@ -335,11 +353,20 @@ public sealed class SelectedObjectController : IRetainedPanelController
// gmToolbarUI::HandleSelectionChanged @ 0x004BF52D..0x004BF666:
// stacks initialize to the full stack, show the numeric entry + horizontal
// slider, and set the stacked selection state. Vendor-owned stack precedence
// is intentionally absent until the vendor panel owns an active vendor id.
// slider, and set the stacked selection state. Slice 6.2: the
// vendor-owned branch (pc:198779-198790, mask literal pc:198784)
// seeds splitSize (the INITIAL value) to 1 instead of the full stack
// when the selection is owned by the currently-open vendor AND its
// type intersects VendorSplitPolicy.SplitExemptMask — see the
// isVendorSplitExempt parameter doc. maxSplitSize (the slider's
// RANGE) is always the full authored stack size regardless of
// exemption (research doc §B.3: "Sets GenItemHolder::splitSize =
// seed, GenItemHolder::maxSplitSize = stackSize") — only the
// starting VALUE differs, not the ceiling.
if (stackSize > 1u)
{
_splitQuantity.Reset(stackSize);
uint seed = _isVendorSplitExempt(g) ? 1u : stackSize;
_splitQuantity.Reset(stackSize, initialValue: seed);
if (_stackSizeEntry is not null) _stackSizeEntry.Visible = true;
if (_stackSizeSlider is not null) _stackSizeSlider.Visible = true;
}