mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-17 19:05:42 +00:00
fix(Core): Fixed a few crashes/bugs that were found via static code analysis (#2617)
This commit is contained in:
@@ -603,11 +603,12 @@ public:
|
||||
static bool HandleNpcSetOriginalFaction(ChatHandler* handler, const char* /*args*/)
|
||||
{
|
||||
Player* me = handler->GetSession()->GetPlayer();
|
||||
Creature* creature = me->GetSelectedUnit()->ToCreature();
|
||||
|
||||
if (!me)
|
||||
return false;
|
||||
|
||||
Creature* creature = me->GetSelectedUnit()->ToCreature();
|
||||
|
||||
if (!creature)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -371,6 +371,12 @@ public:
|
||||
|
||||
if (show == "del")
|
||||
{
|
||||
if (!arg_id)
|
||||
{
|
||||
handler->SendSysMessage("|cffff33ffERROR: Waypoint script guid not present.|r");
|
||||
return true;
|
||||
}
|
||||
|
||||
id = atoi(arg_id);
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID);
|
||||
|
||||
@@ -201,13 +201,14 @@ public:
|
||||
events.RescheduleEvent(EVENT_RESPAWN_SPHERE, 4000);
|
||||
|
||||
for( std::list<uint64>::iterator itr = summons.begin(); itr != summons.end(); ++itr )
|
||||
if( Creature* c = pInstance->instance->GetCreature(*itr) )
|
||||
{
|
||||
c->GetMotionMaster()->MoveIdle();
|
||||
c->StopMoving();
|
||||
c->CastSpell(c, SPELL_SUBMERGE, false);
|
||||
c->AI()->DoAction(1);
|
||||
}
|
||||
if (pInstance)
|
||||
if(Creature* c = pInstance->instance->GetCreature(*itr) )
|
||||
{
|
||||
c->GetMotionMaster()->MoveIdle();
|
||||
c->StopMoving();
|
||||
c->CastSpell(c, SPELL_SUBMERGE, false);
|
||||
c->AI()->DoAction(1);
|
||||
}
|
||||
summons.clear();
|
||||
for( uint8 i=0; i<4; ++i )
|
||||
if( Creature* c = me->SummonCreature(NPC_BURROW, AnubLocs[i+1]) )
|
||||
|
||||
@@ -153,14 +153,12 @@ public:
|
||||
{
|
||||
float dist = j == 2 ? 0.0f : 8.0f; // second in middle
|
||||
float angle = SummonPositions[i].GetOrientation() + M_PI*2/4*j;
|
||||
NormalizeOrientation(angle);
|
||||
me->SummonCreature(NPC_UNSTOPPABLE_ABOMINATION, SummonPositions[i].GetPositionX()+dist*cos(angle), SummonPositions[i].GetPositionY()+dist*sin(angle), SummonPositions[i].GetPositionZ()+0.5f, SummonPositions[i].GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
|
||||
}
|
||||
for (uint8 i = 6; i < 12; ++i)
|
||||
for (uint8 j = 0; j < 1; ++j)
|
||||
{
|
||||
float angle = SummonPositions[i].GetOrientation() + M_PI;
|
||||
NormalizeOrientation(angle);
|
||||
me->SummonCreature(NPC_SOUL_WEAVER, SummonPositions[i].GetPositionX()+6*cos(angle), SummonPositions[i].GetPositionY()+6*sin(angle), SummonPositions[i].GetPositionZ()+0.5f, SummonPositions[i].GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -876,7 +876,8 @@ public:
|
||||
despawnTimer = 0;
|
||||
me->UpdatePosition(CenterPos.GetPositionX(), CenterPos.GetPositionY(), CenterPos.GetPositionZ()+18.0f, 0.0f, true);
|
||||
me->StopMovingOnCurrentPos();
|
||||
me->GetVehicleKit()->RemoveAllPassengers();
|
||||
if (Vehicle* vehicle = me->GetVehicleKit())
|
||||
vehicle->RemoveAllPassengers();
|
||||
me->DespawnOrUnsummon();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -778,9 +778,12 @@ class spell_oculus_rider_aura : public SpellScriptLoader
|
||||
void HandleOnEffectApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
|
||||
{
|
||||
Unit* caster = GetCaster();
|
||||
if (!caster)
|
||||
return;
|
||||
|
||||
Creature* drake = caster->GetVehicleCreatureBase();
|
||||
|
||||
if (!drake || !caster)
|
||||
if (!drake)
|
||||
return;
|
||||
|
||||
switch (aurEff->GetEffIndex())
|
||||
|
||||
@@ -395,11 +395,12 @@ public:
|
||||
}
|
||||
|
||||
// ensure LMK2 is at proper position
|
||||
if (Creature* LMK2 = GetLMK2())
|
||||
{
|
||||
LMK2->UpdatePosition(LMK2->GetHomePosition(), true);
|
||||
LMK2->StopMovingOnCurrentPos();
|
||||
}
|
||||
if (pInstance)
|
||||
if (Creature* LMK2 = GetLMK2())
|
||||
{
|
||||
LMK2->UpdatePosition(LMK2->GetHomePosition(), true);
|
||||
LMK2->StopMovingOnCurrentPos();
|
||||
}
|
||||
|
||||
if (pInstance && pInstance->GetData(TYPE_MIMIRON) != DONE)
|
||||
pInstance->SetData(TYPE_MIMIRON, IN_PROGRESS);
|
||||
|
||||
@@ -2312,8 +2312,14 @@ class spell_yogg_saron_brain_link : public SpellScriptLoader
|
||||
void OnPeriodic(AuraEffect const* /*aurEff*/)
|
||||
{
|
||||
Unit* owner = GetUnitOwner();
|
||||
if (!owner)
|
||||
{
|
||||
SetDuration(0);
|
||||
return;
|
||||
}
|
||||
|
||||
Unit* _target = ObjectAccessor::GetUnit(*owner, _targetGUID);
|
||||
if (!owner || !_target || !_target->IsAlive() || fabs(owner->GetPositionZ() - _target->GetPositionZ()) > 10.0f) // Target or owner underground
|
||||
if (!_target || !_target->IsAlive() || fabs(owner->GetPositionZ() - _target->GetPositionZ()) > 10.0f) // Target or owner underground
|
||||
{
|
||||
SetDuration(0);
|
||||
return;
|
||||
|
||||
@@ -749,7 +749,7 @@ public:
|
||||
{
|
||||
case EVENT_WORGEN_MORTAL:
|
||||
{
|
||||
me->CastSpell(me->GetVictim(), IsHeroic() ? SPELL_MORTAL_WOUND_H : SPELL_MORTAL_WOUND_H, false);
|
||||
me->CastSpell(me->GetVictim(), IsHeroic() ? SPELL_MORTAL_WOUND_H : SPELL_MORTAL_WOUND_N, false);
|
||||
events.RepeatEvent(4000 + rand()%3000);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
|
||||
void SetData(uint32 data, uint32 param)
|
||||
{
|
||||
if (data != 1 || param != 1 || Started || instance->GetData(DATA_SVALA_SORROWGRAVE) == DONE)
|
||||
if (data != 1 || param != 1 || Started || (instance && instance->GetData(DATA_SVALA_SORROWGRAVE) == DONE))
|
||||
return;
|
||||
|
||||
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_IMMUNE_TO_NPC);
|
||||
|
||||
@@ -220,16 +220,20 @@ public:
|
||||
|
||||
void JustSummoned(Creature *pSummoned)
|
||||
{
|
||||
listOfMobs.Summon(pSummoned);
|
||||
if (pSummoned)
|
||||
{
|
||||
listOfMobs.Summon(pSummoned);
|
||||
pInstance->SetData64(DATA_ADD_TRASH_MOB, pSummoned->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
void SummonedMobDied(Creature *pSummoned)
|
||||
{
|
||||
listOfMobs.Despawn(pSummoned);
|
||||
if (pSummoned)
|
||||
{
|
||||
listOfMobs.Despawn(pSummoned);
|
||||
pInstance->SetData64(DATA_DELETE_TRASH_MOB, pSummoned->GetGUID());
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -551,11 +551,14 @@ class boss_essence_of_anger : public CreatureScript
|
||||
events.ScheduleEvent(EVENT_ANGER_SOUL_SCREAM, 10000);
|
||||
break;
|
||||
case EVENT_ANGER_SEETHE:
|
||||
if (targetGUID && targetGUID != me->GetVictim()->GetGUID())
|
||||
me->CastSpell(me, SPELL_SEETHE, false);
|
||||
// victim can be lost
|
||||
if (me->GetVictim())
|
||||
targetGUID = me->GetVictim()->GetGUID();
|
||||
if (Unit* victim = me->GetVictim())
|
||||
{
|
||||
uint64 victimGUID = victim->GetGUID();
|
||||
if (targetGUID && targetGUID != victimGUID)
|
||||
me->CastSpell(me, SPELL_SEETHE, false);
|
||||
// victim can be lost
|
||||
targetGUID = victimGUID;
|
||||
}
|
||||
events.ScheduleEvent(EVENT_ANGER_SEETHE, 1000);
|
||||
break;
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ class spell_sha_feral_spirit_scaling : public SpellScriptLoader
|
||||
|
||||
void Register()
|
||||
{
|
||||
if (m_scriptSpellId == 35675 || m_scriptSpellId == 35675)
|
||||
if (m_scriptSpellId == 35675)
|
||||
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_sha_feral_spirit_scaling_AuraScript::CalculateResistanceAmount, EFFECT_ALL, SPELL_AURA_MOD_RESISTANCE);
|
||||
|
||||
if (m_scriptSpellId == 35674)
|
||||
|
||||
Reference in New Issue
Block a user