From 5ac5beb45610a10296ed502bca0632dfde42f157 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 12 Feb 2023 22:59:01 -0500 Subject: [PATCH] [Quest API] (Performance) Check event exists before export and execute EVENT_DESPAWN and EVENT_DESPAWN_ZONE (#2887) # Notes - Optionally parse these events instead of always doing so. --- zone/npc.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/zone/npc.cpp b/zone/npc.cpp index 1027d5679..2b3b1d879 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -1114,11 +1114,21 @@ void NPC::Depop(bool start_spawn_timer) { } if (IsNPC()) { - parse->EventNPC(EVENT_DESPAWN, this, nullptr, "", 0); - DispatchZoneControllerEvent(EVENT_DESPAWN_ZONE, this, "", 0, nullptr); + if (parse->HasQuestSub(GetNPCTypeID(), EVENT_DESPAWN)) { + parse->EventNPC(EVENT_DESPAWN, this, nullptr, "", 0); + } + + if (parse->HasQuestSub(ZONE_CONTROLLER_NPC_ID, EVENT_DESPAWN_ZONE)) { + DispatchZoneControllerEvent(EVENT_DESPAWN_ZONE, this, "", 0, nullptr); + } } else if (IsBot()) { - parse->EventBot(EVENT_DESPAWN, CastToBot(), nullptr, "", 0); - DispatchZoneControllerEvent(EVENT_DESPAWN_ZONE, this, "", 0, nullptr); + if (parse->BotHasQuestSub(EVENT_DESPAWN)) { + parse->EventBot(EVENT_DESPAWN, CastToBot(), nullptr, "", 0); + } + + if (parse->HasQuestSub(ZONE_CONTROLLER_NPC_ID, EVENT_DESPAWN_ZONE)) { + DispatchZoneControllerEvent(EVENT_DESPAWN_ZONE, this, "", 0, nullptr); + } } p_depop = true;