diff --git a/src/game/Player.cpp b/src/game/Player.cpp index b48f2911e..8a17d2b7d 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -13231,22 +13231,9 @@ bool Player::CanAddQuest( Quest const *pQuest, bool msg ) const if (!SatisfyQuestLog( msg )) return false; - uint32 srcitem = pQuest->GetSrcItemId(); - if (srcitem > 0) - { - uint32 count = pQuest->GetSrcItemCount(); - ItemPosCountVec dest; - uint8 msg2 = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count ); + if (!CanGiveQuestSourceItem(pQuest)) + return false; - // 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) - return true; - else if (msg2 != EQUIP_ERR_OK) - { - SendEquipError(msg2, NULL, NULL, srcitem); - return false; - } - } return true; } @@ -13446,7 +13433,8 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver ) questStatusData.m_creatureOrGOcount[i] = 0; } - GiveQuestSourceItem( pQuest ); + GiveQuestSourceItem(pQuest); + AdjustQuestReqItemCount( pQuest, questStatusData ); if( pQuest->GetRepObjectiveFaction() ) @@ -14058,7 +14046,7 @@ bool Player::SatisfyQuestWeek( Quest const* qInfo, bool msg ) const return m_weeklyquests.find(qInfo->GetQuestId()) == m_weeklyquests.end(); } -bool Player::GiveQuestSourceItem( Quest const *pQuest ) +bool Player::CanGiveQuestSourceItem( Quest const *pQuest, ItemPosCountVec* dest ) const { uint32 srcitem = pQuest->GetSrcItemId(); if (srcitem > 0) @@ -14067,14 +14055,17 @@ bool Player::GiveQuestSourceItem( Quest const *pQuest ) if( count <= 0 ) count = 1; - ItemPosCountVec dest; - uint8 msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count ); - if (msg == EQUIP_ERR_OK) + uint8 msg; + if (!dest) { - Item * item = StoreNewItem(dest, srcitem, true); - SendNewItem(item, count, true, false); - return true; + ItemPosCountVec destTemp; + msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, destTemp, srcitem, count ); } + else + msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, *dest, srcitem, count ); + + if (msg == EQUIP_ERR_OK) + return true; // player already have max amount required item, just report success else if (msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS) return true; @@ -14086,6 +14077,22 @@ bool Player::GiveQuestSourceItem( Quest const *pQuest ) return true; } +void Player::GiveQuestSourceItem( Quest const *pQuest ) +{ + ItemPosCountVec dest; + + if (CanGiveQuestSourceItem(pQuest, &dest) && !dest.empty()) + { + uint32 count = 0; + for(ItemPosCountVec::const_iterator c_itr = dest.begin(); c_itr != dest.end(); ++c_itr) + count += c_itr->count; + + Item * item = StoreNewItem(dest, pQuest->GetSrcItemId(), true); + SendNewItem(item, count, true, false); + } +} + + bool Player::TakeQuestSourceItem( uint32 quest_id, bool msg ) { Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest_id); diff --git a/src/game/Player.h b/src/game/Player.h index 059aa2b57..afe9c7a2e 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1405,7 +1405,8 @@ class MANGOS_DLL_SPEC Player : public Unit 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 CanGiveQuestSourceItem( Quest const *pQuest, ItemPosCountVec* dest = NULL) const; + void GiveQuestSourceItem( Quest const *pQuest ); bool TakeQuestSourceItem( uint32 quest_id, bool msg ); bool GetQuestRewardStatus( uint32 quest_id ) const; QuestStatus GetQuestStatus( uint32 quest_id ) const; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4d4867cf1..81989299f 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10139" + #define REVISION_NR "10140" #endif // __REVISION_NR_H__