From 9e0b6ff7a646f43b9c1d17d06ee8e001fb5b07fa Mon Sep 17 00:00:00 2001 From: Andrew <47818697+Nyeriah@users.noreply.github.com> Date: Mon, 15 Sep 2025 19:05:50 -0300 Subject: [PATCH] fix(Core/Creature): ensure target is valid when acquiring GUID (#22937) --- src/server/game/AI/CreatureAI.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 95e9b042c..0f7487700 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); - } } /**