diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 85615d3a5..36d4bd363 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -14449,6 +14449,21 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) } } + // paying more than the merchant charges for the same quantity would be a money loop + uint64 buy_unit_price = (item->Price * item->SellRate); + if (!RuleB(Merchant, UseClassicPriceMod)) { + buy_unit_price *= RuleR(Merchant, SellCostMod); + } + + if (RuleB(Merchant, UsePriceMod)) { + buy_unit_price *= Client::CalcPriceMod(vendor, false); + } + + const uint64 buy_back_cap = buy_unit_price * cost_quantity; + if (price > buy_back_cap) { + price = static_cast(buy_back_cap); + } + AddMoneyToPP(price); // Update merchant stock and refresh client