Core/Misc: Fix some static analysis issues
Fix some static analysis issues about missing NULL checks. Pass safe Creature pointer instead of summoning a Creature, passing the GUID and retrieve the same Creature from GUID.
This commit is contained in:
1 parent
0a9e58c2cc
commit
5bbded18b5
3 files changed
+13
-8
No files matched your search
@@ -718,6 +718,12 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket)
|
||||
}
|
||||
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
|
||||
if (!spellInfo)
|
||||
{
|
||||
TC_LOG_ERROR("network", "WORLD: unknown PET spell id %u", spellid);
|
||||
return;
|
||||
}
|
||||
|
||||
// do not add not learned spells/ passive spells
|
||||
if (!pet->HasSpell(spellid) || !spellInfo->IsAutocastable())
|
||||
return;
|
||||
|
||||
@@ -614,7 +614,8 @@ public:
|
||||
}
|
||||
return 50000;
|
||||
case 15:
|
||||
arca->DealDamage(arca, arca->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
|
||||
if (arca)
|
||||
arca->DealDamage(arca, arca->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
|
||||
return 5000;
|
||||
default : return 9999999;
|
||||
}
|
||||
|
||||
@@ -57,16 +57,15 @@ public:
|
||||
float x, y, z;
|
||||
me->GetClosePoint(x, y, z, me->GetObjectSize() / 3, 0.1f);
|
||||
|
||||
if (Unit* summon = me->SummonCreature(NPC_RAGECLAW, x, y, z, 0, TEMPSUMMON_DEAD_DESPAWN, 1000))
|
||||
if (Creature* summon = me->SummonCreature(NPC_RAGECLAW, x, y, z, 0, TEMPSUMMON_DEAD_DESPAWN, 1000))
|
||||
{
|
||||
_rageclawGUID = summon->GetGUID();
|
||||
LockRageclaw();
|
||||
LockRageclaw(summon);
|
||||
}
|
||||
}
|
||||
|
||||
void LockRageclaw()
|
||||
void LockRageclaw(Creature* rageclaw)
|
||||
{
|
||||
Unit* rageclaw = Unit::GetCreature(*me, _rageclawGUID);
|
||||
// pointer check not needed
|
||||
me->SetInFront(rageclaw);
|
||||
rageclaw->SetInFront(me);
|
||||
@@ -75,12 +74,11 @@ public:
|
||||
DoCast(rageclaw, SPELL_RIGHT_CHAIN, true);
|
||||
}
|
||||
|
||||
void UnlockRageclaw(Unit* who)
|
||||
void UnlockRageclaw(Unit* who, Creature* rageclaw)
|
||||
{
|
||||
if (!who)
|
||||
return;
|
||||
|
||||
Creature* rageclaw = Unit::GetCreature(*me, _rageclawGUID);
|
||||
// pointer check not needed
|
||||
DoCast(rageclaw, SPELL_FREE_RAGECLAW, true);
|
||||
|
||||
@@ -95,7 +93,7 @@ public:
|
||||
{
|
||||
if (Creature* rageclaw = Unit::GetCreature(*me, _rageclawGUID))
|
||||
{
|
||||
UnlockRageclaw(caster);
|
||||
UnlockRageclaw(caster, rageclaw);
|
||||
caster->ToPlayer()->KilledMonster(rageclaw->GetCreatureTemplate(), _rageclawGUID);
|
||||
me->DespawnOrUnsummon();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user