[12675] Fix MoveGen's interrupting after last commit

Signed-off-by: Schmoozerd <schmoozerd@cmangos>

(based on commit [12473] - baa6525)
This commit is contained in:
rsa 2013-08-19 16:31:30 +03:00 committed by Antz
parent 394be2c5bf
commit 60a7bec73f
14 changed files with 32 additions and 18 deletions

View file

@ -51,8 +51,7 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recv_data)
return; return;
// Stop the npc if moving // Stop the npc if moving
if (!pCreature->IsStopped()) pCreature->StopMoving();
pCreature->StopMoving();
BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(pCreature->GetEntry()); BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(pCreature->GetEntry());

View file

@ -42,6 +42,7 @@ void ConfusedMovementGenerator<T>::Initialize(T& unit)
template<class T> template<class T>
void ConfusedMovementGenerator<T>::Interrupt(T& unit) void ConfusedMovementGenerator<T>::Interrupt(T& unit)
{ {
unit.InterruptMoving();
// confused state still applied while movegen disabled // confused state still applied while movegen disabled
unit.clearUnitState(UNIT_STAT_CONFUSED_MOVE); unit.clearUnitState(UNIT_STAT_CONFUSED_MOVE);
} }

View file

@ -141,6 +141,7 @@ void FleeingMovementGenerator<Creature>::Finalize(Creature& owner)
template<class T> template<class T>
void FleeingMovementGenerator<T>::Interrupt(T& owner) void FleeingMovementGenerator<T>::Interrupt(T& owner)
{ {
owner.InterruptMoving();
// flee state still applied while movegen disabled // flee state still applied while movegen disabled
owner.clearUnitState(UNIT_STAT_FLEEING_MOVE); owner.clearUnitState(UNIT_STAT_FLEEING_MOVE);
} }

View file

@ -568,8 +568,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorguid)
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
// Stop the npc if moving // Stop the npc if moving
if (!pCreature->IsStopped()) pCreature->StopMoving();
pCreature->StopMoving();
VendorItemData const* vItems = pCreature->GetVendorItems(); VendorItemData const* vItems = pCreature->GetVendorItems();
VendorItemData const* tItems = pCreature->GetVendorTemplateItems(); VendorItemData const* tItems = pCreature->GetVendorTemplateItems();

View file

@ -44,8 +44,7 @@ inline bool isStatic(MovementGenerator* mv)
void MotionMaster::Initialize() void MotionMaster::Initialize()
{ {
// stop current move // stop current move
if (!m_owner->IsStopped()) m_owner->StopMoving();
m_owner->StopMoving();
// clear ALL movement generators (including default) // clear ALL movement generators (including default)
Clear(false, true); Clear(false, true);

View file

@ -346,8 +346,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket& recv_data)
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
if (!pCreature->IsStopped()) pCreature->StopMoving();
pCreature->StopMoving();
if (pCreature->isSpiritGuide()) if (pCreature->isSpiritGuide())
pCreature->SendAreaSpiritHealerQueryOpcode(_player); pCreature->SendAreaSpiritHealerQueryOpcode(_player);

View file

@ -32,8 +32,7 @@ void PointMovementGenerator<T>::Initialize(T& unit)
if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE)) if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE))
return; return;
if (!unit.IsStopped()) unit.StopMoving();
unit.StopMoving();
unit.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); unit.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
Movement::MoveSplineInit init(unit); Movement::MoveSplineInit init(unit);
@ -53,15 +52,14 @@ void PointMovementGenerator<T>::Finalize(T& unit)
template<class T> template<class T>
void PointMovementGenerator<T>::Interrupt(T& unit) void PointMovementGenerator<T>::Interrupt(T& unit)
{ {
unit.InterruptMoving();
unit.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); unit.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
} }
template<class T> template<class T>
void PointMovementGenerator<T>::Reset(T& unit) void PointMovementGenerator<T>::Reset(T& unit)
{ {
if (!unit.IsStopped()) unit.StopMoving();
unit.StopMoving();
unit.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); 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)) if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE))
return; return;
if (!unit.IsStopped()) unit.StopMoving();
unit.StopMoving();
float x, y, z; float x, y, z;
GetDestination(x, y, z); GetDestination(x, y, z);

View file

@ -99,8 +99,7 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket& recv_data)
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
// Stop the npc if moving // Stop the npc if moving
if (!pCreature->IsStopped()) pCreature->StopMoving();
pCreature->StopMoving();
if (sScriptMgr.OnGossipHello(_player, pCreature)) if (sScriptMgr.OnGossipHello(_player, pCreature))
return; return;

View file

@ -82,6 +82,7 @@ void RandomMovementGenerator<Creature>::Reset(Creature& creature)
template<> template<>
void RandomMovementGenerator<Creature>::Interrupt(Creature& creature) void RandomMovementGenerator<Creature>::Interrupt(Creature& creature)
{ {
creature.InterruptMoving();
creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE), false); creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE), false);
} }

View file

@ -210,6 +210,7 @@ void ChaseMovementGenerator<T>::Finalize(T& owner)
template<class T> template<class T>
void ChaseMovementGenerator<T>::Interrupt(T& owner) void ChaseMovementGenerator<T>::Interrupt(T& owner)
{ {
owner.InterruptMoving();
owner.clearUnitState(UNIT_STAT_CHASE | UNIT_STAT_CHASE_MOVE); owner.clearUnitState(UNIT_STAT_CHASE | UNIT_STAT_CHASE_MOVE);
} }
@ -281,6 +282,7 @@ void FollowMovementGenerator<T>::Finalize(T& owner)
template<class T> template<class T>
void FollowMovementGenerator<T>::Interrupt(T& owner) void FollowMovementGenerator<T>::Interrupt(T& owner)
{ {
owner.InterruptMoving();
owner.clearUnitState(UNIT_STAT_FOLLOW | UNIT_STAT_FOLLOW_MOVE); owner.clearUnitState(UNIT_STAT_FOLLOW | UNIT_STAT_FOLLOW_MOVE);
_updateSpeed(owner); _updateSpeed(owner);
} }

View file

@ -10868,6 +10868,21 @@ void Unit::StopMoving(bool forceSendStop /*=false*/)
init.Launch(); 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) void Unit::SetFeared(bool apply, ObjectGuid casterGuid, uint32 spellID, uint32 time)
{ {
if (apply) if (apply)

View file

@ -2676,6 +2676,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
bool IsStopped() const { return !(hasUnitState(UNIT_STAT_MOVING)); } bool IsStopped() const { return !(hasUnitState(UNIT_STAT_MOVING)); }
void StopMoving(bool forceSendStop = false); void StopMoving(bool forceSendStop = false);
void InterruptMoving(bool forceSendStop = false);
void SetFeared(bool apply, ObjectGuid casterGuid = ObjectGuid(), uint32 spellID = 0, uint32 time = 0); void SetFeared(bool apply, ObjectGuid casterGuid = ObjectGuid(), uint32 spellID = 0, uint32 time = 0);
void SetConfused(bool apply, ObjectGuid casterGuid = ObjectGuid(), uint32 spellID = 0); void SetConfused(bool apply, ObjectGuid casterGuid = ObjectGuid(), uint32 spellID = 0);

View file

@ -89,6 +89,7 @@ void WaypointMovementGenerator<Creature>::Finalize(Creature& creature)
void WaypointMovementGenerator<Creature>::Interrupt(Creature& creature) void WaypointMovementGenerator<Creature>::Interrupt(Creature& creature)
{ {
creature.InterruptMoving();
creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);
creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE), false); creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE), false);
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "12674" #define REVISION_NR "12675"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__