diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index 2aa7ec772..8f2ba5adc 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -37,22 +37,21 @@ inline bool isStatic(MovementGenerator *mv) return (mv == &si_idleMovement); } -void -MotionMaster::Initialize() +void MotionMaster::Initialize() { // stop current move - if (!i_owner->IsStopped()) - i_owner->StopMoving(); + if (!m_owner->IsStopped()) + m_owner->StopMoving(); // clear ALL movement generators (including default) Clear(false,true); // set new default movement generator - if (i_owner->GetTypeId() == TYPEID_UNIT && !i_owner->hasUnitState(UNIT_STAT_CONTROLLED)) + if (m_owner->GetTypeId() == TYPEID_UNIT && !m_owner->hasUnitState(UNIT_STAT_CONTROLLED)) { - MovementGenerator* movement = FactorySelector::selectMovementGenerator((Creature*)i_owner); + MovementGenerator* movement = FactorySelector::selectMovementGenerator((Creature*)m_owner); push(movement == NULL ? &si_idleMovement : movement); - top()->Initialize(*i_owner); + top()->Initialize(*m_owner); } else push(&si_idleMovement); @@ -64,14 +63,15 @@ MotionMaster::~MotionMaster() DirectClean(false,true); } -void -MotionMaster::UpdateMotion(uint32 diff) +void MotionMaster::UpdateMotion(uint32 diff) { - if( i_owner->hasUnitState(UNIT_STAT_CAN_NOT_MOVE) ) + if (m_owner->hasUnitState(UNIT_STAT_CAN_NOT_MOVE)) return; + MANGOS_ASSERT( !empty() ); m_cleanFlag |= MMCF_UPDATE; - if (!top()->Update(*i_owner, diff)) + + if (!top()->Update(*m_owner, diff)) { m_cleanFlag &= ~MMCF_UPDATE; MovementExpired(); @@ -96,35 +96,34 @@ MotionMaster::UpdateMotion(uint32 diff) if (m_cleanFlag & MMCF_RESET) { - top()->Reset(*i_owner); + top()->Reset(*m_owner); m_cleanFlag &= ~MMCF_RESET; } } } -void -MotionMaster::DirectClean(bool reset, bool all) +void MotionMaster::DirectClean(bool reset, bool all) { while( all ? !empty() : size() > 1 ) { MovementGenerator *curr = top(); pop(); - curr->Finalize(*i_owner); - if (!isStatic( curr )) + curr->Finalize(*m_owner); + + if (!isStatic(curr)) delete curr; } if (!all && reset) { MANGOS_ASSERT( !empty() ); - top()->Reset(*i_owner); + top()->Reset(*m_owner); } } -void -MotionMaster::DelayedClean(bool reset, bool all) +void MotionMaster::DelayedClean(bool reset, bool all) { - if(reset) + if (reset) m_cleanFlag |= MMCF_RESET; else m_cleanFlag &= ~MMCF_RESET; @@ -139,14 +138,14 @@ MotionMaster::DelayedClean(bool reset, bool all) { MovementGenerator *curr = top(); pop(); - curr->Finalize(*i_owner); - if (!isStatic( curr )) + curr->Finalize(*m_owner); + + if (!isStatic(curr)) m_expList->push_back(curr); } } -void -MotionMaster::DirectExpire(bool reset) +void MotionMaster::DirectExpire(bool reset) { if (empty() || size() == 1) return; @@ -159,12 +158,12 @@ MotionMaster::DirectExpire(bool reset) { MovementGenerator *temp = top(); pop(); - temp ->Finalize(*i_owner); + temp->Finalize(*m_owner); delete temp; } // it can add another motions instead - curr->Finalize(*i_owner); + curr->Finalize(*m_owner); if (!isStatic(curr)) delete curr; @@ -173,11 +172,10 @@ MotionMaster::DirectExpire(bool reset) Initialize(); if (reset) - top()->Reset(*i_owner); + top()->Reset(*m_owner); } -void -MotionMaster::DelayedExpire(bool reset) +void MotionMaster::DelayedExpire(bool reset) { if (reset) m_cleanFlag |= MMCF_RESET; @@ -198,11 +196,11 @@ MotionMaster::DelayedExpire(bool reset) { MovementGenerator *temp = top(); pop(); - temp ->Finalize(*i_owner); + temp ->Finalize(*m_owner); m_expList->push_back(temp ); } - curr->Finalize(*i_owner); + curr->Finalize(*m_owner); if (!isStatic(curr)) m_expList->push_back(curr); @@ -216,142 +214,134 @@ void MotionMaster::MoveIdle() void MotionMaster::MoveRandom() { - if (i_owner->GetTypeId() == TYPEID_PLAYER) + if (m_owner->GetTypeId() == TYPEID_PLAYER) { - sLog.outError("%s attempt to move random.", i_owner->GetObjectGuid().GetString().c_str()); + sLog.outError("%s attempt to move random.", m_owner->GetObjectGuid().GetString().c_str()); } else { - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s move random.", i_owner->GetObjectGuid().GetString().c_str()); - Mutate(new RandomMovementGenerator(*i_owner)); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s move random.", m_owner->GetObjectGuid().GetString().c_str()); + Mutate(new RandomMovementGenerator(*m_owner)); } } -void -MotionMaster::MoveTargetedHome() +void MotionMaster::MoveTargetedHome() { - if(i_owner->hasUnitState(UNIT_STAT_LOST_CONTROL)) + if (m_owner->hasUnitState(UNIT_STAT_LOST_CONTROL)) return; Clear(false); - if(i_owner->GetTypeId()==TYPEID_UNIT && !((Creature*)i_owner)->GetCharmerOrOwnerGUID()) + if (m_owner->GetTypeId() == TYPEID_UNIT && !((Creature*)m_owner)->GetCharmerOrOwnerGUID()) { - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted home", i_owner->GetObjectGuid().GetString().c_str()); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted home", m_owner->GetObjectGuid().GetString().c_str()); Mutate(new HomeMovementGenerator()); } - else if(i_owner->GetTypeId()==TYPEID_UNIT && ((Creature*)i_owner)->GetCharmerOrOwnerGUID()) + else if (m_owner->GetTypeId() == TYPEID_UNIT && ((Creature*)m_owner)->GetCharmerOrOwnerGUID()) { - if (Unit *target = ((Creature*)i_owner)->GetCharmerOrOwner()) + if (Unit *target = ((Creature*)m_owner)->GetCharmerOrOwner()) { - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s follow to %s", i_owner->GetObjectGuid().GetString().c_str(), target->GetObjectGuid().GetString().c_str()); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s follow to %s", m_owner->GetObjectGuid().GetString().c_str(), target->GetObjectGuid().GetString().c_str()); Mutate(new FollowMovementGenerator(*target,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE)); } else { - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s attempt but fail to follow owner", i_owner->GetObjectGuid().GetString().c_str()); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s attempt but fail to follow owner", m_owner->GetObjectGuid().GetString().c_str()); } } else - sLog.outError("%s attempt targeted home", i_owner->GetObjectGuid().GetString().c_str()); + sLog.outError("%s attempt targeted home", m_owner->GetObjectGuid().GetString().c_str()); } -void -MotionMaster::MoveConfused() +void MotionMaster::MoveConfused() { - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s move confused", i_owner->GetObjectGuid().GetString().c_str()); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s move confused", m_owner->GetObjectGuid().GetString().c_str()); - if(i_owner->GetTypeId()==TYPEID_PLAYER) + if (m_owner->GetTypeId() == TYPEID_PLAYER) Mutate(new ConfusedMovementGenerator()); else Mutate(new ConfusedMovementGenerator()); } -void -MotionMaster::MoveChase(Unit* target, float dist, float angle) +void MotionMaster::MoveChase(Unit* target, float dist, float angle) { // ignore movement request if target not exist - if(!target) + if (!target) return; - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s chase to %s", i_owner->GetObjectGuid().GetString().c_str(), target->GetObjectGuid().GetString().c_str()); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s chase to %s", m_owner->GetObjectGuid().GetString().c_str(), target->GetObjectGuid().GetString().c_str()); - if(i_owner->GetTypeId()==TYPEID_PLAYER) + if (m_owner->GetTypeId() == TYPEID_PLAYER) Mutate(new ChaseMovementGenerator(*target,dist,angle)); else Mutate(new ChaseMovementGenerator(*target,dist,angle)); } -void -MotionMaster::MoveFollow(Unit* target, float dist, float angle) +void MotionMaster::MoveFollow(Unit* target, float dist, float angle) { - if(i_owner->hasUnitState(UNIT_STAT_LOST_CONTROL)) + if (m_owner->hasUnitState(UNIT_STAT_LOST_CONTROL)) return; Clear(); // ignore movement request if target not exist - if(!target) + if (!target) return; - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s follow to %s", i_owner->GetObjectGuid().GetString().c_str(), target->GetObjectGuid().GetString().c_str()); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s follow to %s", m_owner->GetObjectGuid().GetString().c_str(), target->GetObjectGuid().GetString().c_str()); - if(i_owner->GetTypeId()==TYPEID_PLAYER) + if (m_owner->GetTypeId() == TYPEID_PLAYER) Mutate(new FollowMovementGenerator(*target,dist,angle)); else Mutate(new FollowMovementGenerator(*target,dist,angle)); } -void -MotionMaster::MovePoint(uint32 id, float x, float y, float z) +void MotionMaster::MovePoint(uint32 id, float x, float y, float z) { - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point (Id: %u X: %f Y: %f Z: %f)", i_owner->GetObjectGuid().GetString().c_str(), id, x, y, z ); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point (Id: %u X: %f Y: %f Z: %f)", m_owner->GetObjectGuid().GetString().c_str(), id, x, y, z ); - if(i_owner->GetTypeId()==TYPEID_PLAYER) + if (m_owner->GetTypeId() == TYPEID_PLAYER) Mutate(new PointMovementGenerator(id,x,y,z)); else Mutate(new PointMovementGenerator(id,x,y,z)); } -void -MotionMaster::MoveSeekAssistance(float x, float y, float z) +void MotionMaster::MoveSeekAssistance(float x, float y, float z) { - if(i_owner->GetTypeId()==TYPEID_PLAYER) + if (m_owner->GetTypeId() == TYPEID_PLAYER) { - sLog.outError("%s attempt to seek assistance",i_owner->GetObjectGuid().GetString().c_str()); + sLog.outError("%s attempt to seek assistance", m_owner->GetObjectGuid().GetString().c_str()); } else { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s seek assistance (X: %f Y: %f Z: %f)", - i_owner->GetObjectGuid().GetString().c_str(), x, y, z ); + m_owner->GetObjectGuid().GetString().c_str(), x, y, z ); Mutate(new AssistanceMovementGenerator(x,y,z)); } } -void -MotionMaster::MoveSeekAssistanceDistract(uint32 time) +void MotionMaster::MoveSeekAssistanceDistract(uint32 time) { - if(i_owner->GetTypeId()==TYPEID_PLAYER) + if (m_owner->GetTypeId() == TYPEID_PLAYER) { - sLog.outError("%s attempt to call distract after assistance",i_owner->GetObjectGuid().GetString().c_str()); + sLog.outError("%s attempt to call distract after assistance", m_owner->GetObjectGuid().GetString().c_str()); } else { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s is distracted after assistance call (Time: %u)", - i_owner->GetObjectGuid().GetString().c_str(), time ); + m_owner->GetObjectGuid().GetString().c_str(), time ); Mutate(new AssistanceDistractMovementGenerator(time)); } } -void -MotionMaster::MoveFleeing(Unit* enemy, uint32 time) +void MotionMaster::MoveFleeing(Unit* enemy, uint32 time) { - if(!enemy) + if (!enemy) return; - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s flee from %s", i_owner->GetObjectGuid().GetString().c_str(), enemy->GetObjectGuid().GetString().c_str()); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s flee from %s", m_owner->GetObjectGuid().GetString().c_str(), enemy->GetObjectGuid().GetString().c_str()); - if(i_owner->GetTypeId()==TYPEID_PLAYER) + if (m_owner->GetTypeId() == TYPEID_PLAYER) Mutate(new FleeingMovementGenerator(enemy->GetGUID())); else { @@ -362,34 +352,32 @@ MotionMaster::MoveFleeing(Unit* enemy, uint32 time) } } -void -MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode) +void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode) { - if(i_owner->GetTypeId()==TYPEID_PLAYER) + if (m_owner->GetTypeId() == TYPEID_PLAYER) { - if(path < sTaxiPathNodesByPath.size()) + if (path < sTaxiPathNodesByPath.size()) { - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s taxi to (Path %u node %u)", i_owner->GetObjectGuid().GetString().c_str(), path, pathnode); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s taxi to (Path %u node %u)", m_owner->GetObjectGuid().GetString().c_str(), path, pathnode); FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(sTaxiPathNodesByPath[path],pathnode); Mutate(mgen); } else { sLog.outError("%s attempt taxi to (nonexistent Path %u node %u)", - i_owner->GetObjectGuid().GetString().c_str(), path, pathnode ); + m_owner->GetObjectGuid().GetString().c_str(), path, pathnode); } } else { sLog.outError("%s attempt taxi to (Path %u node %u)", - i_owner->GetObjectGuid().GetString().c_str(), path, pathnode ); + m_owner->GetObjectGuid().GetString().c_str(), path, pathnode); } } -void -MotionMaster::MoveDistract(uint32 timer) +void MotionMaster::MoveDistract(uint32 timer) { - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s distracted (timer: %u)", i_owner->GetObjectGuid().GetString().c_str(), timer); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s distracted (timer: %u)", m_owner->GetObjectGuid().GetString().c_str(), timer); DistractMovementGenerator* mgen = new DistractMovementGenerator(timer); Mutate(mgen); } @@ -410,9 +398,10 @@ void MotionMaster::Mutate(MovementGenerator *m) } if (!empty()) - top()->Interrupt(*i_owner); + top()->Interrupt(*m_owner); } - m->Initialize(*i_owner); + + m->Initialize(*m_owner); push(m); } @@ -427,18 +416,18 @@ void MotionMaster::propagateSpeedChange() MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType() const { - if(empty()) + if (empty()) return IDLE_MOTION_TYPE; - return top()->GetMovementGeneratorType(); + return top()->GetMovementGeneratorType(); } bool MotionMaster::GetDestination(float &x, float &y, float &z) { - if(empty()) + if (empty()) return false; - return top()->GetDestination(x,y,z); + return top()->GetDestination(x,y,z); } void MotionMaster::UpdateFinalDistanceToTarget(float fDistance) diff --git a/src/game/MotionMaster.h b/src/game/MotionMaster.h index 139387a71..d67f27cc2 100644 --- a/src/game/MotionMaster.h +++ b/src/game/MotionMaster.h @@ -53,8 +53,8 @@ enum MovementGeneratorType enum MMCleanFlag { MMCF_NONE = 0, - MMCF_UPDATE = 1, // Clear or Expire called from update - MMCF_RESET = 2 // Flag if need top()->Reset() + MMCF_UPDATE = 1, // Clear or Expire called from update + MMCF_RESET = 2 // Flag if need top()->Reset() }; class MANGOS_DLL_SPEC MotionMaster : private std::stack @@ -64,7 +64,7 @@ class MANGOS_DLL_SPEC MotionMaster : private std::stack typedef std::vector ExpireList; public: - explicit MotionMaster(Unit *unit) : i_owner(unit), m_expList(NULL), m_cleanFlag(MMCF_NONE) {} + explicit MotionMaster(Unit *unit) : m_owner(unit), m_expList(NULL), m_cleanFlag(MMCF_NONE) {} ~MotionMaster(); void Initialize(); @@ -124,7 +124,7 @@ class MANGOS_DLL_SPEC MotionMaster : private std::stack void DirectExpire(bool reset); void DelayedExpire(bool reset); - Unit *i_owner; + Unit *m_owner; ExpireList *m_expList; uint8 m_cleanFlag; }; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 917846fab..406838807 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10480" + #define REVISION_NR "10481" #endif // __REVISION_NR_H__