From 384de31989b1df081efe29bb6ddc56a85aae78ea Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Mon, 13 Feb 2023 00:40:03 -0500 Subject: [PATCH] [Quest API] (Performance) Check event exists before export and execute EVENT_BOT_CREATE (#2886) * [Quest API] Optionally parse EVENT_BOT_CREATE - Optionally parse this event instead of always doing so. * Cleanup * Cleanup --- zone/bot_command.cpp | 21 +++++++++++---------- zone/questmgr.cpp | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index 58ceef906..e6e2782b8 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -9935,17 +9935,18 @@ uint32 helper_bot_create(Client *bot_owner, std::string bot_name, uint8 bot_clas ); bot_id = my_bot->GetBotID(); + if (parse->PlayerHasQuestSub(EVENT_BOT_CREATE)) { + const auto& export_string = fmt::format( + "{} {} {} {} {}", + bot_name, + bot_id, + bot_race, + bot_class, + bot_gender + ); - const auto export_string = fmt::format( - "{} {} {} {} {}", - bot_name, - bot_id, - bot_race, - bot_class, - bot_gender - ); - - parse->EventPlayer(EVENT_BOT_CREATE, bot_owner, export_string, 0); + parse->EventPlayer(EVENT_BOT_CREATE, bot_owner, export_string, 0); + } safe_delete(my_bot); diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 68ee9c379..d2db20bc2 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -2427,16 +2427,18 @@ bool QuestManager::createBot(const char *name, const char *lastname, uint8 level ).c_str() ); - const auto export_string = fmt::format( - "{} {} {} {} {}", - name, - new_bot->GetBotID(), - race, - botclass, - gender - ); + if (parse->PlayerHasQuestSub(EVENT_BOT_CREATE)) { + const auto& export_string = fmt::format( + "{} {} {} {} {}", + name, + new_bot->GetBotID(), + race, + botclass, + gender + ); - parse->EventPlayer(EVENT_BOT_CREATE, initiator, export_string, 0); + parse->EventPlayer(EVENT_BOT_CREATE, initiator, export_string, 0); + } return true; }