[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
This commit is contained in:
Alex King 2023-02-13 00:40:03 -05:00 committed by GitHub
parent 5be3780a54
commit 384de31989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 19 deletions

View File

@ -9935,17 +9935,18 @@ uint32 helper_bot_create(Client *bot_owner, std::string bot_name, uint8 bot_clas
); );
bot_id = my_bot->GetBotID(); 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( parse->EventPlayer(EVENT_BOT_CREATE, bot_owner, export_string, 0);
"{} {} {} {} {}", }
bot_name,
bot_id,
bot_race,
bot_class,
bot_gender
);
parse->EventPlayer(EVENT_BOT_CREATE, bot_owner, export_string, 0);
safe_delete(my_bot); safe_delete(my_bot);

View File

@ -2427,16 +2427,18 @@ bool QuestManager::createBot(const char *name, const char *lastname, uint8 level
).c_str() ).c_str()
); );
const auto export_string = fmt::format( if (parse->PlayerHasQuestSub(EVENT_BOT_CREATE)) {
"{} {} {} {} {}", const auto& export_string = fmt::format(
name, "{} {} {} {} {}",
new_bot->GetBotID(), name,
race, new_bot->GetBotID(),
botclass, race,
gender botclass,
); gender
);
parse->EventPlayer(EVENT_BOT_CREATE, initiator, export_string, 0); parse->EventPlayer(EVENT_BOT_CREATE, initiator, export_string, 0);
}
return true; return true;
} }