Skip to content
Open
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
6 changes: 5 additions & 1 deletion src/AcDream.Core.Net/GameEventWiring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,13 @@ void NotifyOfEnchantmentRemoval(uint spellId)
for (int i = 0; i < shopItems.Length; i++)
{
VendorApproach.ItemProfile item = p.Value.Items[i];
// ACE sends a shop create-list row's authored stack size
// as-is, and world content authors many of them as 0 rather
// than -1. ACE never limits a create-list item, so any
// non-positive count means the vendor never runs out.
shopItems[i] = new VendorShopItem(
item.ItemGuid,
item.StackSize,
item.StackSize > 0 ? item.StackSize : VendorComponentFill.UnlimitedStock,
item.Desc.WeenieClassId,
item.Desc.Name,
item.Desc.ItemType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,46 @@ public void ApproachVendorEvent_PopulatesVendorStateWithProfileAndItems()
Assert.Equal(250, item.Value);
}

[Fact]
public void ApproachVendorEvent_ZeroStockListing_IsUnlimited()
{
using GameRuntime runtime = Create();
VendorState vendor = runtime.InventoryOwner.Vendor;
using IDisposable wiring = Wire(vendor);

// ACE sends a shop create-list row's authored stack size as-is, and
// world content authors many of them as 0. ACE never limits a
// create-list item, so 0 carries the same meaning as -1.
Dispatch(BuildApproachVendorPayload(
vendorGuid: 0x40001000u,
categories: 0x42u,
minValue: 0u,
maxValue: 500u,
dealsMagic: false,
buyPrice: 0.8f,
sellPrice: 1.3f,
currencyWcid: 0u,
currencyAmount: 0u,
currencyName: "",
items:
[
new VendorItemFixture(
ItemGuid: 0x50002000u, StackSize: 0, Name: "Iron Sword",
WeenieClassId: 42u, RawIconId: 0x1234u,
ItemType: (uint)ItemType.Weapon, Value: 250),
new VendorItemFixture(
ItemGuid: 0x50002001u, StackSize: -1, Name: "Bread",
WeenieClassId: 43u, RawIconId: 0x1235u,
ItemType: (uint)ItemType.Food, Value: 5),
new VendorItemFixture(
ItemGuid: 0x50002002u, StackSize: 3, Name: "Leather Cap",
WeenieClassId: 44u, RawIconId: 0x1236u,
ItemType: (uint)ItemType.Armor, Value: 40),
]));

Assert.Equal([-1, -1, 3], vendor.Items.Select(i => i.StackSize));
}

[Fact]
public void SecondApproachVendorEventFromDifferentVendor_ReplacesTheSession()
{
Expand Down