Core/Quests: Some cleanup in quest relation accessing

--HG--
branch : trunk
This commit is contained in:
Shauren
2010-09-13 13:18:27 +02:00
parent c7289967b0
commit 6d0a031a77
6 changed files with 77 additions and 59 deletions
@@ -1315,8 +1315,8 @@ void Creature::LoadEquipment(uint32 equip_entry, bool force)
bool Creature::hasQuest(uint32 quest_id) const
{
QuestRelations const& qr = sObjectMgr.mCreatureQuestRelations;
for (QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr)
QuestRelationBounds qr = sObjectMgr.GetCreatureQuestRelationBounds(GetEntry());
for (QuestRelations::const_iterator itr = qr.first; itr != qr.second; ++itr)
{
if (itr->second == quest_id)
return true;
@@ -1326,8 +1326,8 @@ bool Creature::hasQuest(uint32 quest_id) const
bool Creature::hasInvolvedQuest(uint32 quest_id) const
{
QuestRelations const& qr = sObjectMgr.mCreatureQuestInvolvedRelations;
for (QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr)
QuestRelationBounds qir = sObjectMgr.GetCreatureQuestInvolvedRelationBounds(GetEntry());
for (QuestRelations::const_iterator itr = qir.first; itr != qir.second; ++itr)
{
if (itr->second == quest_id)
return true;
@@ -742,8 +742,8 @@ GameObject* GameObject::GetGameObject(WorldObject& object, uint64 guid)
/*********************************************************/
bool GameObject::hasQuest(uint32 quest_id) const
{
QuestRelations const& qr = sObjectMgr.mGOQuestRelations;
for (QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr)
QuestRelationBounds qr = sObjectMgr.GetGOQuestRelationBounds(GetEntry());
for (QuestRelations::const_iterator itr = qr.first; itr != qr.second; ++itr)
{
if (itr->second == quest_id)
return true;
@@ -753,8 +753,8 @@ bool GameObject::hasQuest(uint32 quest_id) const
bool GameObject::hasInvolvedQuest(uint32 quest_id) const
{
QuestRelations const& qr = sObjectMgr.mGOQuestInvolvedRelations;
for (QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr)
QuestRelationBounds qir = sObjectMgr.GetGOQuestInvolvedRelationBounds(GetEntry());
for (QuestRelations::const_iterator itr = qir.first; itr != qir.second; ++itr)
{
if (itr->second == quest_id)
return true;
+12 -25
View File
@@ -13800,17 +13800,15 @@ uint32 Player::GetDefaultGossipMenuForSource(WorldObject *pSource)
void Player::PrepareQuestMenu(uint64 guid)
{
Object *pObject;
QuestRelations* pObjectQR;
QuestRelations* pObjectQIR;
QuestRelationBounds pObjectQR;
QuestRelationBounds pObjectQIR;
// pets also can have quests
Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, guid);
if (pCreature)
{
pObject = (Object*)pCreature;
pObjectQR = &sObjectMgr.mCreatureQuestRelations;
pObjectQIR = &sObjectMgr.mCreatureQuestInvolvedRelations;
pObjectQR = sObjectMgr.GetCreatureQuestRelationBounds(pCreature->GetEntry());
pObjectQIR = sObjectMgr.GetCreatureQuestInvolvedRelationBounds(pCreature->GetEntry());
}
else
{
@@ -13821,9 +13819,8 @@ void Player::PrepareQuestMenu(uint64 guid)
GameObject *pGameObject = _map->GetGameObject(guid);
if (pGameObject)
{
pObject = (Object*)pGameObject;
pObjectQR = &sObjectMgr.mGOQuestRelations;
pObjectQIR = &sObjectMgr.mGOQuestInvolvedRelations;
pObjectQR = sObjectMgr.GetGOQuestRelationBounds(pGameObject->GetEntry());
pObjectQIR = sObjectMgr.GetGOQuestInvolvedRelationBounds(pGameObject->GetEntry());
}
else
return;
@@ -13832,7 +13829,7 @@ void Player::PrepareQuestMenu(uint64 guid)
QuestMenu &qm = PlayerTalkClass->GetQuestMenu();
qm.ClearMenu();
for (QuestRelations::const_iterator i = pObjectQIR->lower_bound(pObject->GetEntry()); i != pObjectQIR->upper_bound(pObject->GetEntry()); ++i)
for (QuestRelations::const_iterator i = pObjectQIR.first; i != pObjectQIR.second; ++i)
{
uint32 quest_id = i->second;
QuestStatus status = GetQuestStatus(quest_id);
@@ -13844,7 +13841,7 @@ void Player::PrepareQuestMenu(uint64 guid)
// qm.AddMenuItem(quest_id, 2);
}
for (QuestRelations::const_iterator i = pObjectQR->lower_bound(pObject->GetEntry()); i != pObjectQR->upper_bound(pObject->GetEntry()); ++i)
for (QuestRelations::const_iterator i = pObjectQR.first; i != pObjectQR.second; ++i)
{
uint32 quest_id = i->second;
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
@@ -13964,17 +13961,11 @@ bool Player::IsActiveQuest(uint32 quest_id) const
Quest const * Player::GetNextQuest(uint64 guid, Quest const *pQuest)
{
Object *pObject;
QuestRelations* pObjectQR;
QuestRelations* pObjectQIR;
QuestRelationBounds pObjectQR;
Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this,guid);
if (pCreature)
{
pObject = (Object*)pCreature;
pObjectQR = &sObjectMgr.mCreatureQuestRelations;
pObjectQIR = &sObjectMgr.mCreatureQuestInvolvedRelations;
}
pObjectQR = sObjectMgr.GetCreatureQuestRelationBounds(pCreature->GetEntry());
else
{
//we should obtain map pointer from GetMap() in 99% of cases. Special case
@@ -13983,17 +13974,13 @@ Quest const * Player::GetNextQuest(uint64 guid, Quest const *pQuest)
ASSERT(_map);
GameObject *pGameObject = _map->GetGameObject(guid);
if (pGameObject)
{
pObject = (Object*)pGameObject;
pObjectQR = &sObjectMgr.mGOQuestRelations;
pObjectQIR = &sObjectMgr.mGOQuestInvolvedRelations;
}
pObjectQR = sObjectMgr.GetGOQuestRelationBounds(pGameObject->GetEntry());
else
return NULL;
}
uint32 nextQuestID = pQuest->GetNextQuestInChain();
for (QuestRelations::const_iterator itr = pObjectQR->lower_bound(pObject->GetEntry()); itr != pObjectQR->upper_bound(pObject->GetEntry()); ++itr)
for (QuestRelations::const_iterator itr = pObjectQR.first; itr != pObjectQR.second; ++itr)
{
if (itr->second == nextQuestID)
return sObjectMgr.GetQuestTemplate(nextQuestID);