diff --git a/src/game/BattleGround/BattleGroundHandler.cpp b/src/game/BattleGround/BattleGroundHandler.cpp index 92a3e23d3..320c5fa25 100644 --- a/src/game/BattleGround/BattleGroundHandler.cpp +++ b/src/game/BattleGround/BattleGroundHandler.cpp @@ -51,8 +51,7 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recv_data) return; // Stop the npc if moving - if (!pCreature->IsStopped()) - pCreature->StopMoving(); + pCreature->StopMoving(); BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(pCreature->GetEntry()); diff --git a/src/game/ConfusedMovementGenerator.cpp b/src/game/ConfusedMovementGenerator.cpp index 93768f546..fb3703b13 100644 --- a/src/game/ConfusedMovementGenerator.cpp +++ b/src/game/ConfusedMovementGenerator.cpp @@ -42,6 +42,7 @@ void ConfusedMovementGenerator::Initialize(T& unit) template void ConfusedMovementGenerator::Interrupt(T& unit) { + unit.InterruptMoving(); // confused state still applied while movegen disabled unit.clearUnitState(UNIT_STAT_CONFUSED_MOVE); } diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp index 36ababace..cc5637c15 100644 --- a/src/game/FleeingMovementGenerator.cpp +++ b/src/game/FleeingMovementGenerator.cpp @@ -141,6 +141,7 @@ void FleeingMovementGenerator::Finalize(Creature& owner) template void FleeingMovementGenerator::Interrupt(T& owner) { + owner.InterruptMoving(); // flee state still applied while movegen disabled owner.clearUnitState(UNIT_STAT_FLEEING_MOVE); } diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index ff85f6a77..853bc5947 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -568,8 +568,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorguid) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); // Stop the npc if moving - if (!pCreature->IsStopped()) - pCreature->StopMoving(); + pCreature->StopMoving(); VendorItemData const* vItems = pCreature->GetVendorItems(); VendorItemData const* tItems = pCreature->GetVendorTemplateItems(); diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index ded459ee0..aad847924 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -44,8 +44,7 @@ inline bool isStatic(MovementGenerator* mv) void MotionMaster::Initialize() { // stop current move - if (!m_owner->IsStopped()) - m_owner->StopMoving(); + m_owner->StopMoving(); // clear ALL movement generators (including default) Clear(false, true); diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index 11aa03d02..965266559 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -346,8 +346,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket& recv_data) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - if (!pCreature->IsStopped()) - pCreature->StopMoving(); + pCreature->StopMoving(); if (pCreature->isSpiritGuide()) pCreature->SendAreaSpiritHealerQueryOpcode(_player); diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index b2156e713..2fa3b852f 100644 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -32,8 +32,7 @@ void PointMovementGenerator::Initialize(T& unit) if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE)) return; - if (!unit.IsStopped()) - unit.StopMoving(); + unit.StopMoving(); unit.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); Movement::MoveSplineInit init(unit); @@ -53,15 +52,14 @@ void PointMovementGenerator::Finalize(T& unit) template void PointMovementGenerator::Interrupt(T& unit) { + unit.InterruptMoving(); unit.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); } template void PointMovementGenerator::Reset(T& unit) { - if (!unit.IsStopped()) - unit.StopMoving(); - + unit.StopMoving(); unit.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); } @@ -152,8 +150,7 @@ void FlyOrLandMovementGenerator::Initialize(Unit& unit) if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE)) return; - if (!unit.IsStopped()) - unit.StopMoving(); + unit.StopMoving(); float x, y, z; GetDestination(x, y, z); diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp index 73a684c2a..468f84c52 100644 --- a/src/game/QuestHandler.cpp +++ b/src/game/QuestHandler.cpp @@ -99,8 +99,7 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket& recv_data) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); // Stop the npc if moving - if (!pCreature->IsStopped()) - pCreature->StopMoving(); + pCreature->StopMoving(); if (sScriptMgr.OnGossipHello(_player, pCreature)) return; diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp index ac07b766d..148634ab6 100644 --- a/src/game/RandomMovementGenerator.cpp +++ b/src/game/RandomMovementGenerator.cpp @@ -82,6 +82,7 @@ void RandomMovementGenerator::Reset(Creature& creature) template<> void RandomMovementGenerator::Interrupt(Creature& creature) { + creature.InterruptMoving(); creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE), false); } diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp index 39e4b83a7..b426abf0d 100644 --- a/src/game/TargetedMovementGenerator.cpp +++ b/src/game/TargetedMovementGenerator.cpp @@ -210,6 +210,7 @@ void ChaseMovementGenerator::Finalize(T& owner) template void ChaseMovementGenerator::Interrupt(T& owner) { + owner.InterruptMoving(); owner.clearUnitState(UNIT_STAT_CHASE | UNIT_STAT_CHASE_MOVE); } @@ -281,6 +282,7 @@ void FollowMovementGenerator::Finalize(T& owner) template void FollowMovementGenerator::Interrupt(T& owner) { + owner.InterruptMoving(); owner.clearUnitState(UNIT_STAT_FOLLOW | UNIT_STAT_FOLLOW_MOVE); _updateSpeed(owner); } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 08d96c93d..afb40742b 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -10868,6 +10868,21 @@ void Unit::StopMoving(bool forceSendStop /*=false*/) init.Launch(); } +void Unit::InterruptMoving(bool forceSendStop /*=false*/) +{ + bool isMoving = false; + + if (!movespline->Finalized()) + { + Movement::Location loc = movespline->ComputePosition(); + movespline->_Interrupt(); + Relocate(loc.x, loc.y, loc.z, loc.orientation); + isMoving = true; + } + + StopMoving(forceSendStop || isMoving); +} + void Unit::SetFeared(bool apply, ObjectGuid casterGuid, uint32 spellID, uint32 time) { if (apply) diff --git a/src/game/Unit.h b/src/game/Unit.h index ee22126d6..b55bb338b 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -2676,6 +2676,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool IsStopped() const { return !(hasUnitState(UNIT_STAT_MOVING)); } void StopMoving(bool forceSendStop = false); + void InterruptMoving(bool forceSendStop = false); void SetFeared(bool apply, ObjectGuid casterGuid = ObjectGuid(), uint32 spellID = 0, uint32 time = 0); void SetConfused(bool apply, ObjectGuid casterGuid = ObjectGuid(), uint32 spellID = 0); diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index 74981924d..1f9cc8b76 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -89,6 +89,7 @@ void WaypointMovementGenerator::Finalize(Creature& creature) void WaypointMovementGenerator::Interrupt(Creature& creature) { + creature.InterruptMoving(); creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE), false); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index f1d8d594b..19b03f363 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 "12674" + #define REVISION_NR "12675" #endif // __REVISION_NR_H__