AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Movement::PacketBuilder Class Reference

#include "MovementPacketBuilder.h"

Static Public Member Functions

static void WriteMonsterMove (const MoveSpline &mov, ByteBuffer &data)
 
static void WriteStopMovement (Vector3 const &loc, uint32 splineId, ByteBuffer &data)
 
static void WriteCreate (const MoveSpline &mov, ByteBuffer &data)
 

Static Private Member Functions

static void WriteCommonMonsterMovePart (const MoveSpline &mov, ByteBuffer &data)
 

Detailed Description

Member Function Documentation

◆ WriteCommonMonsterMovePart()

void Movement::PacketBuilder::WriteCommonMonsterMovePart ( const MoveSpline mov,
ByteBuffer data 
)
staticprivate
44 {
45 MoveSplineFlag splineflags = move_spline.splineflags;
46
47 data << uint8(0); // sets/unsets MOVEMENTFLAG2_UNK7 (0x40)
48 data << move_spline.spline.getPoint(move_spline.spline.first());
49 data << move_spline.GetId();
50
51 switch (splineflags & MoveSplineFlag::Mask_Final_Facing)
52 {
55 data << move_spline.facing.target;
56 break;
59 data << move_spline.facing.angle;
60 break;
63 data << move_spline.facing.f.x << move_spline.facing.f.y << move_spline.facing.f.z;
64 break;
65 default:
66 data << uint8(MonsterMoveNormal);
67 break;
68 }
69
70 // add fake Enter_Cycle flag - needed for client-side cyclic movement (client will erase first spline vertex after first cycle done)
71 // Xinef: this flag breaks cycle for ground movement, client teleports npc between last and first point instead of using smooth movement
72 if (splineflags & MoveSplineFlag::Flying)
73 splineflags.enter_cycle = move_spline.isCyclic();
74 data << uint32(splineflags & uint32(~MoveSplineFlag::Mask_No_Monster_Move));
75
76 if (splineflags.animation)
77 {
78 data << splineflags.getAnimationId();
79 data << move_spline.effect_start_time;
80 }
81
82 data << move_spline.Duration();
83
84 if (splineflags.parabolic)
85 {
86 data << move_spline.vertical_acceleration;
87 data << move_spline.effect_start_time;
88 }
89 }
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
@ MonsterMoveFacingSpot
Definition: MovementPacketBuilder.cpp:38
@ MonsterMoveFacingTarget
Definition: MovementPacketBuilder.cpp:39
@ MonsterMoveNormal
Definition: MovementPacketBuilder.cpp:36
@ MonsterMoveFacingAngle
Definition: MovementPacketBuilder.cpp:40
@ Final_Angle
Definition: MoveSplineFlag.h:48
@ Flying
Definition: MoveSplineFlag.h:44
@ Final_Point
Definition: MoveSplineFlag.h:46
@ Mask_No_Monster_Move
Definition: MoveSplineFlag.h:69
@ Final_Target
Definition: MoveSplineFlag.h:47
@ Mask_Final_Facing
Definition: MoveSplineFlag.h:65

References Movement::FacingInfo::angle, Movement::MoveSplineFlag::animation, Movement::MoveSpline::Duration(), Movement::MoveSpline::effect_start_time, Movement::MoveSplineFlag::enter_cycle, Movement::FacingInfo::f, Movement::MoveSpline::facing, Movement::MoveSplineFlag::Final_Angle, Movement::MoveSplineFlag::Final_Point, Movement::MoveSplineFlag::Final_Target, Movement::SplineBase::first(), Movement::MoveSplineFlag::Flying, Movement::MoveSplineFlag::getAnimationId(), Movement::MoveSpline::GetId(), Movement::SplineBase::getPoint(), Movement::MoveSpline::isCyclic(), Movement::MoveSplineFlag::Mask_Final_Facing, Movement::MoveSplineFlag::Mask_No_Monster_Move, Movement::MonsterMoveFacingAngle, Movement::MonsterMoveFacingSpot, Movement::MonsterMoveFacingTarget, Movement::MonsterMoveNormal, Movement::MoveSplineFlag::parabolic, Movement::MoveSpline::spline, Movement::MoveSpline::splineflags, Movement::FacingInfo::target, Movement::MoveSpline::vertical_acceleration, Movement::FacingInfo::x, Movement::FacingInfo::y, and Movement::FacingInfo::z.

Referenced by WriteMonsterMove().

◆ WriteCreate()

void Movement::PacketBuilder::WriteCreate ( const MoveSpline mov,
ByteBuffer data 
)
static
160 {
161 //WriteClientStatus(mov, data);
162 //data.append<float>(&mov.m_float_values[SpeedWalk], SpeedMaxCount);
163 //if (mov.SplineEnabled())
164 {
165 MoveSplineFlag const& splineFlags = move_spline.splineflags;
166
167 data << splineFlags.raw();
168
169 if (splineFlags.final_angle)
170 {
171 data << move_spline.facing.angle;
172 }
173 else if (splineFlags.final_target)
174 {
175 data << move_spline.facing.target;
176 }
177 else if (splineFlags.final_point)
178 {
179 data << move_spline.facing.f.x << move_spline.facing.f.y << move_spline.facing.f.z;
180 }
181
182 data << move_spline.timePassed();
183 data << move_spline.Duration();
184 data << move_spline.GetId();
185
186 data << float(1.f); // splineInfo.duration_mod; added in 3.1
187 data << float(1.f); // splineInfo.duration_mod_next; added in 3.1
188
189 data << move_spline.vertical_acceleration; // added in 3.1
190 data << move_spline.effect_start_time; // added in 3.1
191
192 uint32 nodes = move_spline.getPath().size();
193 data << nodes;
194 if (nodes)
195 {
196 data.append<Vector3>(&move_spline.getPath()[0], nodes);
197 }
198 data << uint8(move_spline.spline.mode()); // added in 3.1
199 data << (move_spline.isCyclic() ? Vector3::zero() : move_spline.FinalDestination());
200 }
201 }
std::size_t size() const
Definition: ByteBuffer.h:444
void append(T value)
Definition: ByteBuffer.h:129

References Movement::FacingInfo::angle, ByteBuffer::append(), Movement::MoveSpline::Duration(), Movement::MoveSpline::effect_start_time, Movement::FacingInfo::f, Movement::MoveSpline::facing, Movement::MoveSplineFlag::final_angle, Movement::MoveSplineFlag::final_point, Movement::MoveSplineFlag::final_target, Movement::MoveSpline::FinalDestination(), Movement::MoveSpline::GetId(), Movement::MoveSpline::getPath(), Movement::MoveSpline::isCyclic(), Movement::SplineBase::mode(), Movement::MoveSplineFlag::raw(), Movement::MoveSpline::spline, Movement::MoveSpline::splineflags, Movement::FacingInfo::target, Movement::MoveSpline::timePassed(), Movement::MoveSpline::vertical_acceleration, Movement::FacingInfo::x, Movement::FacingInfo::y, and Movement::FacingInfo::z.

Referenced by Object::BuildMovementUpdate().

◆ WriteMonsterMove()

void Movement::PacketBuilder::WriteMonsterMove ( const MoveSpline mov,
ByteBuffer data 
)
static
143 {
144 WriteCommonMonsterMovePart(move_spline, data);
145
146 const Spline<int32>& spline = move_spline.spline;
147 MoveSplineFlag splineflags = move_spline.splineflags;
148 if (splineflags & MoveSplineFlag::Mask_CatmullRom)
149 {
150 if (splineflags.cyclic)
151 WriteCatmullRomCyclicPath(spline, data, splineflags & MoveSplineFlag::Flying);
152 else
153 WriteCatmullRomPath(spline, data);
154 }
155 else
156 WriteLinearPath(spline, data);
157 }
void WriteCatmullRomPath(const Spline< int32 > &spline, ByteBuffer &data)
Definition: MovementPacketBuilder.cpp:119
void WriteLinearPath(const Spline< int32 > &spline, ByteBuffer &data)
Definition: MovementPacketBuilder.cpp:99
void WriteCatmullRomCyclicPath(const Spline< int32 > &spline, ByteBuffer &data, bool flying)
Definition: MovementPacketBuilder.cpp:126
static void WriteCommonMonsterMovePart(const MoveSpline &mov, ByteBuffer &data)
Definition: MovementPacketBuilder.cpp:43
@ Mask_CatmullRom
Definition: MoveSplineFlag.h:71

References Movement::MoveSplineFlag::cyclic, Movement::MoveSplineFlag::Flying, Movement::MoveSplineFlag::Mask_CatmullRom, Movement::MoveSpline::spline, Movement::MoveSpline::splineflags, Movement::WriteCatmullRomCyclicPath(), Movement::WriteCatmullRomPath(), WriteCommonMonsterMovePart(), and Movement::WriteLinearPath().

Referenced by Movement::MoveSplineInit::Launch().

◆ WriteStopMovement()

void Movement::PacketBuilder::WriteStopMovement ( Vector3 const &  loc,
uint32  splineId,
ByteBuffer data 
)
static
92 {
93 data << uint8(0); // sets/unsets MOVEMENTFLAG2_UNK7 (0x40)
94 data << pos;
95 data << splineId;
96 data << uint8(MonsterMoveStop);
97 }
@ MonsterMoveStop
Definition: MovementPacketBuilder.cpp:37

References Movement::MonsterMoveStop.

Referenced by Movement::MoveSplineInit::Stop().