TrinityCore
Loading...
Searching...
No Matches
MovementPacketSender.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
19#include "GameClient.h"
20#include "MovementPackets.h"
21#include "Unit.h"
22
23// SMSG_SPLINE_SET_* messages are for units controlled by the server.
24// SMSG_FORCE_*_SPEED_CHANGE messages are for units controlled by a player and require the client to respond with an ACK message.
25// MSG_MOVE_SET_*_SPEED is used to broadcast changes to observers of units controlled by a player
27{
37};
38
56
58{
59 GameClient* controller = unit->GetGameClientMovingMe();
60
61 ASSERT(controller);
62
63 uint32 mCounter = unit->GetMovementCounterAndInc();
64 PlayerMovementPendingChange pendingChange;
65 pendingChange.movementCounter = mCounter;
66 pendingChange.newValue = newSpeedFlat;
68 unit->PushPendingMovementChange(pendingChange);
69
71 packet.MoverGUID = unit->GetGUID();
72 packet.SequenceIndex = mCounter;
73 packet.Speed = newSpeedFlat;
74 controller->SendDirectMessage(packet.Write());
75}
76
78{
79 GameClient* controller = unit->GetGameClientMovingMe();
80
81 ASSERT(controller);
82
84 packet.Status = &unit->m_movementInfo;
85 packet.Speed = newSpeedFlat;
86 unit->SendMessageToSet(packet.Write(), controller->GetBasePlayer());
87}
88
89void MovementPacketSender::SendSpeedChangeToAll(Unit* unit, UnitMoveType mtype, float newSpeedFlat)
90{
91 GameClient* controller = unit->GetGameClientMovingMe();
92
93 ASSERT(!controller);
94
96 packet.MoverGUID = unit->GetGUID();
97 packet.Speed = newSpeedFlat;
98 unit->SendMessageToSet(packet.Write(), true);
99}
uint32_t uint32
Definition Define.h:133
#define ASSERT
Definition Errors.h:68
#define MAX_MOVE_TYPE
UnitMoveType
@ MOVE_FLIGHT
@ MOVE_SWIM
@ MOVE_TURN_RATE
@ MOVE_FLIGHT_BACK
@ MOVE_SWIM_BACK
@ MOVE_RUN
@ MOVE_PITCH_RATE
@ MOVE_RUN_BACK
@ MOVE_WALK
MovementChangeType
Definition Unit.h:289
void SendDirectMessage(WorldPacket const *data) const
Player * GetBasePlayer() const
Definition GameClient.h:40
static void SendSpeedChangeToMover(Unit *unit, UnitMoveType mtype, float newRate)
static MovementChangeType GetChangeTypeByMoveType(UnitMoveType moveType)
static void SendSpeedChangeToObservers(Unit *unit, UnitMoveType mtype, float newRate)
static void SendSpeedChangeToAll(Unit *unit, UnitMoveType mtype, float newRate)
static Opcodes const moveTypeToOpcode[MAX_MOVE_TYPE][3]
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
Definition Unit.h:783
void PushPendingMovementChange(PlayerMovementPendingChange newChange)
Definition Unit.cpp:12936
GameClient * GetGameClientMovingMe() const
Definition Unit.h:1315
uint32 GetMovementCounterAndInc()
Definition Unit.h:1788
virtual void SendMessageToSet(WorldPacket const *data, bool self) const
Definition Object.cpp:1784
MovementInfo m_movementInfo
Definition Object.h:577
uint32 SequenceIndex
Unit movement packet index, incremented each time.
WorldPacket const * Write() override
WorldPacket const * Write() override
Opcodes
Definition Opcodes.h:29
@ SMSG_FORCE_TURN_RATE_CHANGE
Definition Opcodes.h:763
@ MSG_MOVE_SET_SWIM_BACK_SPEED
Definition Opcodes.h:242
@ MSG_MOVE_SET_TURN_RATE
Definition Opcodes.h:245
@ SMSG_FORCE_WALK_SPEED_CHANGE
Definition Opcodes.h:759
@ SMSG_SPLINE_SET_FLIGHT_SPEED
Definition Opcodes.h:930
@ SMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE
Definition Opcodes.h:928
@ MSG_MOVE_SET_PITCH_RATE
Definition Opcodes.h:1144
@ SMSG_SPLINE_SET_SWIM_SPEED
Definition Opcodes.h:797
@ SMSG_FORCE_RUN_SPEED_CHANGE
Definition Opcodes.h:255
@ SMSG_FORCE_SWIM_BACK_SPEED_CHANGE
Definition Opcodes.h:761
@ SMSG_SPLINE_SET_FLIGHT_BACK_SPEED
Definition Opcodes.h:931
@ SMSG_FORCE_RUN_BACK_SPEED_CHANGE
Definition Opcodes.h:257
@ SMSG_FORCE_FLIGHT_SPEED_CHANGE
Definition Opcodes.h:926
@ SMSG_FORCE_SWIM_SPEED_CHANGE
Definition Opcodes.h:259
@ MSG_MOVE_SET_RUN_SPEED
Definition Opcodes.h:234
@ MSG_MOVE_SET_FLIGHT_SPEED
Definition Opcodes.h:923
@ MSG_MOVE_SET_WALK_SPEED
Definition Opcodes.h:238
@ SMSG_SPLINE_SET_WALK_SPEED
Definition Opcodes.h:798
@ SMSG_SPLINE_SET_RUN_BACK_SPEED
Definition Opcodes.h:796
@ MSG_MOVE_SET_SWIM_SPEED
Definition Opcodes.h:240
@ MSG_MOVE_SET_FLIGHT_BACK_SPEED
Definition Opcodes.h:925
@ SMSG_SPLINE_SET_RUN_SPEED
Definition Opcodes.h:795
@ SMSG_FORCE_PITCH_RATE_CHANGE
Definition Opcodes.h:1145
@ SMSG_SPLINE_SET_TURN_RATE
Definition Opcodes.h:800
@ SMSG_SPLINE_SET_PITCH_RATE
Definition Opcodes.h:1147
@ SMSG_SPLINE_SET_SWIM_BACK_SPEED
Definition Opcodes.h:799
@ MSG_MOVE_SET_RUN_BACK_SPEED
Definition Opcodes.h:236
MovementChangeType movementChangeType
Definition Unit.h:320