Skip to content

Commit e93785f

Browse files
authored
[Fix] Add check for simultaneous direct vendor and parcel Trader/Buyer Purchase (#4778)
1 parent 3c2545c commit e93785f

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

zone/client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ class Client : public Mob
443443
int64 ValidateBuyLineCost(std::map<uint32, BuylineItemDetails_Struct>& item_map);
444444
bool DoBarterBuyerChecks(BuyerLineSellItem_Struct& sell_line);
445445
bool DoBarterSellerChecks(BuyerLineSellItem_Struct& sell_line);
446+
void CancelBuyerTradeWindow();
447+
void CancelTraderTradeWindow();
446448

447449
void FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho);
448450
bool ShouldISpawnFor(Client *c) { return !GMHideMe(c) && !IsHoveringForRespawn(); }

zone/client_packet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15463,7 +15463,7 @@ void Client::Handle_OP_TraderBuy(const EQApplicationPacket *app)
1546315463
);
1546415464
Message(
1546515465
Chat::Yellow,
15466-
"Direct inventory delivey is not yet implemented. Please visit the vendor directly or purchase via parcel delivery."
15466+
"Direct inventory delivery is not yet implemented. Please visit the vendor directly or purchase via parcel delivery."
1546715467
);
1546815468
in->method = BazaarByDirectToInventory;
1546915469
in->sub_action = Failed;

zone/trading.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,6 +1894,13 @@ void Client::SellToBuyer(const EQApplicationPacket *app)
18941894
break;
18951895
}
18961896

1897+
if (sell_line.purchase_method == BarterInBazaar && buyer->IsThereACustomer()) {
1898+
auto customer = entity_list.GetClientByID(buyer->GetCustomerID());
1899+
if (customer) {
1900+
customer->CancelBuyerTradeWindow();
1901+
}
1902+
}
1903+
18971904
if (!DoBarterBuyerChecks(sell_line)) {
18981905
return;
18991906
};
@@ -3825,3 +3832,18 @@ bool Client::DoBarterSellerChecks(BuyerLineSellItem_Struct &sell_line)
38253832

38263833
return true;
38273834
}
3835+
3836+
void Client::CancelBuyerTradeWindow()
3837+
{
3838+
auto end_session = new EQApplicationPacket(OP_Barter, sizeof(BuyerRemoveItemFromMerchantWindow_Struct));
3839+
auto data = reinterpret_cast<BuyerRemoveItemFromMerchantWindow_Struct *>(end_session->pBuffer);
3840+
data->action = Barter_BuyerInspectBegin;
3841+
3842+
FastQueuePacket(&end_session);
3843+
}
3844+
3845+
void Client::CancelTraderTradeWindow()
3846+
{
3847+
auto end_session = new EQApplicationPacket(OP_ShopEnd);
3848+
FastQueuePacket(&end_session);
3849+
}

zone/worldserver.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3786,6 +3786,13 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
37863786
return;
37873787
}
37883788

3789+
if (trader_pc->IsThereACustomer()) {
3790+
auto customer = entity_list.GetClientByID(trader_pc->GetCustomerID());
3791+
if (customer) {
3792+
customer->CancelTraderTradeWindow();
3793+
}
3794+
}
3795+
37893796
auto item_sn = Strings::ToUnsignedBigInt(in->trader_buy_struct.serial_number);
37903797
auto outapp = std::make_unique<EQApplicationPacket>(OP_Trader, sizeof(TraderBuy_Struct));
37913798
auto data = (TraderBuy_Struct *) outapp->pBuffer;
@@ -3981,6 +3988,12 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
39813988
worldserver.SendPacket(pack);
39823989
return;
39833990
}
3991+
if (buyer->IsThereACustomer()) {
3992+
auto customer = entity_list.GetClientByID(buyer->GetCustomerID());
3993+
if (customer) {
3994+
customer->CancelBuyerTradeWindow();
3995+
}
3996+
}
39843997

39853998
BuyerLineSellItem_Struct sell_line{};
39863999
sell_line.item_id = in->buy_item_id;

0 commit comments

Comments
 (0)