fix(Core/Scripts): missing null checks for GetCharmerOrOwner and GetOwner (#24902)
This commit is contained in:
@@ -746,10 +746,15 @@ bool PetAI::CanAttack(Unit* target, SpellInfo const* spellInfo)
|
|||||||
|
|
||||||
// Check if our owner selected this target and clicked "attack"
|
// Check if our owner selected this target and clicked "attack"
|
||||||
Unit* ownerTarget = nullptr;
|
Unit* ownerTarget = nullptr;
|
||||||
if (Player* owner = me->GetCharmerOrOwner()->ToPlayer())
|
Unit* charmerOrOwner = me->GetCharmerOrOwner();
|
||||||
ownerTarget = owner->GetSelectedUnit();
|
|
||||||
else
|
if (charmerOrOwner)
|
||||||
ownerTarget = me->GetCharmerOrOwner()->GetVictim();
|
{
|
||||||
|
if (Player* owner = charmerOrOwner->ToPlayer())
|
||||||
|
ownerTarget = owner->GetSelectedUnit();
|
||||||
|
else
|
||||||
|
ownerTarget = charmerOrOwner->GetVictim();
|
||||||
|
}
|
||||||
|
|
||||||
if (ownerTarget && me->GetCharmInfo()->IsCommandAttack())
|
if (ownerTarget && me->GetCharmInfo()->IsCommandAttack())
|
||||||
return (target->GetGUID() == ownerTarget->GetGUID());
|
return (target->GetGUID() == ownerTarget->GetGUID());
|
||||||
|
|||||||
@@ -2559,7 +2559,7 @@ class spell_gen_vehicle_scaling_aura: public AuraScript
|
|||||||
|
|
||||||
bool Load() override
|
bool Load() override
|
||||||
{
|
{
|
||||||
return GetCaster() && GetCaster()->IsPlayer() && GetOwner()->IsCreature();
|
return GetCaster() && GetCaster()->IsPlayer() && GetOwner() && GetOwner()->IsCreature();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
|
void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
|
||||||
|
|||||||
@@ -2674,7 +2674,8 @@ struct npc_controller : public PossessedAI
|
|||||||
{
|
{
|
||||||
if (!apply)
|
if (!apply)
|
||||||
{
|
{
|
||||||
me->GetCharmerOrOwner()->InterruptNonMeleeSpells(false);
|
if (Unit* charmerOrOwner = me->GetCharmerOrOwner())
|
||||||
|
charmerOrOwner->InterruptNonMeleeSpells(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user