Core/Misc: Fixed coverity issues

Uninitialized fields: CID 1354593, 1354595, 1354738
Unchecked return value: CID 1354558
Out of bounds access: CID 1352989, 1352993
Null pointer dereference: CID 1296286
This commit is contained in:
Shauren
2016-06-06 09:16:59 +02:00
parent d59bba3c5d
commit 8396dabdad
9 changed files with 39 additions and 38 deletions

View File

@@ -200,7 +200,7 @@ public:
if (zombie)
{
zombieToBeEatenGUID = zombie->GetGUID(); // save for later use
// the soon-to-be-eaten zombie should stop moving and stop attacking
zombie->AI()->SetData(DATA_ZOMBIE_STATE, STATE_ZOMBIE_TOBE_EATEN);
@@ -225,7 +225,7 @@ public:
case EVENT_KILL_ZOMBIE_SINGLE:
{
Creature* zombieToBeEaten = ObjectAccessor::GetCreature(*me, zombieToBeEatenGUID);
if (zombieToBeEaten && zombieToBeEaten->IsAlive() && zombieToBeEaten->IsWithinDistInMap(me, 10.0))
if (zombieToBeEaten && zombieToBeEaten->IsAlive() && zombieToBeEaten->IsWithinDistInMap(me, 10.0))
DoCast(zombieToBeEaten, SPELL_ZOMBIE_CHOW_SEARCH_SINGLE); // do the killing + healing in done inside by spell script see below.
zombieToBeEatenGUID = ObjectGuid::Empty;
@@ -249,11 +249,11 @@ public:
if (zombie && zombie->IsAlive() && zombie->GetExactDist2d(me) > 18.0)
zombie = nullptr;
}
if (zombie) // cast the aoe spell only if at least one zombie is found nearby
{
Talk(EMOTE_DEVOURS_ALL);
DoCastAOE(SPELL_ZOMBIE_CHOW_SEARCH_MULTI);
DoCastAOE(SPELL_ZOMBIE_CHOW_SEARCH_MULTI);
}
break;
}
@@ -269,7 +269,7 @@ public:
me->GetMotionMaster()->MoveIdle();
events.ScheduleEvent(EVENT_KILL_ZOMBIE_SINGLE, Seconds(1));
}
}
void DoAction(int32 action) override
@@ -405,17 +405,19 @@ public:
if (state == STATE_ZOMBIE_DECIMATED)
{
timer += diff;
Creature* gluth = ObjectAccessor::GetCreature(*me, GluthGUID);
// Putting this in the UpdateAI loop fixes an issue where death gripping a decimated zombie would make the zombie stand still until the rest of the fight.
// Also fix the issue where if one or more zombie is rooted when decimates hits (and MovePoint() is called), the zombie teleport to the boss. pretty weird behavior.
if (gluth && timer>1600 && me->GetExactDist2d(gluth) > 10.0 && me->CanFreeMove()) // it takes about 1600 ms for the animation to cycle. This way, the animation looks relatively smooth.
if (Creature* gluth = ObjectAccessor::GetCreature(*me, GluthGUID))
{
me->GetMotionMaster()->MovePoint(0, gluth->GetPosition()); // isn't dynamic. So, to take into account Gluth's movement, it must be called periodicly.
timer = 0;
}
if (timer > 1600 && me->GetExactDist2d(gluth) > 10.0 && me->CanFreeMove()) // it takes about 1600 ms for the animation to cycle. This way, the animation looks relatively smooth.
{
me->GetMotionMaster()->MovePoint(0, gluth->GetPosition()); // isn't dynamic. So, to take into account Gluth's movement, it must be called periodicly.
timer = 0;
}
if (me->GetExactDist2d(gluth) <= 10.0)
me->StopMoving();
if (me->GetExactDist2d(gluth) <= 10.0)
me->StopMoving();
}
}
else if (state == STATE_ZOMBIE_NORMAL)
DoMeleeAttackIfReady();
@@ -430,10 +432,10 @@ public:
{
me->SetReactState(ReactStates::REACT_PASSIVE);
me->AttackStop();
me->SetTarget(ObjectGuid::Empty);
me->SetTarget(ObjectGuid::Empty);
// at this point, the zombie should be non attacking and non moving.
me->SetWalk(true); // it doesnt seem to work with MoveFollow() (but it does work with MovePoint()).
me->SetWalk(true); // it doesnt seem to work with MoveFollow() (but it does work with MovePoint()).
timer = 1000;
}