Skip to content

Commit

Permalink
[Quest API] (Performance) Check event exists before export and execut…
Browse files Browse the repository at this point in the history
…e EVENT_TRADE (#2906)

# Notes
- Optionally parse this event instead of always doing so.
  • Loading branch information
Kinglykrab authored Feb 13, 2023
1 parent 8415682 commit 90def9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 10 additions & 4 deletions zone/bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5208,8 +5208,11 @@ void Bot::PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client*
std::vector<EQ::ItemInstance*> items(insts, insts + std::size(insts));

// Check if EVENT_TRADE accepts any items
std::vector<std::any> item_list(items.begin(), items.end());
parse->EventBot(EVENT_TRADE, this, client, "", 0, &item_list);
if (parse->BotHasQuestSub(EVENT_TRADE)) {
std::vector<std::any> item_list(items.begin(), items.end());
parse->EventBot(EVENT_TRADE, this, client, "", 0, &item_list);
}

CalcBotStats(false);

} else {
Expand All @@ -5224,8 +5227,11 @@ void Bot::PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client*
std::vector<EQ::ItemInstance*> items(insts, insts + std::size(insts));

// Check if EVENT_TRADE accepts any items
std::vector<std::any> item_list(items.begin(), items.end());
parse->EventBot(EVENT_TRADE, this, client, "", 0, &item_list);
if (parse->BotHasQuestSub(EVENT_TRADE)) {
std::vector<std::any> item_list(items.begin(), items.end());
parse->EventBot(EVENT_TRADE, this, client, "", 0, &item_list);
}

CalcBotStats(false);
}
}
Expand Down
6 changes: 4 additions & 2 deletions zone/trading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,10 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
tradingWith->FaceTarget(this);
}

std::vector<std::any> 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<std::any> 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]) {
Expand Down

0 comments on commit 90def9b

Please sign in to comment.