diff --git a/src/strategy/actions/QueryQuestAction.cpp b/src/strategy/actions/QueryQuestAction.cpp index 8769ef3b..960bf84a 100644 --- a/src/strategy/actions/QueryQuestAction.cpp +++ b/src/strategy/actions/QueryQuestAction.cpp @@ -113,21 +113,33 @@ bool QueryQuestAction::Execute(Event event) void QueryQuestAction::TellObjectives(uint32 questId) { Quest const* questTemplate = sObjectMgr->GetQuestTemplate(questId); + + // Checks if the questTemplate is valid + if (!questTemplate) + { + botAI->TellMaster("Quest template not found."); + return; + } + QuestStatusData questStatus = bot->getQuestStatusMap()[questId]; for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) { + // Checks for objective text if (!questTemplate->ObjectiveText[i].empty()) botAI->TellMaster(questTemplate->ObjectiveText[i]); + // Checks for required items if (questTemplate->RequiredItemId[i]) { uint32 required = questTemplate->RequiredItemCount[i]; uint32 available = questStatus.ItemCount[i]; ItemTemplate const* proto = sObjectMgr->GetItemTemplate(questTemplate->RequiredItemId[i]); - TellObjective(chat->FormatItem(proto), available, required); + if (proto) + TellObjective(chat->FormatItem(proto), available, required); } + // Checks for required NPCs or GOs if (questTemplate->RequiredNpcOrGo[i]) { uint32 required = questTemplate->RequiredNpcOrGoCount[i]; @@ -135,8 +147,7 @@ void QueryQuestAction::TellObjectives(uint32 questId) if (questTemplate->RequiredNpcOrGo[i] < 0) { - if (GameObjectTemplate const* info = - sObjectMgr->GetGameObjectTemplate(-questTemplate->RequiredNpcOrGo[i])) + if (GameObjectTemplate const* info = sObjectMgr->GetGameObjectTemplate(-questTemplate->RequiredNpcOrGo[i])) TellObjective(info->name, available, required); } else diff --git a/src/strategy/values/EstimatedLifetimeValue.cpp b/src/strategy/values/EstimatedLifetimeValue.cpp index b69861c4..6ab58f83 100644 --- a/src/strategy/values/EstimatedLifetimeValue.cpp +++ b/src/strategy/values/EstimatedLifetimeValue.cpp @@ -25,7 +25,7 @@ float EstimatedLifetimeValue::Calculate() float EstimatedGroupDpsValue::Calculate() { - float totalDps; + float totalDps = 0; std::vector groupPlayer = {bot}; if (Group* group = bot->GetGroup())