Skip to content

Commit

Permalink
[10043] Fixed share quest in case completed objectives.
Browse files Browse the repository at this point in the history
* Also fixed CONDITION_QUESTTAKEN for same case.
* Aslo fixed exclusive prev quests check.
  • Loading branch information
VladimirMangos committed Jun 7, 2010
1 parent 6eb863f commit 5da6d23
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 29 deletions.
3 changes: 1 addition & 2 deletions src/game/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7397,8 +7397,7 @@ bool PlayerCondition::Meets(Player const * player) const
return player->GetQuestRewardStatus(value1);
case CONDITION_QUESTTAKEN:
{
QuestStatus status = player->GetQuestStatus(value1);
return (status == QUEST_STATUS_INCOMPLETE);
return player->IsCurrentQuest(value1);
}
case CONDITION_AD_COMMISSION_AURA:
{
Expand Down
45 changes: 20 additions & 25 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13086,6 +13086,15 @@ bool Player::IsActiveQuest( uint32 quest_id ) const
return itr != mQuestStatus.end() && itr->second.m_status != QUEST_STATUS_NONE;
}

bool Player::IsCurrentQuest( uint32 quest_id ) const
{
QuestStatusMap::const_iterator itr = mQuestStatus.find(quest_id);
if (itr == mQuestStatus.end())
return false;

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 )
{
Object *pObject;
Expand Down Expand Up @@ -13760,8 +13769,7 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) const
return true;
}
// If any of the negative previous quests active, return true
if (*iter < 0 && (i_prevstatus->second.m_status == QUEST_STATUS_INCOMPLETE
|| (i_prevstatus->second.m_status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus(prevId))))
if (*iter < 0 && IsCurrentQuest(prevId))
{
// skip one-from-all exclusive group
if (qPrevInfo->GetExclusiveGroup() >= 0)
Expand All @@ -13782,12 +13790,8 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg ) const
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() ||
i_exstatus->second.m_status != QUEST_STATUS_INCOMPLETE &&
(i_prevstatus->second.m_status != QUEST_STATUS_COMPLETE || GetQuestRewardStatus(prevId)))
if (!IsCurrentQuest(exclude_Id))
{
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
Expand Down Expand Up @@ -13939,18 +13943,12 @@ bool Player::SatisfyQuestPrevChain( Quest const* qInfo, bool msg ) const
{
uint32 prevId = *iter;

QuestStatusMap::const_iterator i_prevstatus = mQuestStatus.find( prevId );

if (i_prevstatus != mQuestStatus.end())
// If any of the previous quests in chain active, return false
if (IsCurrentQuest(prevId))
{
// If any of the previous quests in chain active, return false
if (i_prevstatus->second.m_status == QUEST_STATUS_INCOMPLETE
|| (i_prevstatus->second.m_status == QUEST_STATUS_COMPLETE && !GetQuestRewardStatus(prevId)))
{
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
return false;
}
if (msg)
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
return false;
}

// check for all quests further down the chain
Expand Down Expand Up @@ -14083,13 +14081,10 @@ QuestStatus Player::GetQuestStatus( uint32 quest_id ) const

bool Player::CanShareQuest(uint32 quest_id) const
{
Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest_id);
if( qInfo && qInfo->HasFlag(QUEST_FLAGS_SHARABLE) )
{
QuestStatusMap::const_iterator itr = mQuestStatus.find( quest_id );
if( itr != mQuestStatus.end() )
return itr->second.m_status == QUEST_STATUS_NONE || itr->second.m_status == QUEST_STATUS_INCOMPLETE;
}
if (Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest_id))
if (qInfo->HasFlag(QUEST_FLAGS_SHARABLE))
return IsCurrentQuest(quest_id);

return false;
}

Expand Down
3 changes: 2 additions & 1 deletion src/game/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,8 @@ class MANGOS_DLL_SPEC Player : public Unit

void PrepareQuestMenu( uint64 guid );
void SendPreparedQuest( uint64 guid );
bool IsActiveQuest( uint32 quest_id ) const;
bool IsActiveQuest( uint32 quest_id ) const; // can be taken or taken
bool IsCurrentQuest( uint32 quest_id ) const; // taken and not yet rewarded
Quest const *GetNextQuest( uint64 guid, Quest const *pQuest );
bool CanSeeStartQuest( Quest const *pQuest ) const;
bool CanTakeQuest( Quest const *pQuest, bool msg ) const;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10042"
#define REVISION_NR "10043"
#endif // __REVISION_NR_H__

0 comments on commit 5da6d23

Please sign in to comment.