summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew <47818697+Nyeriah@users.noreply.github.com>2025-09-15 19:05:50 -0300
committerGitHub <noreply@github.com>2025-09-15 19:05:50 -0300
commit9e0b6ff7a646f43b9c1d17d06ee8e001fb5b07fa (patch)
treeced474174b85cd95ef51e6d85f645486681eddf5 /src
parent1aa5788f723c2bd13fa855ae008dad50be701cf3 (diff)
fix(Core/Creature): ensure target is valid when acquiring GUID (#22937)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CreatureAI.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index 95e9b042ce..0f74877007 100644
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -53,17 +53,19 @@ void CreatureAI::Talk(uint8 id, WorldObject const* target /*= nullptr*/, Millise
{
if (delay > Seconds::zero())
{
- ObjectGuid targetGuid = target->GetGUID();
+ ObjectGuid targetGuid;
+
+ if (target)
+ targetGuid = target->GetGUID();
+
me->m_Events.AddEventAtOffset([this, id, targetGuid]()
{
- if (Unit* textTarget = ObjectAccessor::GetUnit(*me, targetGuid))
- sCreatureTextMgr->SendChat(me, id, textTarget);
+ // Target can be nullptr here, it will be handled inside the function.
+ sCreatureTextMgr->SendChat(me, id, ObjectAccessor::GetUnit(*me, targetGuid));
}, delay);
}
else
- {
sCreatureTextMgr->SendChat(me, id, target);
- }
}
/**