Core/Quests: Fixed destroying of quest items which start a quest and are also needed for completing this quest

This commit is contained in:
Lopin
2011-06-18 21:08:14 +02:00
parent f778c5e739
commit 19ede8fa72
2 changed files with 23 additions and 12 deletions
+22 -11
View File
@@ -15449,31 +15449,42 @@ bool Player::GiveQuestSourceItem(Quest const *pQuest)
return true;
}
bool Player::TakeQuestSourceItem(uint32 quest_id, bool msg)
bool Player::TakeQuestSourceItem(uint32 questId, bool msg)
{
Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id);
if (qInfo)
Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
if (quest)
{
uint32 srcitem = qInfo->GetSrcItemId();
if (srcitem > 0)
uint32 srcItemId = quest->GetSrcItemId();
ItemTemplate const* item = sObjectMgr->GetItemTemplate(srcItemId);
bool destroyItem = true;
if (srcItemId > 0)
{
uint32 count = qInfo->GetSrcItemCount();
uint32 count = quest->GetSrcItemCount();
if (count <= 0)
count = 1;
// exist one case when destroy source quest item not possible:
// non un-equippable item (equipped non-empty bag, for example)
InventoryResult res = CanUnequipItems(srcitem, count);
// exist two cases when destroy source quest item not possible:
// a) non un-equippable item (equipped non-empty bag, for example)
// b) when quest is started from an item and item also is needed in
// the end as ReqItemId
InventoryResult res = CanUnequipItems(srcItemId, count);
if (res != EQUIP_ERR_OK)
{
if (msg)
SendEquipError(res, NULL, NULL, srcitem);
SendEquipError(res, NULL, NULL, srcItemId);
return false;
}
DestroyItemCount(srcitem, count, true, true);
for (uint8 n = 0; n < QUEST_ITEM_OBJECTIVES_COUNT; ++n)
if (item->StartQuest == questId && srcItemId == quest->ReqItemId[n])
destroyItem = false;
if (destroyItem)
DestroyItemCount(srcItemId, count, true, true);
}
}
return true;
}
+1 -1
View File
@@ -1379,7 +1379,7 @@ class Player : public Unit, public GridObject<Player>
bool SatisfyQuestDay(Quest const* qInfo, bool msg);
bool SatisfyQuestWeek(Quest const* qInfo, bool msg);
bool GiveQuestSourceItem(Quest const *pQuest);
bool TakeQuestSourceItem(uint32 quest_id, bool msg);
bool TakeQuestSourceItem(uint32 questId, bool msg);
bool GetQuestRewardStatus(uint32 quest_id) const;
QuestStatus GetQuestStatus(uint32 quest_id) const;
void SetQuestStatus(uint32 quest_id, QuestStatus status);