mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 18:36:31 +01:00
Core/Quests: Optimize Player::HasQuestForGO
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user