mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-05 21:52:26 +00:00
Trader Direct purchase updated and tested
This commit is contained in:
parent
e57a789dce
commit
32daa4834c
@ -4679,10 +4679,7 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::vector<temp> queue;
|
std::vector<temp> queue;
|
||||||
auto free_id = GetInv().FindFirstFreeSlotThatFitsItem(inst->GetItem());
|
auto quantity = inst->GetCharges();
|
||||||
auto quantity = inst->GetCharges(); // 2
|
|
||||||
auto remaining_quantity = 0;
|
|
||||||
auto item_size = inst->GetItem()->Size;
|
|
||||||
|
|
||||||
for (int i = EQ::invslot::GENERAL_BEGIN; i <= EQ::invslot::GENERAL_END; i++) {
|
for (int i = EQ::invslot::GENERAL_BEGIN; i <= EQ::invslot::GENERAL_END; i++) {
|
||||||
auto inv_inst = GetInv().GetItem(i);
|
auto inv_inst = GetInv().GetItem(i);
|
||||||
|
|||||||
@ -1373,8 +1373,8 @@ static void BazaarAuditTrail(const char *seller, const char *buyer, const char *
|
|||||||
|
|
||||||
void Client::BuyTraderItem(const EQApplicationPacket *app)
|
void Client::BuyTraderItem(const EQApplicationPacket *app)
|
||||||
{
|
{
|
||||||
auto in = reinterpret_cast<TraderBuy_Struct*>(app->pBuffer);
|
auto in = reinterpret_cast<TraderBuy_Struct *>(app->pBuffer);
|
||||||
auto trader = entity_list.GetClientByID(in->trader_id);
|
auto trader = entity_list.GetClientByID(in->trader_id);
|
||||||
|
|
||||||
if (!trader || !trader->IsTrader()) {
|
if (!trader || !trader->IsTrader()) {
|
||||||
Message(Chat::Red, "The trader could not be found.");
|
Message(Chat::Red, "The trader could not be found.");
|
||||||
@ -1408,6 +1408,12 @@ void Client::BuyTraderItem(const EQApplicationPacket *app)
|
|||||||
quantity
|
quantity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (CheckLoreConflict(inst_copy->GetItem())) {
|
||||||
|
MessageString(Chat::Red, DUPLICATE_LORE);
|
||||||
|
TradeRequestFailed(app);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (in->price * quantity <= 0) {
|
if (in->price * quantity <= 0) {
|
||||||
Message(Chat::Red, "Internal error. Aborting trade. Please report this to the ServerOP. Error code is 1");
|
Message(Chat::Red, "Internal error. Aborting trade. Please report this to the ServerOP. Error code is 1");
|
||||||
trader->Message(Chat::Red, "Internal error. Aborting trade. Please report this to the ServerOP. Error code is 1");
|
trader->Message(Chat::Red, "Internal error. Aborting trade. Please report this to the ServerOP. Error code is 1");
|
||||||
@ -1446,40 +1452,18 @@ void Client::BuyTraderItem(const EQApplicationPacket *app)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogTrading("Customer Paid: <green>[{}] in Copper", total_cost);
|
|
||||||
|
|
||||||
uint32 platinum = total_cost / 1000;
|
|
||||||
total_cost -= platinum * 1000;
|
|
||||||
uint32 gold = total_cost / 100;
|
|
||||||
total_cost -= gold * 100;
|
|
||||||
uint32 silver = total_cost / 10;
|
|
||||||
total_cost -= silver * 10;
|
|
||||||
uint32 copper = total_cost;
|
|
||||||
|
|
||||||
LogTrading("Trader Received: [{}] Platinum, [{}] Gold, [{}] Silver, [{}] Copper", platinum, gold, silver, copper);
|
|
||||||
ReturnTraderReq(app, quantity, buy_inst->GetID());
|
|
||||||
|
|
||||||
if (CheckLoreConflict(buy_inst->GetItem())) {
|
|
||||||
MessageString(Chat::Red, DUPLICATE_LORE);
|
|
||||||
TradeRequestFailed(app);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!trader->RemoveItemByItemUniqueId(buy_inst->GetUniqueID(), quantity)) {
|
if (!trader->RemoveItemByItemUniqueId(buy_inst->GetUniqueID(), quantity)) {
|
||||||
|
AddMoneyToPP(total_cost, true);
|
||||||
Message(Chat::Red, "The Trader no longer has the item. Please refresh the merchant window.");
|
Message(Chat::Red, "The Trader no longer has the item. Please refresh the merchant window.");
|
||||||
TradeRequestFailed(app);
|
TradeRequestFailed(app);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
trader->AddMoneyToPP(copper, silver, gold, platinum, true);
|
trader->AddMoneyToPP(total_cost, true);
|
||||||
|
|
||||||
// if (buy_inst->IsStackable() && !TryStacking(buy_inst, ItemPacketTrade, false, false)) {
|
|
||||||
// MessageString(Chat::Red, HOW_CAN_YOU_BUY_MORE, trader->GetCleanName());
|
|
||||||
// TradeRequestFailed(app);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (!PutItemInInventoryWithStacking(inst_copy.get())) {
|
if (!PutItemInInventoryWithStacking(inst_copy.get())) {
|
||||||
|
trader->TakeMoneyFromPP(total_cost, true);
|
||||||
|
trader->PutItemInInventoryWithStacking(buy_inst);
|
||||||
MessageString(Chat::Red, HOW_CAN_YOU_BUY_MORE, trader->GetCleanName());
|
MessageString(Chat::Red, HOW_CAN_YOU_BUY_MORE, trader->GetCleanName());
|
||||||
TradeRequestFailed(app);
|
TradeRequestFailed(app);
|
||||||
return;
|
return;
|
||||||
@ -1498,6 +1482,11 @@ void Client::BuyTraderItem(const EQApplicationPacket *app)
|
|||||||
strn0cpy(data->item_unique_id, buy_inst->GetUniqueID().data(), sizeof(data->item_unique_id));
|
strn0cpy(data->item_unique_id, buy_inst->GetUniqueID().data(), sizeof(data->item_unique_id));
|
||||||
trader->QueuePacket(trader_packet.get());
|
trader->QueuePacket(trader_packet.get());
|
||||||
|
|
||||||
|
QueuePacket(app);
|
||||||
|
|
||||||
|
LogTrading("Customer Paid: [{}] in Copper", total_cost);
|
||||||
|
LogTrading("Trader Received: [{}] in Copper", total_cost);
|
||||||
|
|
||||||
if (merchant_quantity > quantity) {
|
if (merchant_quantity > quantity) {
|
||||||
std::unique_ptr<EQ::ItemInstance> vendor_inst(buy_inst ? buy_inst->Clone() : nullptr);
|
std::unique_ptr<EQ::ItemInstance> vendor_inst(buy_inst ? buy_inst->Clone() : nullptr);
|
||||||
vendor_inst->SetMerchantCount(merchant_quantity - quantity);
|
vendor_inst->SetMerchantCount(merchant_quantity - quantity);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user