TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MovementPackets.cpp File Reference
#include "MovementPackets.h"
#include "MoveSpline.h"
#include "MoveSplineFlag.h"
#include "MovementTypedefs.h"
#include "PacketUtilities.h"
#include "Unit.h"
+ Include dependency graph for MovementPackets.cpp:

Functions

ByteBufferoperator<< (ByteBuffer &data, MovementInfo &movementInfo)
 
ByteBufferoperator>> (ByteBuffer &data, MovementInfo &movementInfo)
 
ByteBufferoperator>> (ByteBuffer &data, MovementInfo::TransportInfo &transportInfo)
 
ByteBufferoperator<< (ByteBuffer &data, MovementInfo::TransportInfo const &transportInfo)
 
ByteBufferoperator>> (ByteBuffer &data, WorldPackets::Movement::MovementAck &ack)
 

Function Documentation

ByteBuffer& operator<< ( ByteBuffer data,
MovementInfo movementInfo 
)
26 {
27  bool hasTransportData = !movementInfo.transport.guid.IsEmpty();
28  bool hasFallDirection = movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR);
29  bool hasFallData = hasFallDirection || movementInfo.jump.fallTime != 0;
30  bool hasSpline = false; // todo 6.x send this infos
31 
32  data << movementInfo.guid;
33  data << movementInfo.time;
34  data << movementInfo.pos.PositionXYZOStream();
35  data << movementInfo.pitch;
36  data << movementInfo.splineElevation;
37 
38  uint32 removeMovementForcesCount = 0;
39  data << removeMovementForcesCount;
40 
41  uint32 int168 = 0;
42  data << int168;
43 
44  /*for (uint32 i = 0; i < removeMovementForcesCount; ++i)
45  {
46  data << ObjectGuid;
47  }*/
48 
49  data.WriteBits(movementInfo.flags, 30);
50  data.WriteBits(movementInfo.flags2, 16);
51 
52  data.WriteBit(hasTransportData);
53  data.WriteBit(hasFallData);
54  data.WriteBit(hasSpline);
55 
56  data.WriteBit(0); // HeightChangeFailed
57  data.WriteBit(0); // RemoteTimeValid
58 
59  data.FlushBits();
60 
61  if (hasTransportData)
62  data << movementInfo.transport;
63 
64  if (hasFallData)
65  {
66  data << movementInfo.jump.fallTime;
67  data << movementInfo.jump.zspeed;
68 
69  data.WriteBit(hasFallDirection);
70  data.FlushBits();
71  if (hasFallDirection)
72  {
73  data << movementInfo.jump.sinAngle;
74  data << movementInfo.jump.cosAngle;
75  data << movementInfo.jump.xyspeed;
76  }
77  }
78 
79  return data;
80 }
bool HasMovementFlag(uint32 flag) const
Definition: Object.h:330
Position::PositionXYZOStreamer PositionXYZOStream()
Definition: Position.h:128
uint32 fallTime
Definition: Object.h:309
Definition: Unit.h:787
float cosAngle
Definition: Object.h:311
struct MovementInfo::JumpInfo jump
void FlushBits()
Definition: ByteBuffer.h:150
Position pos
Definition: Object.h:273
bool WriteBit(uint32 bit)
Definition: ByteBuffer.h:170
struct MovementInfo::TransportInfo transport
uint32 time
Definition: Object.h:274
float zspeed
Definition: Object.h:311
uint32 flags
Definition: Object.h:271
uint32_t uint32
Definition: Define.h:150
float pitch
Definition: Object.h:298
uint16 flags2
Definition: Object.h:272
float splineElevation
Definition: Object.h:316
float sinAngle
Definition: Object.h:311
ObjectGuid guid
Definition: Object.h:270
ObjectGuid guid
Definition: Object.h:289
bool IsEmpty() const
Definition: ObjectGuid.h:242
float xyspeed
Definition: Object.h:311
void WriteBits(T value, int32 bits)
Definition: ByteBuffer.h:198
Definition: Unit.h:788

+ Here is the call graph for this function:

ByteBuffer& operator<< ( ByteBuffer data,
MovementInfo::TransportInfo const transportInfo 
)
156 {
157  bool hasPrevTime = transportInfo.prevTime != 0;
158  bool hasVehicleId = transportInfo.vehicleId != 0;
159 
160  data << transportInfo.guid; // Transport Guid
161  data << transportInfo.pos.GetPositionX();
162  data << transportInfo.pos.GetPositionY();
163  data << transportInfo.pos.GetPositionZ();
164  data << transportInfo.pos.GetOrientation();
165  data << transportInfo.seat; // VehicleSeatIndex
166  data << transportInfo.time; // MoveTime
167 
168  data.WriteBit(hasPrevTime);
169  data.WriteBit(hasVehicleId);
170 
171  data.FlushBits();
172 
173  if (hasPrevTime)
174  data << transportInfo.prevTime; // PrevMoveTime
175 
176  if (hasVehicleId)
177  data << transportInfo.vehicleId; // VehicleRecID
178 
179  return data;
180 }
void FlushBits()
Definition: ByteBuffer.h:150
bool WriteBit(uint32 bit)
Definition: ByteBuffer.h:170

+ Here is the call graph for this function:

ByteBuffer& operator>> ( ByteBuffer data,
MovementInfo movementInfo 
)
83 {
84  //bool hasSpline = false;
85 
86  data >> movementInfo.guid;
87  data >> movementInfo.time;
88  data >> movementInfo.pos.PositionXYZOStream();
89  data >> movementInfo.pitch;
90  data >> movementInfo.splineElevation;
91 
92  uint32 removeMovementForcesCount;
93  data >> removeMovementForcesCount;
94 
95  uint32 int168;
96  data >> int168;
97 
98  for (uint32 i = 0; i < removeMovementForcesCount; ++i)
99  {
100  ObjectGuid guid;
101  data >> guid;
102  }
103 
104  movementInfo.flags = data.ReadBits(30);
105  movementInfo.flags2 = data.ReadBits(16);
106 
107  bool hasTransport = data.ReadBit();
108  bool hasFall = data.ReadBit();
109  /*hasSpline = */data.ReadBit(); // todo 6.x read this infos
110 
111  data.ReadBit(); // HeightChangeFailed
112  data.ReadBit(); // RemoteTimeValid
113 
114  if (hasTransport)
115  data >> movementInfo.transport;
116 
117  if (hasFall)
118  {
119  data >> movementInfo.jump.fallTime;
120  data >> movementInfo.jump.zspeed;
121 
122  // ResetBitReader
123 
124  bool hasFallDirection = data.ReadBit();
125  if (hasFallDirection)
126  {
127  data >> movementInfo.jump.sinAngle;
128  data >> movementInfo.jump.cosAngle;
129  data >> movementInfo.jump.xyspeed;
130  }
131  }
132 
133  return data;
134 }
Position::PositionXYZOStreamer PositionXYZOStream()
Definition: Position.h:128
uint32 fallTime
Definition: Object.h:309
uint32 ReadBits(int32 bits)
Definition: ByteBuffer.h:204
float cosAngle
Definition: Object.h:311
struct MovementInfo::JumpInfo jump
Position pos
Definition: Object.h:273
struct MovementInfo::TransportInfo transport
uint32 time
Definition: Object.h:274
float zspeed
Definition: Object.h:311
uint32 flags
Definition: Object.h:271
uint32_t uint32
Definition: Define.h:150
float pitch
Definition: Object.h:298
uint16 flags2
Definition: Object.h:272
float splineElevation
Definition: Object.h:316
float sinAngle
Definition: Object.h:311
ObjectGuid guid
Definition: Object.h:270
Definition: ObjectGuid.h:189
bool ReadBit()
Definition: ByteBuffer.h:186
float xyspeed
Definition: Object.h:311

+ Here is the call graph for this function:

ByteBuffer& operator>> ( ByteBuffer data,
MovementInfo::TransportInfo transportInfo 
)
137 {
138  data >> transportInfo.guid; // Transport Guid
139  data >> transportInfo.pos.PositionXYZOStream();
140  data >> transportInfo.seat; // VehicleSeatIndex
141  data >> transportInfo.time; // MoveTime
142 
143  bool hasPrevTime = data.ReadBit();
144  bool hasVehicleId = data.ReadBit();
145 
146  if (hasPrevTime)
147  data >> transportInfo.prevTime; // PrevMoveTime
148 
149  if (hasVehicleId)
150  data >> transportInfo.vehicleId; // VehicleRecID
151 
152  return data;
153 }
Position::PositionXYZOStreamer PositionXYZOStream()
Definition: Position.h:128
uint32 prevTime
Definition: Object.h:293
uint32 vehicleId
Definition: Object.h:294
int8 seat
Definition: Object.h:291
Position pos
Definition: Object.h:290
ObjectGuid guid
Definition: Object.h:289
uint32 time
Definition: Object.h:292
bool ReadBit()
Definition: ByteBuffer.h:186

+ Here is the call graph for this function:

ByteBuffer& operator>> ( ByteBuffer data,
WorldPackets::Movement::MovementAck ack 
)
604 {
605  data >> ack.movementInfo;
606  data >> ack.AckIndex;
607  return data;
608 }
int32 AckIndex
Definition: MovementPackets.h:293
MovementInfo movementInfo
Definition: MovementPackets.h:292