From 3c6d5e985f636b48ecac08e12b00cd4b17bec370 Mon Sep 17 00:00:00 2001 From: zerg Date: Tue, 19 Oct 2010 00:38:43 +0400 Subject: [PATCH] [10620] Fixed MSG_MOVE_HEARTBEAT structure. Thx Wojta for pointing. Signed-off-by: VladimirMangos --- src/game/HomeMovementGenerator.cpp | 8 +++----- src/game/Unit.cpp | 33 ++++++++---------------------- src/game/Unit.h | 2 +- src/shared/revision_nr.h | 2 +- 4 files changed, 14 insertions(+), 31 deletions(-) diff --git a/src/game/HomeMovementGenerator.cpp b/src/game/HomeMovementGenerator.cpp index 0406fbdc4..ae7d3cd6d 100644 --- a/src/game/HomeMovementGenerator.cpp +++ b/src/game/HomeMovementGenerator.cpp @@ -70,14 +70,12 @@ HomeMovementGenerator::Update(Creature &owner, const uint32& time_diff owner.AddSplineFlag(SPLINEFLAG_WALKMODE); // restore orientation of not moving creature at returning to home - if(owner.GetDefaultMovementType()==IDLE_MOTION_TYPE) + if (owner.GetDefaultMovementType() == IDLE_MOTION_TYPE) { - if(CreatureData const* data = sObjectMgr.GetCreatureData(owner.GetDBTableGUIDLow())) + if (CreatureData const* data = sObjectMgr.GetCreatureData(owner.GetDBTableGUIDLow())) { owner.SetOrientation(data->orientation); - WorldPacket packet; - owner.BuildHeartBeatMsg(&packet); - owner.SendMessageToSet(&packet, false); + owner.SendHeartBeat(false); } } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index bd2b77bcc..7c1379e6b 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -432,22 +432,12 @@ void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTim SendMonsterMove(x, y, z, SPLINETYPE_NORMAL, flags, transitTime, player); } -void Unit::BuildHeartBeatMsg(WorldPacket *data) const +void Unit::SendHeartBeat(bool toSelf) { - MovementFlags move_flags = GetTypeId()==TYPEID_PLAYER - ? ((Player const*)this)->m_movementInfo.GetMovementFlags() - : MOVEFLAG_NONE; - - data->Initialize(MSG_MOVE_HEARTBEAT, 32); - *data << GetPackGUID(); - *data << uint32(move_flags); // movement flags - *data << uint16(0); // 2.3.0 - *data << uint32(getMSTime()); // time - *data << float(GetPositionX()); - *data << float(GetPositionY()); - *data << float(GetPositionZ()); - *data << float(GetOrientation()); - *data << uint32(0); + WorldPacket data(MSG_MOVE_HEARTBEAT, 64); + data << GetPackGUID(); + data << m_movementInfo; + SendMessageToSet(&data, toSelf); } void Unit::resetAttackTimer(WeaponAttackType type) @@ -3694,9 +3684,7 @@ void Unit::SetFacingTo(float ori, bool bToSelf /*= false*/) SetOrientation(ori); // and client - WorldPacket data; - BuildHeartBeatMsg(&data); - SendMessageToSet(&data, bToSelf); + SendHeartBeat(bToSelf); } // Consider move this to Creature:: since only creature appear to be able to use this @@ -9822,9 +9810,7 @@ void Unit::StopMoving() SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), SPLINETYPE_STOP, GetTypeId() == TYPEID_PLAYER ? SPLINEFLAG_WALKMODE : SPLINEFLAG_NONE, 0); // update position and orientation for near players - WorldPacket data; - BuildHeartBeatMsg(&data); - SendMessageToSet(&data, false); + SendHeartBeat(false); } void Unit::SetFeared(bool apply, uint64 const& casterGUID, uint32 spellID, uint32 time) @@ -10398,9 +10384,8 @@ void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool ca GetMap()->CreatureRelocation((Creature*)this, x, y, z, orientation); - WorldPacket data; - BuildHeartBeatMsg(&data); - SendMessageToSet(&data, false); + SendHeartBeat(false); + // finished relocation, movegen can different from top before creature relocation, // but apply Reset expected to be safe in any case if (!c->GetMotionMaster()->empty()) diff --git a/src/game/Unit.h b/src/game/Unit.h index def113fbe..a79654458 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1464,7 +1464,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void SendThreatRemove(HostileReference* pHostileReference); void SendThreatUpdate(); - void BuildHeartBeatMsg( WorldPacket *data ) const; + void SendHeartBeat(bool toSelf); virtual void MoveOutOfRange(Player &) { }; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7f641875d..29817d8b9 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 "10619" + #define REVISION_NR "10620" #endif // __REVISION_NR_H__