VendorTrade: allow vendors with 0 buy/sell rates #10

Closed
AwfulWaffle wants to merge 2 commits from AwfulWaffle/RynthCore:vendor-zero-rate into main

2026-10-30

Daniel Wallace
VendorTrade: price a 0-rate vendor at 0, log free vendors, pin wiring
Review follow-up to the 0-rate fix.

- A vendor rate of exactly 0 now means free: PlayerPaysForStack and
  VendorPaysForStack return 0 instead of the 1-per-stack floor (notes
  included). Every rate above 0 keeps the stock ACE floor. With the
  floor, a free storage vendor refused withdrawals to a player with no
  pyreals ("costs N pyreals, you have 0") and deposits with no free pack
  slot (the estimated "payout" needed one), though the vault charges and
  pays nothing. The server stays the authority on the real price.
- The two price helpers move to VendorRatePolicy.cs; VendorTrade keeps
  thin forwarders so its call sites are unchanged.
- A vendor with buy=0 and sell=0 is logged once per vendor id as a
  zero-rate (free) vendor.
- tools\VendorRateTests covers the pricing (rate 0 -> cost 0 and payout
  0; rate 0.001, value 1 -> still 1) and reads VendorTrade.cs to pin that
  it calls VendorRatePolicy, so reverting the wiring fails the test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 20:16:09 -07:00
Daniel Wallace
VendorTrade: allow vendors with 0 buy/sell rates
A custom server can run a free storage vendor whose BuyPrice and
SellPrice are both 0: it pays nothing for items handed to it and charges
nothing to take them back. The profile check required rate > 0, so
opening such a vendor logged

  VendorTrade: vendor 0x8007810B profile rates look wrong (buy=0 sell=0);
  trading with it is off.

and every VendorBuy/VendorSell (RynthAi AutoVendor, RynthLua vendor
actions, /rc vendor) was refused with "vendor profile unreadable".

The rate check now accepts finite rates in [0, 1000). Negative, NaN,
infinite and huge values are still treated as a misread profile, and
the warning still fires for them. The check moves to
VendorRatePolicy.cs so tools\VendorRateTests can compile it in.

Rate consumers checked: PlayerPaysForStack, VendorPaysForStack,
EstimateBuy and UnitPrice multiply by the rate and floor at 1 per stack
(the stock ACE rule), so a 0 rate gives a 1-per-stack estimate; there
is no division by a rate anywhere. FillInfo and the /rc vendor info
line only copy or print the rates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 20:09:32 -07:00