aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2021-12-04 21:17:43 +0100
committerShauren <shauren.trinity@gmail.com>2021-12-04 21:17:43 +0100
commiteb834272cb0c0a1b1bb102bcee1b2a18b27f862d (patch)
tree1a7e8b14ec114916e237367d66bf5d631c6ec2df
parent198d18bef5d3480cb30c80e4a4946327f401a6d4 (diff)
Core/Quests: Optimize Player::HasQuestForGO
-rw-r--r--src/server/game/Entities/Player/Player.cpp38
1 files changed, 10 insertions, 28 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 530fe970011..15a4728a362 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -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)
- continue;
-
- QuestStatusMap::const_iterator qs_itr = m_QuestStatus.find(questid);
- if (qs_itr == m_QuestStatus.end())
+ 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;
- QuestStatusData const& qs = qs_itr->second;
-
- if (qs.Status == QUEST_STATUS_INCOMPLETE)
- {
- Quest const* qInfo = sObjectMgr->GetQuestTemplate(questid);
- if (!qInfo)
- continue;
-
- if (GetGroup() && GetGroup()->isRaidGroup() && !qInfo->IsAllowedInRaid(GetMap()->GetDifficultyID()))
+ // 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;
- 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;
}