fix(vendor): Slice 6 review corrections — ownership-checked retire, live slider display, drag-proof shop rows, hardened buy reservation
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
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
All nine findings from the buy-arc review, at root: F1 the materializer's retire pass re-checks ownership (guid->vendorId map; remove only while the live object's ContainerId still equals the recording vendor) — buying a player-sold UNIQUE no longer deletes the item you just purchased; the discriminating reparent-then-refresh test pins it. F2 the cost/name display subscribes to the live split state and shares ONE quantity computation with Buy (retail re-renders per slider tick: RecvNotice_StackSliderChanged 0x004C4500) — the sentence and the charge can no longer disagree. F3 shop rows never mint drag payloads (UiItemSlot.AllowDragSource gates both IsDragSource AND GetDragPayload — the second gate was caught by this pass's own test). F4 sendBuy reports whether anything was sent; a null-session buy cancels the reservation instead of leaking BusyCount forever. F5 the retire loop snapshots, isolates per-guid observer failures, and clears its tracking in finally and Dispose — teardown convergence can no longer wedge. F6 auto-select is retail's unconditional first-filtered-item shape (pc:201180-201184; the survival-check was our invention and the comment claiming otherwise is corrected). F7 non-stack buys clamp to quantity 1 locally (BuySingleItem pc:201669). F8 the Add button is hard-disabled until staging exists. F9 AP-161/162/163 rewritten to the post-fix reality. Clean-room complete solution: 11,378 passed / 4 skipped / 0 failed. The #350 render-ledger overflow observed this session is under separate investigation and is NOT addressed here. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
97cf873870
commit
3c9fc57adb
11 changed files with 670 additions and 116 deletions
|
|
@ -176,7 +176,10 @@ public sealed class VendorUiControllerTests
|
|||
sendDrop: null,
|
||||
sendExamine: Examines.Add,
|
||||
sendBuy: (vendorGuid, itemGuid, amount, alternateCurrencyId) =>
|
||||
Buys.Add((vendorGuid, itemGuid, amount, alternateCurrencyId)));
|
||||
{
|
||||
Buys.Add((vendorGuid, itemGuid, amount, alternateCurrencyId));
|
||||
return true;
|
||||
});
|
||||
|
||||
Controller = VendorUiController.Bind(
|
||||
layout,
|
||||
|
|
@ -293,6 +296,15 @@ public sealed class VendorUiControllerTests
|
|||
});
|
||||
|
||||
h.ItemList.GetItem(0)!.Clicked?.Invoke();
|
||||
// F2 (Slice 6 review): the display now reads the LIVE split state
|
||||
// instead of recomputing a static seed. Production seeds this via
|
||||
// SelectedObjectController (mounted on the toolbar, subscribed to
|
||||
// SelectionState.Changed BEFORE VendorUiController — RetailUiRuntime
|
||||
// MountToolbar() runs before MountVendor()); this harness doesn't
|
||||
// mount that controller, so the test seeds SplitQuantity directly to
|
||||
// stand in for it, matching the SAME not-exempt full-stack seed
|
||||
// SelectedObjectController.ApplySelection would have computed.
|
||||
h.SplitQuantity.Reset(100u, initialValue: 100u);
|
||||
|
||||
// No authored PluralName -> ACCWeenieObject::GetObjectName falls back
|
||||
// to the singular name UNCHANGED (not an invented "Arrows" + "s").
|
||||
|
|
@ -319,6 +331,10 @@ public sealed class VendorUiControllerTests
|
|||
});
|
||||
|
||||
h.ItemList.GetItem(0)!.Clicked?.Invoke();
|
||||
// F2: exempt seed is 1 regardless of the 50-unit authored stack —
|
||||
// see the split-exempt comment on the sibling test above for why
|
||||
// this harness seeds SplitQuantity explicitly.
|
||||
h.SplitQuantity.Reset(50u, initialValue: 1u);
|
||||
|
||||
Assert.Equal("Bread", GetText(h.ItemNameText));
|
||||
Assert.Equal(
|
||||
|
|
@ -338,10 +354,56 @@ public sealed class VendorUiControllerTests
|
|||
});
|
||||
|
||||
h.ItemList.GetItem(0)!.Clicked?.Invoke();
|
||||
// F2: Key is not split-exempt -> full authored stack (10).
|
||||
h.SplitQuantity.Reset(10u, initialValue: 10u);
|
||||
|
||||
Assert.Equal("10 Iron Keys", GetText(h.ItemNameText));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SliderChange_AfterSelection_UpdatesNameAndPriceToLiveQuantity_MatchingWhatBuyWouldCharge()
|
||||
{
|
||||
// F2 (Slice 6 review): retail re-runs UpdateItemsUI on every slider
|
||||
// change (gmVendorUI::RecvNotice_StackSliderChanged,
|
||||
// pc:203262-203278) -- the OLD implementation froze the display's
|
||||
// quantity at a static per-selection seed while BuySelectedItem
|
||||
// separately read the LIVE split, so a slider drag after selecting
|
||||
// never updated the sentence/price and could show a DIFFERENT price
|
||||
// than what Buy would actually charge. Both now go through the SAME
|
||||
// ResolveBuyQuantity, proven here by asserting the displayed price
|
||||
// equals the amount the subsequent Buy press actually sends.
|
||||
var h = new Harness();
|
||||
h.State.Apply(VendorGuid, Profile(sellRate: 2.0f), new[]
|
||||
{
|
||||
// perUnit = 1000/100 = 10 (MissileWeapon, not split-exempt).
|
||||
new VendorShopItem(
|
||||
StackedItemGuid, -1, 3u, "Arrows", (uint)ItemType.MissileWeapon, 300u, 1000,
|
||||
DescStackSize: 100),
|
||||
});
|
||||
// F6 auto-selects the sole item; the harness's un-mounted-toolbar
|
||||
// split state starts at its class default (Value=1/Maximum=1) —
|
||||
// singular display, matching a fresh, not-yet-slider-touched
|
||||
// selection.
|
||||
Assert.Equal("Arrows", GetText(h.ItemNameText));
|
||||
Assert.Equal(
|
||||
$"costs {20:N0} (you have {Harness.DefaultPlayerCoinValue:N0})",
|
||||
GetText(h.ItemCostText));
|
||||
|
||||
// Player drags the slider to 40 AFTER selecting -- no re-click, no
|
||||
// re-selection, purely a StackSplitQuantityState.Changed event.
|
||||
h.SplitQuantity.Reset(100u, initialValue: 40u);
|
||||
|
||||
// SellPrice = ceil(2.0*10*40 - 0.1) = 800.
|
||||
Assert.Equal("40 Arrows", GetText(h.ItemNameText));
|
||||
Assert.Equal(
|
||||
$"cost {800:N0} (you have {Harness.DefaultPlayerCoinValue:N0})",
|
||||
GetText(h.ItemCostText));
|
||||
|
||||
h.BuyButton.OnClick!.Invoke();
|
||||
|
||||
Assert.Equal(40, h.Buys.Single().Amount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SelectingItem_WithAlternateCurrency_ShowsFullRetailCostSentence()
|
||||
{
|
||||
|
|
@ -370,10 +432,34 @@ public sealed class VendorUiControllerTests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void NoSelection_DisablesBuyAndAddButtons_SelectionEnablesThem()
|
||||
public void NoSelection_DisablesBuyButton_SelectionEnablesIt()
|
||||
{
|
||||
var h = new Harness();
|
||||
Assert.False(h.BuyButton.Enabled);
|
||||
|
||||
h.State.Apply(VendorGuid, Profile(), new[]
|
||||
{
|
||||
new VendorShopItem(ArmorItemGuid, -1, 2u, "Chainmail", (uint)ItemType.Armor, 200u, 500),
|
||||
});
|
||||
|
||||
// F4 auto-selects the sole item on open, so Buy is already enabled
|
||||
// — SetState(1), pc:202784-202789.
|
||||
Assert.True(h.BuyButton.Enabled);
|
||||
|
||||
// Closing clears the selection -> SetState(0xd), pc:202572-202577.
|
||||
h.State.Close();
|
||||
Assert.False(h.BuyButton.Enabled);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddButton_IsPermanentlyDisabled_RegardlessOfSelection()
|
||||
{
|
||||
// F8 (Slice 6 review): "Add to List" has no wired OnClick at all
|
||||
// (staging into the "Buying" tab is deferred, contract decision 6)
|
||||
// — an enabled button that silently does nothing on click is a
|
||||
// dead-affordance bug, worse than a disabled one. It must never
|
||||
// enable, with or without a selection.
|
||||
var h = new Harness();
|
||||
Assert.False(h.AddButton.Enabled);
|
||||
|
||||
h.State.Apply(VendorGuid, Profile(), new[]
|
||||
|
|
@ -381,14 +467,10 @@ public sealed class VendorUiControllerTests
|
|||
new VendorShopItem(ArmorItemGuid, -1, 2u, "Chainmail", (uint)ItemType.Armor, 200u, 500),
|
||||
});
|
||||
|
||||
// F4 auto-selects the sole item on open, so the buttons are already
|
||||
// enabled — SetState(1), pc:202784-202789.
|
||||
Assert.True(h.BuyButton.Enabled);
|
||||
Assert.True(h.AddButton.Enabled);
|
||||
// F4/F6 auto-selects the sole item on open -- Add stays disabled.
|
||||
Assert.False(h.AddButton.Enabled);
|
||||
|
||||
// Closing clears the selection -> SetState(0xd), pc:202572-202577.
|
||||
h.State.Close();
|
||||
Assert.False(h.BuyButton.Enabled);
|
||||
Assert.False(h.AddButton.Enabled);
|
||||
}
|
||||
|
||||
|
|
@ -473,6 +555,29 @@ public sealed class VendorUiControllerTests
|
|||
Assert.NotNull(h.ItemList.EmptySlotFactory);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShopRow_NeverMintsADragPayload()
|
||||
{
|
||||
// F3 (Slice 6 review): with shop items materialized into
|
||||
// ClientObjectTable (Slice 6.1), a draggable vendor cell would pass
|
||||
// every destination handler's existence guard -- a pack drop would
|
||||
// send a real PutItemInContainer for vendor stock, the shortcut bar
|
||||
// would persist a dangling guid, and PlaceIn3D would fire. Retail
|
||||
// excludes vendor/salvage lists from ItemList_BeginDrag entirely; a
|
||||
// populated shop row must never become a drag source at all.
|
||||
var h = new Harness();
|
||||
h.State.Apply(VendorGuid, Profile(), new[]
|
||||
{
|
||||
new VendorShopItem(ArmorItemGuid, -1, 2u, "Chainmail", (uint)ItemType.Armor, 200u, 500),
|
||||
});
|
||||
|
||||
UiItemSlot cell = h.ItemList.GetItem(0)!;
|
||||
|
||||
Assert.NotEqual(0u, cell.ItemId); // occupied -- would otherwise be a drag source by default
|
||||
Assert.False(cell.IsDragSource);
|
||||
Assert.Null(cell.GetDragPayload());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Opened_WithDifferentVendor_ResetsToFirstPresentCategory_NotThePreviousVendors()
|
||||
{
|
||||
|
|
@ -529,6 +634,43 @@ public sealed class VendorUiControllerTests
|
|||
Assert.Equal("Food", h.TypeMenu.Items.Single(i => Equals(i.Payload, h.TypeMenu.Selected)).Label);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Refreshed_SameVendor_ReselectsFirstItemUnconditionally_NotThePreviouslySelectedSurvivor()
|
||||
{
|
||||
// F6 (Slice 6 review): retail's VendorItemsUI::UpdateItemsList
|
||||
// selects UNCONDITIONALLY on every rebuild call site this
|
||||
// controller reaches (pc:201180-201184, confirmed via
|
||||
// VendorItemsUI::OpenVendor's unconditional clamp +
|
||||
// SetSelectedItem(...,1) at pc:201022, which every vendor
|
||||
// open/refresh runs regardless of the sameVendor flag) -- there is
|
||||
// NO survival test. A same-vendor refresh that re-lists the SAME
|
||||
// two items in the SAME order must reset to the FIRST one even
|
||||
// though the player's prior selection (the second item) is still
|
||||
// present in the new snapshot -- this is the case that would have
|
||||
// diverged under the OLD "preserve if it survives" logic.
|
||||
const uint SecondArmorGuid = 0x60000110u;
|
||||
var h = new Harness();
|
||||
var items = new[]
|
||||
{
|
||||
new VendorShopItem(ArmorItemGuid, -1, 2u, "Chainmail", (uint)ItemType.Armor, 200u, 500),
|
||||
new VendorShopItem(SecondArmorGuid, -1, 4u, "Buckler", (uint)ItemType.Armor, 900u, 40),
|
||||
};
|
||||
h.State.Apply(VendorGuid, Profile(), items);
|
||||
Assert.Equal(ArmorItemGuid, h.ItemList.GetItem(0)!.ItemId); // auto-selected first
|
||||
|
||||
// Player explicitly picks the SECOND item.
|
||||
h.ItemList.GetItem(1)!.Clicked?.Invoke();
|
||||
Assert.True(h.ItemList.GetItem(1)!.Selected);
|
||||
|
||||
// SAME vendor, SAME two items, SAME order -> Refreshed transition.
|
||||
h.State.Apply(VendorGuid, Profile(), items);
|
||||
|
||||
// Retail resets to the FIRST item, not the still-present second one.
|
||||
Assert.True(h.ItemList.GetItem(0)!.Selected);
|
||||
Assert.False(h.ItemList.GetItem(1)!.Selected);
|
||||
Assert.Equal("Chainmail", GetText(h.ItemNameText));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CategoryMenu_OpensAndSelectsThroughRealHitPath_UsingAuthoredPopupGeometry()
|
||||
{
|
||||
|
|
@ -723,6 +865,36 @@ public sealed class VendorUiControllerTests
|
|||
Assert.Equal(25, h.Buys.Single().Amount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuyButton_Press_NonStackedItem_IgnoresAStaleSliderFromAPreviouslySelectedStackableItem()
|
||||
{
|
||||
// F7 (Slice 6 review): retail's BuySingleItem (pc:201674-201681)
|
||||
// gates on the SELECTED item's OWN stack size FIRST -- quantity 1
|
||||
// whenever it is <=1, regardless of whatever
|
||||
// GenItemHolder::splitSize still holds from a PREVIOUSLY selected,
|
||||
// DIFFERENT, stackable item. Without this guard,
|
||||
// ResolveBuyQuantity's GetObjectSplitSize(item.ItemGuid, selected,
|
||||
// stackSize) call trivially returns the live Value for ANY selected
|
||||
// item (item.ItemGuid always equals the selection guid at this call
|
||||
// site) -- leaking a stale quantity into a non-stack purchase.
|
||||
var h = new Harness();
|
||||
h.State.Apply(VendorGuid, Profile(), new[]
|
||||
{
|
||||
new VendorShopItem(ArmorItemGuid, -1, 2u, "Chainmail", (uint)ItemType.Armor, 200u, 500),
|
||||
});
|
||||
// Simulate a stale slider left over from a PREVIOUSLY selected,
|
||||
// different, stackable item -- this harness doesn't mount
|
||||
// SelectedObjectController, which in production would already have
|
||||
// reset the slider on selecting the (non-stack) armor; seeding it
|
||||
// directly here proves the clamp doesn't depend on that reset
|
||||
// having run.
|
||||
h.SplitQuantity.Reset(50u, initialValue: 30u);
|
||||
|
||||
h.BuyButton.OnClick!.Invoke();
|
||||
|
||||
Assert.Equal(1, h.Buys.Single().Amount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuyButton_Press_AlternateCurrencyVendor_ForwardsTheVendorsTradeWcid()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue