FIX: part of logic in picking quest reward (#1752)

* FIX: part of logic in picking reward

Avoids dereferencing begin() after confirming the set is empty.

* Update TalkToQuestGiverAction.cpp
This commit is contained in:
SaW
2025-10-21 10:36:10 +02:00
committed by GitHub
parent 7e810f8174
commit 6e1c9114df

View File

@@ -205,17 +205,18 @@ void TalkToQuestGiverAction::RewardMultipleItem(Quest const* quest, Object* ques
}
else
{
// Try to pick the usable item. If multiple list usable rewards.
// Try to pick the usable item. If multiple, list usable rewards.
bestIds = BestRewards(quest);
if (!bestIds.empty())
{
if (bestIds.size() > 1)
AskToSelectReward(quest, out, true);
}
else
else if (!bestIds.empty())
{
// Pick the first item
ItemTemplate const* item = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[*bestIds.begin()]);
bot->RewardQuest(quest, *bestIds.begin(), questGiver, true);
uint32 firstId = *bestIds.begin();
ItemTemplate const* item = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[firstId]);
bot->RewardQuest(quest, firstId, questGiver, true);
out << "Rewarded " << ChatHelper::FormatItem(item);
}