From 90def9b882622eddd9e6d60b5c8889308e7507a1 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 12 Feb 2023 23:26:21 -0500 Subject: [PATCH] [Quest API] (Performance) Check event exists before export and execute EVENT_TRADE (#2906) # Notes - Optionally parse this event instead of always doing so. --- zone/bot.cpp | 14 ++++++++++---- zone/trading.cpp | 6 ++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index aede84c23..85e1150e1 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -5208,8 +5208,11 @@ void Bot::PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client* std::vector items(insts, insts + std::size(insts)); // Check if EVENT_TRADE accepts any items - std::vector item_list(items.begin(), items.end()); - parse->EventBot(EVENT_TRADE, this, client, "", 0, &item_list); + if (parse->BotHasQuestSub(EVENT_TRADE)) { + std::vector item_list(items.begin(), items.end()); + parse->EventBot(EVENT_TRADE, this, client, "", 0, &item_list); + } + CalcBotStats(false); } else { @@ -5224,8 +5227,11 @@ void Bot::PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client* std::vector items(insts, insts + std::size(insts)); // Check if EVENT_TRADE accepts any items - std::vector item_list(items.begin(), items.end()); - parse->EventBot(EVENT_TRADE, this, client, "", 0, &item_list); + if (parse->BotHasQuestSub(EVENT_TRADE)) { + std::vector item_list(items.begin(), items.end()); + parse->EventBot(EVENT_TRADE, this, client, "", 0, &item_list); + } + CalcBotStats(false); } } diff --git a/zone/trading.cpp b/zone/trading.cpp index ba6606b70..1ad0bedfc 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -851,8 +851,10 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st tradingWith->FaceTarget(this); } - std::vector item_list(items.begin(), items.end()); - parse->EventNPC(EVENT_TRADE, tradingWith->CastToNPC(), this, "", 0, &item_list); + if (parse->HasQuestSub(tradingWith->GetNPCTypeID(), EVENT_TRADE)) { + std::vector item_list(items.begin(), items.end()); + parse->EventNPC(EVENT_TRADE, tradingWith->CastToNPC(), this, "", 0, &item_list); + } for(int i = 0; i < 4; ++i) { if(insts[i]) {