From fd0764d4cbf44513c6761722027e8539864c2d6e Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 12 Feb 2023 23:33:33 -0500 Subject: [PATCH] [Quest API] (Performance) Check event exists before export and execute EVENT_TIMER (#2903) # Notes - Parse this event optionally instead of always doing so. --- zone/client.cpp | 8 ++++++-- zone/questmgr.cpp | 17 +++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index b7fbe53ba..f4ef0a72c 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -8161,7 +8161,9 @@ void Client::TryItemTimer(int slot) auto it_iter = item_timers.begin(); while(it_iter != item_timers.end()) { if(it_iter->second.Check()) { - parse->EventItem(EVENT_TIMER, this, inst, nullptr, it_iter->first, 0); + if (parse->ItemHasQuestSub(inst, EVENT_TIMER)) { + parse->EventItem(EVENT_TIMER, this, inst, nullptr, it_iter->first, 0); + } } ++it_iter; } @@ -8181,7 +8183,9 @@ void Client::TryItemTimer(int slot) auto it_iter = item_timers.begin(); while(it_iter != item_timers.end()) { if(it_iter->second.Check()) { - parse->EventItem(EVENT_TIMER, this, a_inst, nullptr, it_iter->first, 0); + if (parse->ItemHasQuestSub(a_inst, EVENT_TIMER)) { + parse->EventItem(EVENT_TIMER, this, a_inst, nullptr, it_iter->first, 0); + } } ++it_iter; } diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index c84b74730..68ee9c379 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -90,15 +90,20 @@ void QuestManager::Process() { if (cur->Timer_.Enabled() && cur->Timer_.Check()) { if(entity_list.IsMobInZone(cur->mob)) { if(cur->mob->IsNPC()) { - parse->EventNPC(EVENT_TIMER, cur->mob->CastToNPC(), nullptr, cur->name, 0); + if (parse->HasQuestSub(cur->mob->GetNPCTypeID(), EVENT_TIMER)) { + parse->EventNPC(EVENT_TIMER, cur->mob->CastToNPC(), nullptr, cur->name, 0); + } } else if (cur->mob->IsEncounter()) { parse->EventEncounter(EVENT_TIMER, cur->mob->CastToEncounter()->GetEncounterName(), cur->name, 0, nullptr); } else if (cur->mob->IsClient()) { - //this is inheriently unsafe if we ever make it so more than npc/client start timers - parse->EventPlayer(EVENT_TIMER, cur->mob->CastToClient(), cur->name, 0); - } - else if (cur->mob->IsBot()) { - parse->EventBot(EVENT_TIMER, cur->mob->CastToBot(), nullptr, cur->name, 0); + if (parse->PlayerHasQuestSub(EVENT_TIMER)) { + //this is inheriently unsafe if we ever make it so more than npc/client start timers + parse->EventPlayer(EVENT_TIMER, cur->mob->CastToClient(), cur->name, 0); + } + } else if (cur->mob->IsBot()) { + if (parse->BotHasQuestSub(EVENT_TIMER)) { + parse->EventBot(EVENT_TIMER, cur->mob->CastToBot(), nullptr, cur->name, 0); + } } //we MUST reset our iterator since the quest could have removed/added any