[10042] Implement CONDITION_QUESTAVAILABLE.

Also do come constatification of quest status check functions
and fix one unsafe use std::map operator[].
Never never use std::map operator [] for _read_ access.
Good chance corrupt related structure state ;)
Not in found case but in general.
This commit is contained in:
VladimirMangos 2010-06-07 22:21:28 +04:00
parent 5ea6815ea1
commit 5eabf12111
6 changed files with 193 additions and 179 deletions

View file

@ -11922,7 +11922,7 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del )
}
}
void Player::SendEquipError( uint8 msg, Item* pItem, Item *pItem2, uint32 itemid /*= 0*/ )
void Player::SendEquipError( uint8 msg, Item* pItem, Item *pItem2, uint32 itemid /*= 0*/ ) const
{
DEBUG_LOG( "WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)", msg);
WorldPacket data(SMSG_INVENTORY_CHANGE_FAILURE, 1+8+8+1);
@ -13125,12 +13125,12 @@ Quest const * Player::GetNextQuest( uint64 guid, Quest const *pQuest )
return NULL;
}
bool Player::CanSeeStartQuest( Quest const *pQuest )
bool Player::CanSeeStartQuest( Quest const *pQuest ) const
{
if( SatisfyQuestRace( pQuest, false ) && SatisfyQuestSkillOrClass( pQuest, false ) &&
if (SatisfyQuestRace( pQuest, false ) && SatisfyQuestSkillOrClass( pQuest, false ) &&
SatisfyQuestExclusiveGroup( pQuest, false ) && SatisfyQuestReputation( pQuest, false ) &&
SatisfyQuestPreviousQuest( pQuest, false ) && SatisfyQuestNextChain( pQuest, false ) &&
SatisfyQuestPrevChain( pQuest, false ) && SatisfyQuestDay( pQuest, false ) && SatisfyQuestWeek( pQuest, false ) )
SatisfyQuestPrevChain( pQuest, false ) && SatisfyQuestDay( pQuest, false ) && SatisfyQuestWeek( pQuest, false ))
{
return getLevel() + sWorld.getConfig(CONFIG_UINT32_QUEST_HIGH_LEVEL_HIDE_DIFF) >= pQuest->GetMinLevel();
}
@ -13138,7 +13138,7 @@ bool Player::CanSeeStartQuest( Quest const *pQuest )
return false;
}
bool Player::CanTakeQuest( Quest const *pQuest, bool msg )
bool Player::CanTakeQuest( Quest const *pQuest, bool msg ) const
{
return SatisfyQuestStatus( pQuest, msg ) && SatisfyQuestExclusiveGroup( pQuest, msg )
&& SatisfyQuestRace( pQuest, msg ) && SatisfyQuestLevel( pQuest, msg )
@ -13148,22 +13148,22 @@ bool Player::CanTakeQuest( Quest const *pQuest, bool msg )
&& SatisfyQuestDay( pQuest, msg ) && SatisfyQuestWeek( pQuest, msg );
}
bool Player::CanAddQuest( Quest const *pQuest, bool msg )
bool Player::CanAddQuest( Quest const *pQuest, bool msg ) const
{
if( !SatisfyQuestLog( msg ) )
if (!SatisfyQuestLog( msg ))
return false;
uint32 srcitem = pQuest->GetSrcItemId();
if( srcitem > 0 )
if (srcitem > 0)
{
uint32 count = pQuest->GetSrcItemCount();
ItemPosCountVec dest;
uint8 msg2 = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count );
// player already have max number (in most case 1) source item, no additional item needed and quest can be added.
if( msg2 == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS )
if (msg2 == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS)
return true;
else if( msg2 != EQUIP_ERR_OK )
else if (msg2 != EQUIP_ERR_OK)
{
SendEquipError(msg2, NULL, NULL, srcitem);
return false;
@ -13172,89 +13172,94 @@ bool Player::CanAddQuest( Quest const *pQuest, bool msg )
return true;
}
bool Player::CanCompleteQuest( uint32 quest_id )
bool Player::CanCompleteQuest( uint32 quest_id ) const
{
if( quest_id )
{
QuestStatusData& q_status = mQuestStatus[quest_id];
if( q_status.m_status == QUEST_STATUS_COMPLETE )
return false; // not allow re-complete quest
Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest_id);
if(!qInfo)
return false;
// auto complete quest
if (qInfo->IsAutoComplete() && CanTakeQuest(qInfo, false))
return true;
if ( q_status.m_status == QUEST_STATUS_INCOMPLETE )
{
if ( qInfo->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) )
{
for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
if( qInfo->ReqItemCount[i] != 0 && q_status.m_itemcount[i] < qInfo->ReqItemCount[i] )
return false;
}
}
if ( qInfo->HasFlag(QUEST_MANGOS_FLAGS_KILL_OR_CAST | QUEST_MANGOS_FLAGS_SPEAKTO) )
{
for(int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
{
if( qInfo->ReqCreatureOrGOId[i] == 0 )
continue;
if( qInfo->ReqCreatureOrGOCount[i] != 0 && q_status.m_creatureOrGOcount[i] < qInfo->ReqCreatureOrGOCount[i] )
return false;
}
}
if ( qInfo->HasFlag( QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT ) && !q_status.m_explored )
return false;
if ( qInfo->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) && q_status.m_timer == 0 )
return false;
if ( qInfo->GetRewOrReqMoney() < 0 )
{
if ( GetMoney() < uint32(-qInfo->GetRewOrReqMoney()) )
return false;
}
uint32 repFacId = qInfo->GetRepObjectiveFaction();
if ( repFacId && GetReputationMgr().GetReputation(repFacId) < qInfo->GetRepObjectiveValue() )
return false;
return true;
}
}
return false;
}
bool Player::CanCompleteRepeatableQuest( Quest const *pQuest )
{
// Solve problem that player don't have the quest and try complete it.
// if repeatable she must be able to complete event if player don't have it.
// Seem that all repeatable quest are DELIVER Flag so, no need to add more.
if( !CanTakeQuest(pQuest, false) )
if (!quest_id)
return false;
if (pQuest->HasFlag( QUEST_MANGOS_FLAGS_DELIVER) )
for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
if( pQuest->ReqItemId[i] && pQuest->ReqItemCount[i] && !HasItemCount(pQuest->ReqItemId[i], pQuest->ReqItemCount[i]) )
return false;
QuestStatusMap::const_iterator q_itr = mQuestStatus.find(quest_id);
if( !CanRewardQuest(pQuest, false) )
// some quests can be auto taken and auto completed in one step
QuestStatus status = q_itr != mQuestStatus.end() ? q_itr->second.m_status : QUEST_STATUS_NONE;
if (status == QUEST_STATUS_COMPLETE)
return false; // not allow re-complete quest
Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest_id);
if (!qInfo)
return false;
// auto complete quest
if (qInfo->IsAutoComplete() && CanTakeQuest(qInfo, false))
return true;
if (status != QUEST_STATUS_INCOMPLETE)
return false;
// incomplete quest have status data
QuestStatusData const& q_status = q_itr->second;
if (qInfo->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ))
{
for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
if (qInfo->ReqItemCount[i] != 0 && q_status.m_itemcount[i] < qInfo->ReqItemCount[i])
return false;
}
}
if (qInfo->HasFlag(QUEST_MANGOS_FLAGS_KILL_OR_CAST | QUEST_MANGOS_FLAGS_SPEAKTO))
{
for(int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
{
if (qInfo->ReqCreatureOrGOId[i] == 0)
continue;
if (qInfo->ReqCreatureOrGOCount[i] != 0 && q_status.m_creatureOrGOcount[i] < qInfo->ReqCreatureOrGOCount[i])
return false;
}
}
if (qInfo->HasFlag( QUEST_MANGOS_FLAGS_EXPLORATION_OR_EVENT ) && !q_status.m_explored)
return false;
if (qInfo->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) && q_status.m_timer == 0)
return false;
if (qInfo->GetRewOrReqMoney() < 0)
{
if (GetMoney() < uint32(-qInfo->GetRewOrReqMoney()))
return false;
}
uint32 repFacId = qInfo->GetRepObjectiveFaction();
if (repFacId && GetReputationMgr().GetReputation(repFacId) < qInfo->GetRepObjectiveValue())
return false;
return true;
}
bool Player::CanRewardQuest( Quest const *pQuest, bool msg )
bool Player::CanCompleteRepeatableQuest( Quest const *pQuest ) const
{
// Solve problem that player don't have the quest and try complete it.
// if repeatable she must be able to complete event if player don't have it.
// Seem that all repeatable quest are DELIVER Flag so, no need to add more.
if (!CanTakeQuest(pQuest, false))
return false;
if (pQuest->HasFlag( QUEST_MANGOS_FLAGS_DELIVER) )
for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
if (pQuest->ReqItemId[i] && pQuest->ReqItemCount[i] && !HasItemCount(pQuest->ReqItemId[i], pQuest->ReqItemCount[i]))
return false;
if (!CanRewardQuest(pQuest, false))
return false;
return true;
}
bool Player::CanRewardQuest( Quest const *pQuest, bool msg ) const
{
// not auto complete quest and not completed quest (only cheating case, then ignore without message)
if (!pQuest->IsAutoComplete() && GetQuestStatus(pQuest->GetQuestId()) != QUEST_STATUS_COMPLETE)
@ -13269,14 +13274,14 @@ bool Player::CanRewardQuest( Quest const *pQuest, bool msg )
return false;
// prevent receive reward with quest items in bank
if ( pQuest->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) )
if (pQuest->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ))
{
for(int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
{
if( pQuest->ReqItemCount[i] != 0 &&
GetItemCount(pQuest->ReqItemId[i]) < pQuest->ReqItemCount[i] )
if (pQuest->ReqItemCount[i] != 0 &&
GetItemCount(pQuest->ReqItemId[i]) < pQuest->ReqItemCount[i])
{
if(msg)
if (msg)
SendEquipError( EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL, pQuest->ReqItemId[i]);
return false;
}
@ -13284,25 +13289,25 @@ bool Player::CanRewardQuest( Quest const *pQuest, bool msg )
}
// prevent receive reward with low money and GetRewOrReqMoney() < 0
if (pQuest->GetRewOrReqMoney() < 0 && GetMoney() < uint32(-pQuest->GetRewOrReqMoney()) )
if (pQuest->GetRewOrReqMoney() < 0 && GetMoney() < uint32(-pQuest->GetRewOrReqMoney()))
return false;
return true;
}
bool Player::CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg )
bool Player::CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg ) const
{
// prevent receive reward with quest items in bank or for not completed quest
if(!CanRewardQuest(pQuest,msg))
if (!CanRewardQuest(pQuest,msg))
return false;
if ( pQuest->GetRewChoiceItemsCount() > 0 )
if (pQuest->GetRewChoiceItemsCount() > 0)
{
if( pQuest->RewChoiceItemId[reward] )
if (pQuest->RewChoiceItemId[reward])
{
ItemPosCountVec dest;
uint8 res = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewChoiceItemId[reward], pQuest->RewChoiceItemCount[reward] );
if( res != EQUIP_ERR_OK )
if (res != EQUIP_ERR_OK)
{
SendEquipError( res, NULL, NULL, pQuest->RewChoiceItemId[reward] );
return false;
@ -13310,15 +13315,15 @@ bool Player::CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg )
}
}
if ( pQuest->GetRewItemsCount() > 0 )
if (pQuest->GetRewItemsCount() > 0)
{
for (uint32 i = 0; i < pQuest->GetRewItemsCount(); ++i)
{
if( pQuest->RewItemId[i] )
if (pQuest->RewItemId[i])
{
ItemPosCountVec dest;
uint8 res = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, pQuest->RewItemId[i], pQuest->RewItemCount[i] );
if( res != EQUIP_ERR_OK )
if (res != EQUIP_ERR_OK)
{
SendEquipError( res, NULL, NULL );
return false;
@ -13633,22 +13638,22 @@ void Player::FailQuest(uint32 questId)
}
}
bool Player::SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg ) const
{
int32 zoneOrSort = qInfo->GetZoneOrSort();
int32 skillOrClass = qInfo->GetSkillOrClass();
// skip zone zoneOrSort and 0 case skillOrClass
if( zoneOrSort >= 0 && skillOrClass == 0 )
if (zoneOrSort >= 0 && skillOrClass == 0)
return true;
int32 questSort = -zoneOrSort;
uint8 reqSortClass = ClassByQuestSort(questSort);
// check class sort cases in zoneOrSort
if( reqSortClass != 0 && getClass() != reqSortClass)
if (reqSortClass != 0 && getClass() != reqSortClass)
{
if( msg )
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
return false;
}
@ -13679,24 +13684,24 @@ bool Player::SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg )
return true;
}
bool Player::SatisfyQuestLevel( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestLevel( Quest const* qInfo, bool msg ) const
{
if( getLevel() < qInfo->GetMinLevel() )
if (getLevel() < qInfo->GetMinLevel())
{
if( msg )
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
return false;
}
return true;
}
bool Player::SatisfyQuestLog( bool msg )
bool Player::SatisfyQuestLog( bool msg ) const
{
// exist free slot
if( FindQuestSlot(0) < MAX_QUEST_LOG_SIZE )
if (FindQuestSlot(0) < MAX_QUEST_LOG_SIZE)
return true;
if( msg )
if (msg)
{
WorldPacket data( SMSG_QUESTLOG_FULL, 0 );
GetSession()->SendPacket( &data );
@ -13705,10 +13710,10 @@ bool Player::SatisfyQuestLog( bool msg )
return false;
}
bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) const
{
// No previous quest (might be first quest in a series)
if( qInfo->prevQuests.empty())
if (qInfo->prevQuests.empty())
return true;
for(Quest::PrevQuests::const_iterator iter = qInfo->prevQuests.begin(); iter != qInfo->prevQuests.end(); ++iter )
@ -13718,13 +13723,13 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg )
QuestStatusMap::const_iterator i_prevstatus = mQuestStatus.find( prevId );
Quest const* qPrevInfo = sObjectMgr.GetQuestTemplate(prevId);
if( qPrevInfo && i_prevstatus != mQuestStatus.end() )
if (qPrevInfo && i_prevstatus != mQuestStatus.end())
{
// If any of the positive previous quests completed, return true
if( *iter > 0 && i_prevstatus->second.m_rewarded )
if (*iter > 0 && i_prevstatus->second.m_rewarded)
{
// skip one-from-all exclusive group
if(qPrevInfo->GetExclusiveGroup() >= 0)
if (qPrevInfo->GetExclusiveGroup() >= 0)
return true;
// each-from-all exclusive group ( < 0)
@ -13739,15 +13744,15 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg )
uint32 exclude_Id = iter2->second;
// skip checked quest id, only state of other quests in group is interesting
if(exclude_Id == prevId)
if (exclude_Id == prevId)
continue;
QuestStatusMap::const_iterator i_exstatus = mQuestStatus.find( exclude_Id );
// alternative quest from group also must be completed and rewarded(reported)
if( i_exstatus == mQuestStatus.end() || !i_exstatus->second.m_rewarded )
if (i_exstatus == mQuestStatus.end() || !i_exstatus->second.m_rewarded)
{
if( msg )
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
return false;
}
@ -13755,11 +13760,11 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg )
return true;
}
// If any of the negative previous quests active, return true
if( *iter < 0 && (i_prevstatus->second.m_status == QUEST_STATUS_INCOMPLETE
if (*iter < 0 && (i_prevstatus->second.m_status == QUEST_STATUS_INCOMPLETE
|| (i_prevstatus->second.m_status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus(prevId))))
{
// skip one-from-all exclusive group
if(qPrevInfo->GetExclusiveGroup() >= 0)
if (qPrevInfo->GetExclusiveGroup() >= 0)
return true;
// each-from-all exclusive group ( < 0)
@ -13774,17 +13779,17 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg )
uint32 exclude_Id = iter2->second;
// skip checked quest id, only state of other quests in group is interesting
if(exclude_Id == prevId)
if (exclude_Id == prevId)
continue;
QuestStatusMap::const_iterator i_exstatus = mQuestStatus.find( exclude_Id );
// alternative quest from group also must be active
if( i_exstatus == mQuestStatus.end() ||
if (i_exstatus == mQuestStatus.end() ||
i_exstatus->second.m_status != QUEST_STATUS_INCOMPLETE &&
(i_prevstatus->second.m_status != QUEST_STATUS_COMPLETE || GetQuestRewardStatus(prevId)) )
(i_prevstatus->second.m_status != QUEST_STATUS_COMPLETE || GetQuestRewardStatus(prevId)))
{
if( msg )
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
return false;
}
@ -13796,40 +13801,40 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg )
// Has only positive prev. quests in non-rewarded state
// and negative prev. quests in non-active state
if( msg )
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
return false;
}
bool Player::SatisfyQuestRace( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestRace( Quest const* qInfo, bool msg ) const
{
uint32 reqraces = qInfo->GetRequiredRaces();
if ( reqraces == 0 )
if (reqraces == 0)
return true;
if( (reqraces & getRaceMask()) == 0 )
if ((reqraces & getRaceMask()) == 0)
{
if( msg )
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_QUEST_FAILED_WRONG_RACE );
return false;
}
return true;
}
bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg ) const
{
uint32 fIdMin = qInfo->GetRequiredMinRepFaction(); //Min required rep
if(fIdMin && GetReputationMgr().GetReputation(fIdMin) < qInfo->GetRequiredMinRepValue())
if (fIdMin && GetReputationMgr().GetReputation(fIdMin) < qInfo->GetRequiredMinRepValue())
{
if( msg )
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
return false;
}
uint32 fIdMax = qInfo->GetRequiredMaxRepFaction(); //Max required rep
if(fIdMax && GetReputationMgr().GetReputation(fIdMax) >= qInfo->GetRequiredMaxRepValue())
if (fIdMax && GetReputationMgr().GetReputation(fIdMax) >= qInfo->GetRequiredMaxRepValue())
{
if( msg )
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
return false;
}
@ -13837,19 +13842,19 @@ bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg )
return true;
}
bool Player::SatisfyQuestStatus( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestStatus( Quest const* qInfo, bool msg ) const
{
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 );
return false;
}
return true;
}
bool Player::SatisfyQuestTimed(Quest const* qInfo, bool msg)
bool Player::SatisfyQuestTimed(Quest const* qInfo, bool msg) const
{
if (!m_timedquests.empty() && qInfo->HasFlag(QUEST_MANGOS_FLAGS_TIMED))
{
@ -13861,7 +13866,7 @@ bool Player::SatisfyQuestTimed(Quest const* qInfo, bool msg)
return true;
}
bool Player::SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg )
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)
@ -13889,13 +13894,13 @@ bool Player::SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg )
return false;
}
QuestStatusMap::iterator i_exstatus = mQuestStatus.find( exclude_Id );
QuestStatusMap::const_iterator i_exstatus = mQuestStatus.find( exclude_Id );
// alternative quest already started or completed
if (i_exstatus != mQuestStatus.end()
&& (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 );
return false;
}
@ -13903,17 +13908,17 @@ bool Player::SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg )
return true;
}
bool Player::SatisfyQuestNextChain( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestNextChain( Quest const* qInfo, bool msg ) const
{
if(!qInfo->GetNextQuestInChain())
if (!qInfo->GetNextQuestInChain())
return true;
// next quest in chain already started or completed
QuestStatusMap::const_iterator itr = mQuestStatus.find( qInfo->GetNextQuestInChain() );
if( itr != mQuestStatus.end()
&& (itr->second.m_status == QUEST_STATUS_COMPLETE || itr->second.m_status == QUEST_STATUS_INCOMPLETE) )
if (itr != mQuestStatus.end()
&& (itr->second.m_status == QUEST_STATUS_COMPLETE || itr->second.m_status == QUEST_STATUS_INCOMPLETE))
{
if( msg )
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
return false;
}
@ -13924,10 +13929,10 @@ bool Player::SatisfyQuestNextChain( Quest const* qInfo, bool msg )
return true;
}
bool Player::SatisfyQuestPrevChain( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestPrevChain( Quest const* qInfo, bool msg ) const
{
// No previous quest in chain
if( qInfo->prevChainQuests.empty())
if (qInfo->prevChainQuests.empty())
return true;
for(Quest::PrevChainQuests::const_iterator iter = qInfo->prevChainQuests.begin(); iter != qInfo->prevChainQuests.end(); ++iter )
@ -13936,13 +13941,13 @@ bool Player::SatisfyQuestPrevChain( Quest const* qInfo, bool msg )
QuestStatusMap::const_iterator i_prevstatus = mQuestStatus.find( prevId );
if( i_prevstatus != mQuestStatus.end() )
if (i_prevstatus != mQuestStatus.end())
{
// If any of the previous quests in chain active, return false
if( i_prevstatus->second.m_status == QUEST_STATUS_INCOMPLETE
if (i_prevstatus->second.m_status == QUEST_STATUS_INCOMPLETE
|| (i_prevstatus->second.m_status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus(prevId)))
{
if( msg )
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
return false;
}
@ -13958,7 +13963,7 @@ bool Player::SatisfyQuestPrevChain( Quest const* qInfo, bool msg )
return true;
}
bool Player::SatisfyQuestDay( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestDay( Quest const* qInfo, bool msg ) const
{
if (!qInfo->IsDaily())
return true;
@ -13970,13 +13975,13 @@ bool Player::SatisfyQuestDay( Quest const* qInfo, bool msg )
if (qInfo->GetQuestId()==id)
return false;
if(!id)
if (!id)
have_slot = true;
}
if (!have_slot)
{
if( msg )
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DAILY_QUESTS_REMAINING );
return false;
}
@ -13984,7 +13989,7 @@ bool Player::SatisfyQuestDay( Quest const* qInfo, bool msg )
return true;
}
bool Player::SatisfyQuestWeek( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestWeek( Quest const* qInfo, bool msg ) const
{
if (!qInfo->IsWeekly() || m_weeklyquests.empty())
return true;
@ -14636,7 +14641,7 @@ void Player::SendQuestTimerFailed( uint32 quest_id )
}
}
void Player::SendCanTakeQuestResponse( uint32 msg )
void Player::SendCanTakeQuestResponse( uint32 msg ) const
{
WorldPacket data( SMSG_QUESTGIVER_QUEST_INVALID, 4 );
data << uint32(msg);