From 6e1c9114df9be02acad3accca0df575b491eaa53 Mon Sep 17 00:00:00 2001 From: SaW Date: Tue, 21 Oct 2025 10:36:10 +0200 Subject: [PATCH] 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 --- src/strategy/actions/TalkToQuestGiverAction.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/strategy/actions/TalkToQuestGiverAction.cpp b/src/strategy/actions/TalkToQuestGiverAction.cpp index ad87a550..7f791d0d 100644 --- a/src/strategy/actions/TalkToQuestGiverAction.cpp +++ b/src/strategy/actions/TalkToQuestGiverAction.cpp @@ -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); }