Core/Movement: Fixed possible invalid memory access

This commit is contained in:
Shauren
2013-12-12 09:50:52 +01:00
parent 385e2dba37
commit 54fd53f7e3
5 changed files with 14 additions and 12 deletions
@@ -726,16 +726,16 @@ bool Creature::AIM_Initialize(CreatureAI* ai)
void Creature::Motion_Initialize()
{
if (!m_formation)
i_motionMaster.Initialize();
GetMotionMaster()->Initialize();
else if (m_formation->getLeader() == this)
{
m_formation->FormationReset(false);
i_motionMaster.Initialize();
GetMotionMaster()->Initialize();
}
else if (m_formation->isFormed())
i_motionMaster.MoveIdle(); //wait the order of leader
GetMotionMaster()->MoveIdle(); //wait the order of leader
else
i_motionMaster.Initialize();
GetMotionMaster()->Initialize();
}
bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, uint32 team, float x, float y, float z, float ang, const CreatureData* data)
@@ -1461,7 +1461,7 @@ void Creature::setDeathState(DeathState s)
m_formation->FormationReset(true);
if ((CanFly() || IsFlying()))
i_motionMaster.MoveFall();
GetMotionMaster()->MoveFall();
Unit::setDeathState(CORPSE);
}
+1 -1
View File
@@ -5197,7 +5197,7 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
void Player::KillPlayer()
{
if (IsFlying() && !GetTransport())
i_motionMaster.MoveFall();
GetMotionMaster()->MoveFall();
SetMovement(MOVE_ROOT);
+3 -2
View File
@@ -165,7 +165,7 @@ Unit::Unit(bool isWorldObject) :
IsAIEnabled(false), NeedChangeAI(false), LastCharmerGUID(0),
m_ControlledByPlayer(false), movespline(new Movement::MoveSpline()),
i_AI(NULL), i_disabledAI(NULL), m_AutoRepeatFirstCast(false), m_procDeep(0),
m_removedAurasCount(0), i_motionMaster(this), m_ThreatManager(this),
m_removedAurasCount(0), i_motionMaster(new MotionMaster(this)), m_ThreatManager(this),
m_vehicle(NULL), m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE),
m_HostileRefManager(this), _lastDamagedTime(0)
{
@@ -293,6 +293,7 @@ Unit::~Unit()
_DeleteRemovedAuras();
delete i_motionMaster;
delete m_charmInfo;
delete movespline;
@@ -362,7 +363,7 @@ void Unit::Update(uint32 p_time)
}
UpdateSplineMovement(p_time);
i_motionMaster.UpdateMotion(p_time);
i_motionMaster->UpdateMotion(p_time);
}
bool Unit::haveOffhandWeapon() const
+3 -3
View File
@@ -2005,8 +2005,8 @@ class Unit : public WorldObject
static Player* GetPlayer(WorldObject& object, uint64 guid);
static Creature* GetCreature(WorldObject& object, uint64 guid);
MotionMaster* GetMotionMaster() { return &i_motionMaster; }
const MotionMaster* GetMotionMaster() const { return &i_motionMaster; }
MotionMaster* GetMotionMaster() { return i_motionMaster; }
const MotionMaster* GetMotionMaster() const { return i_motionMaster; }
bool IsStopped() const { return !(HasUnitState(UNIT_STATE_MOVING)); }
void StopMoving();
@@ -2187,7 +2187,7 @@ class Unit : public WorldObject
virtual SpellSchoolMask GetMeleeDamageSchoolMask() const;
MotionMaster i_motionMaster;
MotionMaster* i_motionMaster;
uint32 m_reactiveTimer[MAX_REACTIVE];
uint32 m_regenTimer;
+2 -1
View File
@@ -72,7 +72,8 @@ MotionMaster::~MotionMaster()
{
MovementGenerator *curr = top();
pop();
if (curr) DirectDelete(curr);
if (curr && !isStatic(curr))
delete curr; // Skip finalizing on delete, it might launch new movement
}
}