fix(Core/SAI): Fix crash in SMART_TARGET_OWNER_OR_SUMMONER (#22789)

This commit is contained in:
Andrew
2025-09-04 06:19:25 -03:00
committed by GitHub
parent af31aaa374
commit d69f61d7ab

View File

@@ -3834,19 +3834,20 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
{ {
targets.clear(); targets.clear();
if (owner->ToCreature()) if (IsCreature(owner))
{ {
if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID())) if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToCreature()->GetCharmerOrOwnerGUID()))
{
targets.push_back(base); targets.push_back(base);
}
} }
else else if (IsGameObject(owner))
{ {
if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID())) if (Unit* base = ObjectAccessor::GetUnit(*owner, owner->ToGameObject()->GetOwnerGUID()))
{
targets.push_back(base); targets.push_back(base);
} }
else if (IsPlayer(owner))
{
if (Unit* base = owner->ToPlayer()->GetCharmerOrOwner())
targets.push_back(base);
} }
} }
} }