mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[10594] Use equal_range instead of lower_bound/upper_bound pairs
(based on zergtmn's repo commit 0499169) Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
0caa0e32dd
commit
2fa5fa43bd
13 changed files with 207 additions and 182 deletions
|
|
@ -13070,18 +13070,16 @@ uint32 Player::GetDefaultGossipMenuForSource(WorldObject *pSource)
|
|||
/*** QUEST SYSTEM ***/
|
||||
/*********************************************************/
|
||||
|
||||
void Player::PrepareQuestMenu( uint64 guid )
|
||||
void Player::PrepareQuestMenu(uint64 guid)
|
||||
{
|
||||
Object *pObject;
|
||||
QuestRelations* pObjectQR;
|
||||
QuestRelations* pObjectQIR;
|
||||
QuestRelationsMapBounds rbounds;
|
||||
QuestRelationsMapBounds irbounds;
|
||||
|
||||
// pets also can have quests
|
||||
if (Creature *pCreature = GetMap()->GetAnyTypeCreature(guid))
|
||||
{
|
||||
pObject = (Object*)pCreature;
|
||||
pObjectQR = &sObjectMgr.mCreatureQuestRelations;
|
||||
pObjectQIR = &sObjectMgr.mCreatureQuestInvolvedRelations;
|
||||
rbounds = sObjectMgr.GetCreatureQuestRelationsMapBounds(pCreature->GetEntry());
|
||||
irbounds = sObjectMgr.GetCreatureQuestInvolvedRelationsMapBounds(pCreature->GetEntry());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -13089,12 +13087,11 @@ void Player::PrepareQuestMenu( uint64 guid )
|
|||
//only for quests which cast teleport spells on player
|
||||
Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId());
|
||||
MANGOS_ASSERT(_map);
|
||||
GameObject *pGameObject = _map->GetGameObject(guid);
|
||||
if( pGameObject )
|
||||
|
||||
if (GameObject *pGameObject = _map->GetGameObject(guid))
|
||||
{
|
||||
pObject = (Object*)pGameObject;
|
||||
pObjectQR = &sObjectMgr.mGOQuestRelations;
|
||||
pObjectQIR = &sObjectMgr.mGOQuestInvolvedRelations;
|
||||
rbounds = sObjectMgr.GetGOQuestRelationsMapBounds(pGameObject->GetEntry());
|
||||
irbounds = sObjectMgr.GetGOQuestInvolvedRelationsMapBounds(pGameObject->GetEntry());
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
|
@ -13103,29 +13100,32 @@ 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(QuestRelationsMap::const_iterator itr = irbounds.first; itr != irbounds.second; ++itr)
|
||||
{
|
||||
uint32 quest_id = i->second;
|
||||
QuestStatus status = GetQuestStatus( quest_id );
|
||||
if ( status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus( quest_id ) )
|
||||
uint32 quest_id = itr->second;
|
||||
QuestStatus status = GetQuestStatus(quest_id);
|
||||
|
||||
if (status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus(quest_id))
|
||||
qm.AddMenuItem(quest_id, 4);
|
||||
else if ( status == QUEST_STATUS_INCOMPLETE )
|
||||
else if (status == QUEST_STATUS_INCOMPLETE)
|
||||
qm.AddMenuItem(quest_id, 4);
|
||||
else if (status == QUEST_STATUS_AVAILABLE )
|
||||
else if (status == QUEST_STATUS_AVAILABLE)
|
||||
qm.AddMenuItem(quest_id, 2);
|
||||
}
|
||||
|
||||
for(QuestRelations::const_iterator i = pObjectQR->lower_bound(pObject->GetEntry()); i != pObjectQR->upper_bound(pObject->GetEntry()); ++i)
|
||||
for(QuestRelationsMap::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr)
|
||||
{
|
||||
uint32 quest_id = i->second;
|
||||
uint32 quest_id = itr->second;
|
||||
Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest_id);
|
||||
if(!pQuest) continue;
|
||||
|
||||
QuestStatus status = GetQuestStatus( quest_id );
|
||||
if (!pQuest)
|
||||
continue;
|
||||
|
||||
QuestStatus status = GetQuestStatus(quest_id);
|
||||
|
||||
if (pQuest->IsAutoComplete() && CanTakeQuest(pQuest, false))
|
||||
qm.AddMenuItem(quest_id, 4);
|
||||
else if ( status == QUEST_STATUS_NONE && CanTakeQuest( pQuest, false ) )
|
||||
else if (status == QUEST_STATUS_NONE && CanTakeQuest(pQuest, false))
|
||||
qm.AddMenuItem(quest_id, 2);
|
||||
}
|
||||
}
|
||||
|
|
@ -13238,17 +13238,13 @@ bool Player::IsCurrentQuest( uint32 quest_id ) const
|
|||
return itr->second.m_status == QUEST_STATUS_INCOMPLETE || itr->second.m_status == QUEST_STATUS_COMPLETE && !itr->second.m_rewarded;
|
||||
}
|
||||
|
||||
Quest const * Player::GetNextQuest( uint64 guid, Quest const *pQuest )
|
||||
Quest const* Player::GetNextQuest(uint64 guid, Quest const *pQuest)
|
||||
{
|
||||
Object *pObject;
|
||||
QuestRelations* pObjectQR;
|
||||
QuestRelations* pObjectQIR;
|
||||
QuestRelationsMapBounds rbounds;
|
||||
|
||||
if (Creature *pCreature = GetMap()->GetAnyTypeCreature(guid))
|
||||
{
|
||||
pObject = (Object*)pCreature;
|
||||
pObjectQR = &sObjectMgr.mCreatureQuestRelations;
|
||||
pObjectQIR = &sObjectMgr.mCreatureQuestInvolvedRelations;
|
||||
rbounds = sObjectMgr.GetCreatureQuestRelationsMapBounds(pCreature->GetEntry());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -13256,19 +13252,17 @@ Quest const * Player::GetNextQuest( uint64 guid, Quest const *pQuest )
|
|||
//only for quests which cast teleport spells on player
|
||||
Map * _map = IsInWorld() ? GetMap() : sMapMgr.FindMap(GetMapId(), GetInstanceId());
|
||||
MANGOS_ASSERT(_map);
|
||||
GameObject *pGameObject = _map->GetGameObject(guid);
|
||||
if( pGameObject )
|
||||
|
||||
if (GameObject *pGameObject = _map->GetGameObject(guid))
|
||||
{
|
||||
pObject = (Object*)pGameObject;
|
||||
pObjectQR = &sObjectMgr.mGOQuestRelations;
|
||||
pObjectQIR = &sObjectMgr.mGOQuestInvolvedRelations;
|
||||
rbounds = sObjectMgr.GetGOQuestRelationsMapBounds(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(QuestRelationsMap::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr)
|
||||
{
|
||||
if (itr->second == nextQuestID)
|
||||
return sObjectMgr.GetQuestTemplate(nextQuestID);
|
||||
|
|
@ -13867,12 +13861,11 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) const
|
|||
|
||||
// each-from-all exclusive group ( < 0)
|
||||
// can be start if only all quests in prev quest exclusive group completed and rewarded
|
||||
ObjectMgr::ExclusiveQuestGroups::const_iterator iter2 = sObjectMgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup());
|
||||
ObjectMgr::ExclusiveQuestGroups::const_iterator end = sObjectMgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup());
|
||||
ExclusiveQuestGroupsMapBounds bounds = sObjectMgr.GetExclusiveQuestGroupsMapBounds(qPrevInfo->GetExclusiveGroup());
|
||||
|
||||
MANGOS_ASSERT(iter2!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0
|
||||
MANGOS_ASSERT(bounds.first != bounds.second); // always must be found if qPrevInfo->ExclusiveGroup != 0
|
||||
|
||||
for(; iter2 != end; ++iter2)
|
||||
for(ExclusiveQuestGroupsMap::const_iterator iter2 = bounds.first; iter2 != bounds.second; ++iter2)
|
||||
{
|
||||
uint32 exclude_Id = iter2->second;
|
||||
|
||||
|
|
@ -13901,12 +13894,11 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) const
|
|||
|
||||
// each-from-all exclusive group ( < 0)
|
||||
// can be start if only all quests in prev quest exclusive group active
|
||||
ObjectMgr::ExclusiveQuestGroups::const_iterator iter2 = sObjectMgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup());
|
||||
ObjectMgr::ExclusiveQuestGroups::const_iterator end = sObjectMgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup());
|
||||
ExclusiveQuestGroupsMapBounds bounds = sObjectMgr.GetExclusiveQuestGroupsMapBounds(qPrevInfo->GetExclusiveGroup());
|
||||
|
||||
MANGOS_ASSERT(iter2!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0
|
||||
MANGOS_ASSERT(bounds.first != bounds.second); // always must be found if qPrevInfo->ExclusiveGroup != 0
|
||||
|
||||
for(; iter2 != end; ++iter2)
|
||||
for(ExclusiveQuestGroupsMap::const_iterator iter2 = bounds.first; iter2 != bounds.second; ++iter2)
|
||||
{
|
||||
uint32 exclude_Id = iter2->second;
|
||||
|
||||
|
|
@ -13994,18 +13986,17 @@ bool Player::SatisfyQuestTimed(Quest const* qInfo, bool msg) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Player::SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg ) const
|
||||
bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const
|
||||
{
|
||||
// non positive exclusive group, if > 0 then can be start if any other quest in exclusive group already started/completed
|
||||
if (qInfo->GetExclusiveGroup() <= 0)
|
||||
return true;
|
||||
|
||||
ObjectMgr::ExclusiveQuestGroups::const_iterator iter = sObjectMgr.mExclusiveQuestGroups.lower_bound(qInfo->GetExclusiveGroup());
|
||||
ObjectMgr::ExclusiveQuestGroups::const_iterator end = sObjectMgr.mExclusiveQuestGroups.upper_bound(qInfo->GetExclusiveGroup());
|
||||
ExclusiveQuestGroupsMapBounds bounds = sObjectMgr.GetExclusiveQuestGroupsMapBounds(qInfo->GetExclusiveGroup());
|
||||
|
||||
MANGOS_ASSERT(iter!=end); // always must be found if qInfo->ExclusiveGroup != 0
|
||||
MANGOS_ASSERT(bounds.first != bounds.second); // always must be found if qInfo->ExclusiveGroup != 0
|
||||
|
||||
for(; iter != end; ++iter)
|
||||
for(ExclusiveQuestGroupsMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter)
|
||||
{
|
||||
uint32 exclude_Id = iter->second;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue