[Quest API] (Performance) Check event exists before export and execute EVENT_TIMER (#2903)

# Notes
- Parse this event optionally instead of always doing so.
This commit is contained in:
Alex King 2023-02-12 23:33:33 -05:00 committed by GitHub
parent 71b2bf6a64
commit fd0764d4cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View File

@ -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;
}

View File

@ -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