mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[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:
parent
5ea6815ea1
commit
5eabf12111
6 changed files with 193 additions and 179 deletions
|
|
@ -7455,6 +7455,13 @@ bool PlayerCondition::Meets(Player const * player) const
|
|||
return data->CheckConditionCriteriaMeet(player, value1, value2);
|
||||
return false;
|
||||
}
|
||||
case CONDITION_QUESTAVAILABLE:
|
||||
{
|
||||
if (Quest const* quest = sObjectMgr.GetQuestTemplate(value1))
|
||||
return player->CanTakeQuest(quest, false);
|
||||
else
|
||||
false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -7563,6 +7570,7 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val
|
|||
}
|
||||
case CONDITION_QUESTREWARDED:
|
||||
case CONDITION_QUESTTAKEN:
|
||||
case CONDITION_QUESTAVAILABLE:
|
||||
{
|
||||
Quest const *Quest = sObjectMgr.GetQuestTemplate(value1);
|
||||
if (!Quest)
|
||||
|
|
|
|||
|
|
@ -317,9 +317,10 @@ enum ConditionType
|
|||
CONDITION_NOITEM = 16, // item_id count
|
||||
CONDITION_SPELL = 17, // spell_id 0, 1 (0: has spell, 1: hasn't spell)
|
||||
CONDITION_INSTANCE_SCRIPT = 18, // map_id instance_condition_id (instance script specific enum)
|
||||
CONDITION_QUESTAVAILABLE = 19, // quest_id 0 for case when loot/gossip possible only if player can start quest
|
||||
};
|
||||
|
||||
#define MAX_CONDITION 19 // maximum value in ConditionType enum
|
||||
#define MAX_CONDITION 20 // maximum value in ConditionType enum
|
||||
|
||||
struct PlayerCondition
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
if (!quest_id)
|
||||
return false;
|
||||
|
||||
QuestStatusMap::const_iterator q_itr = mQuestStatus.find(quest_id);
|
||||
|
||||
// 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)
|
||||
if (!qInfo)
|
||||
return false;
|
||||
|
||||
// auto complete quest
|
||||
if (qInfo->IsAutoComplete() && CanTakeQuest(qInfo, false))
|
||||
return true;
|
||||
|
||||
if ( q_status.m_status == QUEST_STATUS_INCOMPLETE )
|
||||
{
|
||||
if (status != QUEST_STATUS_INCOMPLETE)
|
||||
return false;
|
||||
|
||||
if ( qInfo->HasFlag( QUEST_MANGOS_FLAGS_DELIVER ) )
|
||||
// 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] )
|
||||
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) )
|
||||
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 )
|
||||
if (qInfo->ReqCreatureOrGOId[i] == 0)
|
||||
continue;
|
||||
|
||||
if( qInfo->ReqCreatureOrGOCount[i] != 0 && q_status.m_creatureOrGOcount[i] < qInfo->ReqCreatureOrGOCount[i] )
|
||||
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 )
|
||||
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 )
|
||||
if (qInfo->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) && q_status.m_timer == 0)
|
||||
return false;
|
||||
|
||||
if ( qInfo->GetRewOrReqMoney() < 0 )
|
||||
if (qInfo->GetRewOrReqMoney() < 0)
|
||||
{
|
||||
if ( GetMoney() < uint32(-qInfo->GetRewOrReqMoney()) )
|
||||
if (GetMoney() < uint32(-qInfo->GetRewOrReqMoney()))
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 repFacId = qInfo->GetRepObjectiveFaction();
|
||||
if ( repFacId && GetReputationMgr().GetReputation(repFacId) < qInfo->GetRepObjectiveValue() )
|
||||
if (repFacId && GetReputationMgr().GetReputation(repFacId) < qInfo->GetRepObjectiveValue())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Player::CanCompleteRepeatableQuest( Quest const *pQuest )
|
||||
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) )
|
||||
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]) )
|
||||
if (pQuest->ReqItemId[i] && pQuest->ReqItemCount[i] && !HasItemCount(pQuest->ReqItemId[i], pQuest->ReqItemCount[i]))
|
||||
return false;
|
||||
|
||||
if( !CanRewardQuest(pQuest, false) )
|
||||
if (!CanRewardQuest(pQuest, false))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::CanRewardQuest( Quest const *pQuest, bool msg )
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -1259,7 +1259,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
Item* GetItemFromBuyBackSlot( uint32 slot );
|
||||
void RemoveItemFromBuyBackSlot( uint32 slot, bool del );
|
||||
uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; }
|
||||
void SendEquipError( uint8 msg, Item* pItem, Item *pItem2 = NULL, uint32 itemid = 0 );
|
||||
void SendEquipError( uint8 msg, Item* pItem, Item *pItem2 = NULL, uint32 itemid = 0 ) const;
|
||||
void SendBuyError( uint8 msg, Creature* pCreature, uint32 item, uint32 param );
|
||||
void SendSellError( uint8 msg, Creature* pCreature, uint64 guid, uint32 param );
|
||||
void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
|
||||
|
|
@ -1326,32 +1326,32 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
void SendPreparedQuest( uint64 guid );
|
||||
bool IsActiveQuest( uint32 quest_id ) const;
|
||||
Quest const *GetNextQuest( uint64 guid, Quest const *pQuest );
|
||||
bool CanSeeStartQuest( Quest const *pQuest );
|
||||
bool CanTakeQuest( Quest const *pQuest, bool msg );
|
||||
bool CanAddQuest( Quest const *pQuest, bool msg );
|
||||
bool CanCompleteQuest( uint32 quest_id );
|
||||
bool CanCompleteRepeatableQuest(Quest const *pQuest);
|
||||
bool CanRewardQuest( Quest const *pQuest, bool msg );
|
||||
bool CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg );
|
||||
bool CanSeeStartQuest( Quest const *pQuest ) const;
|
||||
bool CanTakeQuest( Quest const *pQuest, bool msg ) const;
|
||||
bool CanAddQuest( Quest const *pQuest, bool msg ) const;
|
||||
bool CanCompleteQuest( uint32 quest_id ) const;
|
||||
bool CanCompleteRepeatableQuest(Quest const *pQuest) const;
|
||||
bool CanRewardQuest( Quest const *pQuest, bool msg ) const;
|
||||
bool CanRewardQuest( Quest const *pQuest, uint32 reward, bool msg ) const;
|
||||
void AddQuest( Quest const *pQuest, Object *questGiver );
|
||||
void CompleteQuest( uint32 quest_id );
|
||||
void IncompleteQuest( uint32 quest_id );
|
||||
void RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver, bool announce = true );
|
||||
|
||||
void FailQuest( uint32 quest_id );
|
||||
bool SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg );
|
||||
bool SatisfyQuestLevel( Quest const* qInfo, bool msg );
|
||||
bool SatisfyQuestLog( bool msg );
|
||||
bool SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg );
|
||||
bool SatisfyQuestRace( Quest const* qInfo, bool msg );
|
||||
bool SatisfyQuestReputation( Quest const* qInfo, bool msg );
|
||||
bool SatisfyQuestStatus( Quest const* qInfo, bool msg );
|
||||
bool SatisfyQuestTimed( Quest const* qInfo, bool msg );
|
||||
bool SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg );
|
||||
bool SatisfyQuestNextChain( Quest const* qInfo, bool msg );
|
||||
bool SatisfyQuestPrevChain( Quest const* qInfo, bool msg );
|
||||
bool SatisfyQuestDay( Quest const* qInfo, bool msg );
|
||||
bool SatisfyQuestWeek( Quest const* qInfo, bool msg );
|
||||
bool SatisfyQuestSkillOrClass( Quest const* qInfo, bool msg ) const;
|
||||
bool SatisfyQuestLevel( Quest const* qInfo, bool msg ) const;
|
||||
bool SatisfyQuestLog( bool msg ) const;
|
||||
bool SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) const;
|
||||
bool SatisfyQuestRace( Quest const* qInfo, bool msg ) const;
|
||||
bool SatisfyQuestReputation( Quest const* qInfo, bool msg ) const;
|
||||
bool SatisfyQuestStatus( Quest const* qInfo, bool msg ) const;
|
||||
bool SatisfyQuestTimed( Quest const* qInfo, bool msg ) const;
|
||||
bool SatisfyQuestExclusiveGroup( Quest const* qInfo, bool msg ) const;
|
||||
bool SatisfyQuestNextChain( Quest const* qInfo, bool msg ) const;
|
||||
bool SatisfyQuestPrevChain( Quest const* qInfo, bool msg ) const;
|
||||
bool SatisfyQuestDay( Quest const* qInfo, bool msg ) const;
|
||||
bool SatisfyQuestWeek( Quest const* qInfo, bool msg ) const;
|
||||
bool GiveQuestSourceItem( Quest const *pQuest );
|
||||
bool TakeQuestSourceItem( uint32 quest_id, bool msg );
|
||||
bool GetQuestRewardStatus( uint32 quest_id ) const;
|
||||
|
|
@ -1417,7 +1417,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver );
|
||||
void SendQuestFailed( uint32 quest_id );
|
||||
void SendQuestTimerFailed( uint32 quest_id );
|
||||
void SendCanTakeQuestResponse( uint32 msg );
|
||||
void SendCanTakeQuestResponse( uint32 msg ) const;
|
||||
void SendQuestConfirmAccept(Quest const* pQuest, Player* pReceiver);
|
||||
void SendPushToPartyResponse( Player *pPlayer, uint32 msg );
|
||||
void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count );
|
||||
|
|
@ -1474,7 +1474,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
void setRegenTimer(uint32 time) {m_regenTimer = time;}
|
||||
void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
|
||||
|
||||
uint32 GetMoney() { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
|
||||
uint32 GetMoney() const { return GetUInt32Value (PLAYER_FIELD_COINAGE); }
|
||||
void ModifyMoney( int32 d )
|
||||
{
|
||||
if(d < 0)
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ enum QuestStatus
|
|||
QUEST_STATUS_COMPLETE = 1,
|
||||
QUEST_STATUS_UNAVAILABLE = 2,
|
||||
QUEST_STATUS_INCOMPLETE = 3,
|
||||
QUEST_STATUS_AVAILABLE = 4,
|
||||
QUEST_STATUS_AVAILABLE = 4, // unused in fact
|
||||
QUEST_STATUS_FAILED = 5,
|
||||
MAX_QUEST_STATUS
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "10041"
|
||||
#define REVISION_NR "10042"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue