[10631] Small code style cleanup in quest related functions

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-10-20 09:33:34 +02:00
parent da07caba28
commit 2fe87fc3c7
2 changed files with 125 additions and 103 deletions

View file

@ -13284,12 +13284,12 @@ bool Player::CanSeeStartQuest( Quest const *pQuest ) const
bool Player::CanTakeQuest(Quest const *pQuest, bool msg) const bool Player::CanTakeQuest(Quest const *pQuest, bool msg) const
{ {
return SatisfyQuestStatus( pQuest, msg ) && SatisfyQuestExclusiveGroup( pQuest, msg ) return SatisfyQuestStatus(pQuest, msg) && SatisfyQuestExclusiveGroup(pQuest, msg) &&
&& SatisfyQuestClass(pQuest, msg) && SatisfyQuestRace(pQuest, msg) && SatisfyQuestLevel(pQuest, msg) SatisfyQuestClass(pQuest, msg) && SatisfyQuestRace(pQuest, msg) && SatisfyQuestLevel(pQuest, msg) &&
&& SatisfyQuestSkill(pQuest, msg) && SatisfyQuestReputation(pQuest, msg) SatisfyQuestSkill(pQuest, msg) && SatisfyQuestReputation(pQuest, msg) &&
&& SatisfyQuestPreviousQuest( pQuest, msg ) && SatisfyQuestTimed( pQuest, msg ) SatisfyQuestPreviousQuest(pQuest, msg) && SatisfyQuestTimed(pQuest, msg) &&
&& SatisfyQuestNextChain( pQuest, msg ) && SatisfyQuestPrevChain( pQuest, msg ) SatisfyQuestNextChain(pQuest, msg) && SatisfyQuestPrevChain(pQuest, msg) &&
&& SatisfyQuestDay( pQuest, msg ) && SatisfyQuestWeek( pQuest, msg ); SatisfyQuestDay(pQuest, msg) && SatisfyQuestWeek(pQuest, msg);
} }
bool Player::CanAddQuest(Quest const *pQuest, bool msg) const bool Player::CanAddQuest(Quest const *pQuest, bool msg) const
@ -13425,6 +13425,7 @@ bool Player::CanRewardQuest( Quest const *pQuest, bool msg ) const
{ {
if (msg) if (msg)
SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL, pQuest->ReqItemId[i]); SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL, pQuest->ReqItemId[i]);
return false; return false;
} }
} }
@ -13715,6 +13716,7 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
if (pQuest->GetZoneOrSort() > 0) if (pQuest->GetZoneOrSort() > 0)
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE, pQuest->GetZoneOrSort()); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE, pQuest->GetZoneOrSort());
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT);
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, pQuest->GetQuestId()); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST, pQuest->GetQuestId());
@ -13800,8 +13802,10 @@ bool Player::SatisfyQuestLevel( Quest const* qInfo, bool msg ) const
{ {
if (msg) if (msg)
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
return false; return false;
} }
return true; return true;
} }
@ -13863,6 +13867,7 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) const
{ {
if (msg) if (msg)
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
return false; return false;
} }
} }
@ -13894,6 +13899,7 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) const
{ {
if (msg) if (msg)
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
return false; return false;
} }
} }
@ -13931,14 +13937,18 @@ bool Player::SatisfyQuestClass(Quest const* qInfo, bool msg) const
bool Player::SatisfyQuestRace(Quest const* qInfo, bool msg) const bool Player::SatisfyQuestRace(Quest const* qInfo, bool msg) const
{ {
uint32 reqraces = qInfo->GetRequiredRaces(); uint32 reqraces = qInfo->GetRequiredRaces();
if (reqraces == 0) if (reqraces == 0)
return true; return true;
if ((reqraces & getRaceMask()) == 0) if ((reqraces & getRaceMask()) == 0)
{ {
if (msg) if (msg)
SendCanTakeQuestResponse(INVALIDREASON_QUEST_FAILED_WRONG_RACE); SendCanTakeQuestResponse(INVALIDREASON_QUEST_FAILED_WRONG_RACE);
return false; return false;
} }
return true; return true;
} }
@ -13949,6 +13959,7 @@ bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg ) const
{ {
if (msg) if (msg)
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
return false; return false;
} }
@ -13957,6 +13968,7 @@ bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg ) const
{ {
if (msg) if (msg)
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
return false; return false;
} }
@ -13966,12 +13978,15 @@ bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg ) const
bool Player::SatisfyQuestStatus(Quest const* qInfo, bool msg) const bool Player::SatisfyQuestStatus(Quest const* qInfo, bool msg) const
{ {
QuestStatusMap::const_iterator itr = mQuestStatus.find(qInfo->GetQuestId()); QuestStatusMap::const_iterator itr = mQuestStatus.find(qInfo->GetQuestId());
if (itr != mQuestStatus.end() && itr->second.m_status != QUEST_STATUS_NONE) if (itr != mQuestStatus.end() && itr->second.m_status != QUEST_STATUS_NONE)
{ {
if (msg) if (msg)
SendCanTakeQuestResponse(INVALIDREASON_QUEST_ALREADY_ON); SendCanTakeQuestResponse(INVALIDREASON_QUEST_ALREADY_ON);
return false; return false;
} }
return true; return true;
} }
@ -13984,6 +13999,7 @@ bool Player::SatisfyQuestTimed(Quest const* qInfo, bool msg) const
return false; return false;
} }
return true; return true;
} }
@ -13995,7 +14011,7 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const
ExclusiveQuestGroupsMapBounds bounds = sObjectMgr.GetExclusiveQuestGroupsMapBounds(qInfo->GetExclusiveGroup()); ExclusiveQuestGroupsMapBounds bounds = sObjectMgr.GetExclusiveQuestGroupsMapBounds(qInfo->GetExclusiveGroup());
MANGOS_ASSERT(bounds.first != bounds.second); // always must be found if qInfo->ExclusiveGroup != 0 MANGOS_ASSERT(bounds.first != bounds.second); // must always be found if qInfo->ExclusiveGroup != 0
for(ExclusiveQuestGroupsMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter) for(ExclusiveQuestGroupsMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter)
{ {
@ -14011,20 +14027,23 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const
{ {
if (msg) if (msg)
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
return false; return false;
} }
QuestStatusMap::const_iterator i_exstatus = mQuestStatus.find(exclude_Id); QuestStatusMap::const_iterator i_exstatus = mQuestStatus.find(exclude_Id);
// alternative quest already started or completed // alternative quest already started or completed
if (i_exstatus != mQuestStatus.end() if (i_exstatus != mQuestStatus.end() &&
&& (i_exstatus->second.m_status == QUEST_STATUS_COMPLETE || i_exstatus->second.m_status == QUEST_STATUS_INCOMPLETE)) (i_exstatus->second.m_status == QUEST_STATUS_COMPLETE || i_exstatus->second.m_status == QUEST_STATUS_INCOMPLETE))
{ {
if (msg) if (msg)
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
return false; return false;
} }
} }
return true; return true;
} }
@ -14035,11 +14054,12 @@ bool Player::SatisfyQuestNextChain( Quest const* qInfo, bool msg ) const
// next quest in chain already started or completed // next quest in chain already started or completed
QuestStatusMap::const_iterator itr = mQuestStatus.find(qInfo->GetNextQuestInChain()); QuestStatusMap::const_iterator itr = mQuestStatus.find(qInfo->GetNextQuestInChain());
if (itr != mQuestStatus.end() if (itr != mQuestStatus.end() &&
&& (itr->second.m_status == QUEST_STATUS_COMPLETE || itr->second.m_status == QUEST_STATUS_INCOMPLETE)) (itr->second.m_status == QUEST_STATUS_COMPLETE || itr->second.m_status == QUEST_STATUS_INCOMPLETE))
{ {
if (msg) if (msg)
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
return false; return false;
} }
@ -14064,6 +14084,7 @@ bool Player::SatisfyQuestPrevChain( Quest const* qInfo, bool msg ) const
{ {
if (msg) if (msg)
SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ);
return false; return false;
} }
@ -14097,6 +14118,7 @@ bool Player::SatisfyQuestDay( Quest const* qInfo, bool msg ) const
{ {
if (msg) if (msg)
SendCanTakeQuestResponse(INVALIDREASON_DAILY_QUESTS_REMAINING); SendCanTakeQuestResponse(INVALIDREASON_DAILY_QUESTS_REMAINING);
return false; return false;
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10630" #define REVISION_NR "10631"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__