fix: a trade offer takes no undeletable item and no unapproved model

The client's trade window also refuses an item that can not be
deleted and a brick built model whose moderation status is not
approved. An offer with such an item is now refused like the other
offers the window can not make.

Whether an item can be deleted is what the inventory already works
out for a delete: not the item of the mount the player rides, and not
an item its row of the DeletionRestrictions table restricts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 16:06:31 -06:00
parent d5723696f4
commit ba0c5756ad
3 changed files with 72 additions and 3 deletions

View File

@@ -43,7 +43,7 @@ std::optional<std::vector<TradeItem>> Trade::ResolveOffer(
if (tradeItem.itemCount == 0 || !seen.insert(tradeItem.itemId).second) return std::nullopt;
const auto held = findHeld(tradeItem.itemId);
if (!held || held->count == 0 || held->bound || held->equipped) return std::nullopt;
if (!held || held->count == 0 || held->bound || held->equipped || !held->deletable || !held->approved) return std::nullopt;
resolved.push_back({ tradeItem.itemId, held->lot, std::min(tradeItem.itemCount, held->count) });
}
@@ -55,10 +55,22 @@ std::function<std::optional<HeldTradeItem>(LWOOBJID)> Trade::HeldIn(const Invent
return [&inventory](const LWOOBJID itemId) -> std::optional<HeldTradeItem> {
const auto* const item = inventory.FindItemById(itemId);
if (!item) return std::nullopt;
return HeldTradeItem{ item->GetLot(), item->GetCount(), item->GetBound(), item->IsEquipped() };
return HeldTradeItem{
item->GetLot(), item->GetCount(), item->GetBound(), item->IsEquipped(),
inventory.CanDelete(*item), IsApproved(item->GetLot(), item->GetConfig())
};
};
}
bool Trade::IsApproved(const LOT lot, const LwoNameValue& config) {
if (lot != BrickBuiltModelLot) return true;
const auto status = config.find(u"userModelMod");
if (status == config.end() || status->second->GetValueType() != eLDFType::LDF_TYPE_S32) return false;
return static_cast<const LDFData<int32_t>*>(status->second.get())->GetValue() == ApprovedModerationStatus;
}
Trade::~Trade() {
}