mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 02:04:52 +01:00
Core/Players: Improve quest item adding/removal checks, solves cases where quest item removal (under specific conditions) incorrectly incompletes quests
This commit is contained in:
@@ -16383,12 +16383,8 @@ void Player::ItemAddedQuestCheck(uint32 entry, uint32 count)
|
||||
uint16 curitemcount = q_status.ItemCount[j];
|
||||
if (curitemcount < reqitemcount)
|
||||
{
|
||||
uint16 additemcount = curitemcount + count <= reqitemcount ? count : reqitemcount - curitemcount;
|
||||
q_status.ItemCount[j] += additemcount;
|
||||
|
||||
q_status.ItemCount[j] = std::min<uint16>(q_status.ItemCount[j] + count, reqitemcount);
|
||||
m_QuestStatusSave[questid] = true;
|
||||
|
||||
SendQuestUpdateAddItem(qInfo, j, additemcount);
|
||||
}
|
||||
if (CanCompleteQuest(questid))
|
||||
CompleteQuest(questid);
|
||||
@@ -16406,9 +16402,11 @@ void Player::ItemRemovedQuestCheck(uint32 entry, uint32 count)
|
||||
uint32 questid = GetQuestSlotQuestId(i);
|
||||
if (!questid)
|
||||
continue;
|
||||
|
||||
Quest const* qInfo = sObjectMgr->GetQuestTemplate(questid);
|
||||
if (!qInfo)
|
||||
continue;
|
||||
|
||||
if (!qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAGS_DELIVER))
|
||||
continue;
|
||||
|
||||
@@ -16420,18 +16418,17 @@ void Player::ItemRemovedQuestCheck(uint32 entry, uint32 count)
|
||||
QuestStatusData& q_status = m_QuestStatus[questid];
|
||||
|
||||
uint32 reqitemcount = qInfo->RequiredItemCount[j];
|
||||
uint16 curitemcount;
|
||||
if (q_status.Status != QUEST_STATUS_COMPLETE)
|
||||
curitemcount = q_status.ItemCount[j];
|
||||
else
|
||||
curitemcount = GetItemCount(entry, true);
|
||||
if (curitemcount < reqitemcount + count)
|
||||
uint16 curitemcount = q_status.ItemCount[j];
|
||||
|
||||
if (q_status.ItemCount[j] >= reqitemcount) // we may have more than what the status shows
|
||||
curitemcount = GetItemCount(entry, false);
|
||||
|
||||
uint16 newItemCount = (count > curitemcount) ? 0 : curitemcount - count;
|
||||
newItemCount = std::min<uint16>(newItemCount, reqitemcount);
|
||||
if (newItemCount != q_status.ItemCount[j])
|
||||
{
|
||||
uint16 remitemcount = curitemcount <= reqitemcount ? count : count + reqitemcount - curitemcount;
|
||||
q_status.ItemCount[j] = (curitemcount <= remitemcount) ? 0 : curitemcount - remitemcount;
|
||||
|
||||
q_status.ItemCount[j] = newItemCount;
|
||||
m_QuestStatusSave[questid] = true;
|
||||
|
||||
IncompleteQuest(questid);
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user