Core/Quests: Optimize Player::HasQuestForGO

This commit is contained in:
Shauren
2021-12-04 21:17:43 +01:00
parent 198d18bef5
commit eb834272cb

View File

@@ -25177,40 +25177,22 @@ bool Player::IsSpellFitByClassAndRace(uint32 spell_id) const
bool Player::HasQuestForGO(int32 GOId) const
{
for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i)
for (QuestObjectiveStatusMap::value_type const& objectiveItr : Trinity::Containers::MapEqualRange(m_questObjectiveStatus, { QUEST_OBJECTIVE_GAMEOBJECT, GOId }))
{
uint32 questid = GetQuestSlotQuestId(i);
if (questid == 0)
Quest const* qInfo = ASSERT_NOTNULL(sObjectMgr->GetQuestTemplate(objectiveItr.second.QuestStatusItr->first));
QuestObjective const& objective = *objectiveItr.second.Objective;
if (!IsQuestObjectiveCompletable(objectiveItr.second.QuestStatusItr->second.Slot, qInfo, objective))
continue;
QuestStatusMap::const_iterator qs_itr = m_QuestStatus.find(questid);
if (qs_itr == m_QuestStatus.end())
continue;
QuestStatusData const& qs = qs_itr->second;
if (qs.Status == QUEST_STATUS_INCOMPLETE)
{
Quest const* qInfo = sObjectMgr->GetQuestTemplate(questid);
if (!qInfo)
// hide quest if player is in raid-group and quest is no raid quest
if (GetGroup() && GetGroup()->isRaidGroup() && !qInfo->IsAllowedInRaid(GetMap()->GetDifficultyID()))
if (!InBattleground()) //there are two ways.. we can make every bg-quest a raidquest, or add this code here.. i don't know if this can be exploited by other quests, but i think all other quests depend on a specific area.. but keep this in mind, if something strange happens later
continue;
if (GetGroup() && GetGroup()->isRaidGroup() && !qInfo->IsAllowedInRaid(GetMap()->GetDifficultyID()))
continue;
for (QuestObjective const& obj : qInfo->GetObjectives())
{
if (obj.Type != QUEST_OBJECTIVE_GAMEOBJECT) //skip non GO case
continue;
if (!IsQuestObjectiveCompletable(i, qInfo, obj))
continue;
if (GOId == obj.ObjectID && GetQuestSlotObjectiveData(i, obj) < obj.Amount)
return true;
}
}
if (!IsQuestObjectiveComplete(objectiveItr.second.QuestStatusItr->second.Slot, qInfo, objective))
return true;
}
return false;
}