fix(vendor): keep 27 buyback items and drop the oldest

The buyback inventory grew by 9 slots whenever it was nearly full, so
the vendor's buyback page kept resizing. Live kept 27 items: a 2014
capture of 29 sales shows that on the 28th, the server sent
RemoveItemFromInventory (buyback inventory) for the first item sold,
then added the new one.

The buyback inventory now keeps its size. Before a sale needs a new
buyback slot and the inventory holds 27 or more items, the oldest items
(lowest object ID: each sale gives a new, higher ID) are removed. Sales
that fit on an existing buyback stack remove nothing. The removal is not
counted again by the economy ledger, which counted the items as gone
when they were sold.

Fixes issue 1129.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-27 08:57:30 -05:00
parent 02108055e7
commit c759bd1a40
5 changed files with 125 additions and 3 deletions

View File

@@ -10,6 +10,8 @@
#include "eReplicaComponentType.h"
enum class eVendorTransactionResult : uint32_t;
class InventoryComponent;
class Item;
struct SoldItem {
SoldItem(const LOT lot, const int32_t sortPriority) {
@@ -61,6 +63,13 @@ public:
// Sends a VendorTransactionResult targeting target to sysAddr only.
static void SendTransactionResult(LWOOBJID target, const SystemAddress& sysAddr, eVendorTransactionResult result);
// How many items the buyback inventory keeps (the vendor window's buyback page)
static constexpr size_t BUYBACK_SIZE = 27;
// Before count of sold go to the buyback inventory: drops the oldest buyback items while it is full and they need
// a slot of their own.
static void MakeRoomInBuyback(InventoryComponent& inventory, const Item& sold, uint32_t count);
private:
void HandleMrReeCameras();
bool SetupItem(LOT item);