TrinityCore
Loading...
Searching...
No Matches
MovementPackets.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "MovementPackets.h"
19#include "UnitDefines.h"
20
21ByteBuffer& operator<<(ByteBuffer& data, MovementInfo const& movementInfo)
22{
23 data << uint32(movementInfo.flags);
24 data << uint16(movementInfo.flags2);
25 data << uint32(movementInfo.time);
26 data << movementInfo.pos.PositionXYZOStream();
27
29 {
30 data << movementInfo.transport.guid.WriteAsPacked();
31 data << movementInfo.transport.pos.PositionXYZOStream();
32 data << uint32(movementInfo.transport.time);
33 data << int8(movementInfo.transport.seat);
34
36 data << uint32(movementInfo.transport.time2);
37 }
38
40 data << float(movementInfo.pitch);
41
42 data << uint32(movementInfo.fallTime);
43
44 if (movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING))
45 {
46 data << float(movementInfo.jump.zspeed);
47 data << float(movementInfo.jump.sinAngle);
48 data << float(movementInfo.jump.cosAngle);
49 data << float(movementInfo.jump.xyspeed);
50 }
51
53 data << float(movementInfo.splineElevation);
54
55 return data;
56}
57
59{
60 data >> movementInfo.flags;
61 data >> movementInfo.flags2;
62 data >> movementInfo.time;
63 data >> movementInfo.pos.PositionXYZOStream();
64
66 {
67 data >> movementInfo.transport.guid.ReadAsPacked();
68 data >> movementInfo.transport.pos.PositionXYZOStream();
69 data >> movementInfo.transport.time;
70 data >> movementInfo.transport.seat;
71
73 data >> movementInfo.transport.time2;
74 }
75
77 data >> movementInfo.pitch;
78
79 data >> movementInfo.fallTime;
80
81 if (movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING))
82 {
83 data >> movementInfo.jump.zspeed;
84 data >> movementInfo.jump.sinAngle;
85 data >> movementInfo.jump.cosAngle;
86 data >> movementInfo.jump.xyspeed;
87 }
88
90 data >> movementInfo.splineElevation;
91
92 return data;
93}
94
int8_t int8
Definition Define.h:131
uint16_t uint16
Definition Define.h:134
uint32_t uint32
Definition Define.h:133
ByteBuffer & operator<<(ByteBuffer &data, MovementInfo const &movementInfo)
ByteBuffer & operator>>(ByteBuffer &data, MovementInfo &movementInfo)
@ MOVEMENTFLAG_ONTRANSPORT
@ MOVEMENTFLAG_FLYING
@ MOVEMENTFLAG_FALLING
@ MOVEMENTFLAG_SWIMMING
@ MOVEMENTFLAG_SPLINE_ELEVATION
@ MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING
@ MOVEMENTFLAG2_INTERPOLATED_MOVEMENT
PackedGuidWriter WriteAsPacked() const
Definition ObjectGuid.h:152
PackedGuidReader ReadAsPacked()
Definition ObjectGuid.h:146
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket _worldPacket
Definition Packet.h:42
ObjectGuid guid
struct MovementInfo::JumpInfo jump
uint32 fallTime
struct MovementInfo::TransportInfo transport
float splineElevation
bool HasMovementFlag(uint32 flag) const
bool HasExtraMovementFlag(uint16 flag) const
Position pos
Streamer< XYZO > PositionXYZOStream()
Definition Position.h:93