From 1e2ee2d680489ebac307d8356e84de70193f5143 Mon Sep 17 00:00:00 2001 From: e Date: Tue, 4 Sep 2012 13:00:08 -0400 Subject: [Unit::SetCharm] Restore original walking state when removing charm. Fixes mind control + walk bug. --- src/server/game/Entities/Unit/Unit.cpp | 13 ++++++++++--- src/server/game/Entities/Unit/Unit.h | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 33f8828997d..9aca7b8c023 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -9978,7 +9978,8 @@ void Unit::SetCharm(Unit* charm, bool apply) if (!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) sLog->outFatal(LOG_FILTER_UNITS, "Unit %u is being charmed, but it already has a charmer " UI64FMTD "", charm->GetEntry(), charm->GetCharmerGUID()); - if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALKING)) + m_isWalkingBeforeCharm = charm->IsWalking(); + if (m_isWalkingBeforeCharm) { charm->SetWalk(false); charm->SendMovementFlagUpdate(); @@ -10015,6 +10016,12 @@ void Unit::SetCharm(Unit* charm, bool apply) charm->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, 0); } + + if (charm->IsWalking() != m_isWalkingBeforeCharm) + { + charm->SetWalk(m_isWalkingBeforeCharm); + charm->SendMovementFlagUpdate(true); // send packet to self, to update movement state on player. + } if (charm->GetTypeId() == TYPEID_PLAYER || !charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_MINION) @@ -14763,11 +14770,11 @@ void Unit::StopMoving() init.Launch(); } -void Unit::SendMovementFlagUpdate() +void Unit::SendMovementFlagUpdate(bool self /* = false */) { WorldPacket data; BuildHeartBeatMsg(&data); - SendMessageToSet(&data, false); + SendMessageToSet(&data, self); } bool Unit::IsSitState() const diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 2ec3ffec8ef..ff4832e043e 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1606,7 +1606,7 @@ class Unit : public WorldObject void MonsterMoveWithSpeed(float x, float y, float z, float speed); //void SetFacing(float ori, WorldObject* obj = NULL); //void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL); - void SendMovementFlagUpdate(); + void SendMovementFlagUpdate(bool self = false); /*! These methods send the same packet to the client in apply and unapply case. The client-side interpretation of this packet depends on the presence of relevant movementflags @@ -2356,6 +2356,7 @@ class Unit : public WorldObject Spell const* _focusSpell; bool _targetLocked; // locks the target during spell cast for proper facing + bool m_isWalkingBeforeCharm; // Are we walking before we were charmed? }; namespace Trinity -- cgit v1.2.3 From 1695f78c9f05d0516b6ac79c2404a98a9d94192a Mon Sep 17 00:00:00 2001 From: e Date: Tue, 4 Sep 2012 13:04:30 -0400 Subject: Fix codestyle per Vincent-Michael --- src/server/game/Entities/Unit/Unit.cpp | 8 ++++---- src/server/game/Entities/Unit/Unit.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 9aca7b8c023..1657fb8c679 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -9978,8 +9978,8 @@ void Unit::SetCharm(Unit* charm, bool apply) if (!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) sLog->outFatal(LOG_FILTER_UNITS, "Unit %u is being charmed, but it already has a charmer " UI64FMTD "", charm->GetEntry(), charm->GetCharmerGUID()); - m_isWalkingBeforeCharm = charm->IsWalking(); - if (m_isWalkingBeforeCharm) + _isWalkingBeforeCharm = charm->IsWalking(); + if (_isWalkingBeforeCharm) { charm->SetWalk(false); charm->SendMovementFlagUpdate(); @@ -10017,9 +10017,9 @@ void Unit::SetCharm(Unit* charm, bool apply) charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, 0); } - if (charm->IsWalking() != m_isWalkingBeforeCharm) + if (charm->IsWalking() != _isWalkingBeforeCharm) { - charm->SetWalk(m_isWalkingBeforeCharm); + charm->SetWalk(_isWalkingBeforeCharm); charm->SendMovementFlagUpdate(true); // send packet to self, to update movement state on player. } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index ff4832e043e..013b5244e2a 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -2356,7 +2356,7 @@ class Unit : public WorldObject Spell const* _focusSpell; bool _targetLocked; // locks the target during spell cast for proper facing - bool m_isWalkingBeforeCharm; // Are we walking before we were charmed? + bool _isWalkingBeforeCharm; // Are we walking before we were charmed? }; namespace Trinity -- cgit v1.2.3