Prevent crash by guarding creatureData against nullptr

This commit is contained in:
qudzy
2022-06-01 21:46:10 +02:00
parent 66e77e324d
commit 1d7c709b52

View File

@@ -53,8 +53,13 @@ CDPairCalculatedValue::CDPairCalculatedValue(PlayerbotAI* botAI, std::string con
std::string const CDPairCalculatedValue::Format()
{
CreatureData const* creatureData = Calculate();
CreatureTemplate const* bmTemplate = sObjectMgr->GetCreatureTemplate(creatureData->id1);
return bmTemplate ? bmTemplate->Name : "<none>";
if (creatureData)
{
CreatureTemplate const* bmTemplate = sObjectMgr->GetCreatureTemplate(creatureData->id1);
return bmTemplate ? bmTemplate->Name : "<none>";
}
return "<none>";
}
CDPairListCalculatedValue::CDPairListCalculatedValue(PlayerbotAI* botAI, std::string const name, int32 checkInterval) :