Core/Movement

* Implemented a generic way of sending movement packets depending on who controls the unit (player or server controlled)
* Added possibility to specify extra elements in movement packets (such as speed, extra passenger guid, collision height and similar) without having to add a special element only for these
* Removed Unit::SendMovementFlagUpdate as it was something working only in 3.3.5a and earlier (no serverside HEARTBEAT opcode exists now)
This commit is contained in:
Shauren committed 2013-04-09 17:24:39 +02:00
1 parent c34fd8d862
commit 12a828fdbc
30 files changed
+5242 -3153

No files matched your search

+79 -489
View File
@@ -8606,7 +8606,7 @@ void Unit::SetCharm(Unit* charm, bool apply)
if (_isWalkingBeforeCharm)
{
charm->SetWalk(false);
charm->SendMovementFlagUpdate();
charm->SendMovementWalkMode();
}
m_Controlled.insert(charm);
@@ -8644,7 +8644,7 @@ void Unit::SetCharm(Unit* charm, bool apply)
if (charm->IsWalking() != _isWalkingBeforeCharm)
{
charm->SetWalk(_isWalkingBeforeCharm);
charm->SendMovementFlagUpdate(true); // send packet to self, to update movement state on player.
charm->SendMovementWalkMode();
}
if (charm->GetTypeId() == TYPEID_PLAYER
@@ -11168,418 +11168,35 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
propagateSpeedChange();
WorldPacket data;
ObjectGuid guid = GetGUID();
if (!forced)
static Opcodes const moveTypeToOpcode[MAX_MOVE_TYPE][3] =
{
switch (mtype)
{
case MOVE_WALK:
data.Initialize(SMSG_SPLINE_MOVE_SET_WALK_SPEED, 8+4+2+4+4+4+4+4+4+4);
data.WriteBit(guid[0]);
data.WriteBit(guid[6]);
data.WriteBit(guid[7]);
data.WriteBit(guid[3]);
data.WriteBit(guid[5]);
data.WriteBit(guid[1]);
data.WriteBit(guid[2]);
data.WriteBit(guid[4]);
data.FlushBits();
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[3]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[5]);
break;
case MOVE_RUN:
data.Initialize(SMSG_SPLINE_MOVE_SET_RUN_SPEED, 1 + 8 + 4);
data.WriteBit(guid[4]);
data.WriteBit(guid[0]);
data.WriteBit(guid[5]);
data.WriteBit(guid[7]);
data.WriteBit(guid[6]);
data.WriteBit(guid[3]);
data.WriteBit(guid[1]);
data.WriteBit(guid[2]);
data.FlushBits();
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[4]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[1]);
break;
case MOVE_RUN_BACK:
data.Initialize(SMSG_SPLINE_MOVE_SET_RUN_BACK_SPEED, 1 + 8 + 4);
data.WriteBit(guid[1]);
data.WriteBit(guid[2]);
data.WriteBit(guid[6]);
data.WriteBit(guid[0]);
data.WriteBit(guid[3]);
data.WriteBit(guid[7]);
data.WriteBit(guid[5]);
data.WriteBit(guid[4]);
data.FlushBits();
data.WriteByteSeq(guid[1]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[7]);
break;
case MOVE_SWIM:
data.Initialize(SMSG_SPLINE_MOVE_SET_SWIM_SPEED, 1 + 8 + 4);
data.WriteBit(guid[4]);
data.WriteBit(guid[2]);
data.WriteBit(guid[5]);
data.WriteBit(guid[0]);
data.WriteBit(guid[7]);
data.WriteBit(guid[6]);
data.WriteBit(guid[3]);
data.WriteBit(guid[1]);
data.FlushBits();
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[4]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[3]);
break;
case MOVE_SWIM_BACK:
data.Initialize(SMSG_SPLINE_MOVE_SET_SWIM_BACK_SPEED, 1 + 8 + 4);
data.WriteBit(guid[0]);
data.WriteBit(guid[1]);
data.WriteBit(guid[3]);
data.WriteBit(guid[6]);
data.WriteBit(guid[4]);
data.WriteBit(guid[5]);
data.WriteBit(guid[7]);
data.WriteBit(guid[2]);
data.FlushBits();
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[6]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[2]);
break;
case MOVE_TURN_RATE:
data.Initialize(SMSG_SPLINE_MOVE_SET_TURN_RATE, 1 + 8 + 4);
data.WriteBit(guid[2]);
data.WriteBit(guid[4]);
data.WriteBit(guid[6]);
data.WriteBit(guid[1]);
data.WriteBit(guid[3]);
data.WriteBit(guid[5]);
data.WriteBit(guid[7]);
data.WriteBit(guid[0]);
data.FlushBits();
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[0]);
break;
case MOVE_FLIGHT:
data.Initialize(SMSG_SPLINE_MOVE_SET_FLIGHT_SPEED, 1 + 8 + 4);
data.WriteBit(guid[7]);
data.WriteBit(guid[4]);
data.WriteBit(guid[0]);
data.WriteBit(guid[1]);
data.WriteBit(guid[3]);
data.WriteBit(guid[6]);
data.WriteBit(guid[5]);
data.WriteBit(guid[2]);
data.FlushBits();
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[6]);
data << float(GetSpeed(mtype));
break;
case MOVE_FLIGHT_BACK:
data.Initialize(SMSG_SPLINE_MOVE_SET_FLIGHT_BACK_SPEED, 1 + 8 + 4);
data.WriteBit(guid[2]);
data.WriteBit(guid[1]);
data.WriteBit(guid[6]);
data.WriteBit(guid[5]);
data.WriteBit(guid[0]);
data.WriteBit(guid[3]);
data.WriteBit(guid[4]);
data.WriteBit(guid[7]);
data.FlushBits();
data.WriteByteSeq(guid[5]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[4]);
break;
case MOVE_PITCH_RATE:
data.Initialize(SMSG_SPLINE_MOVE_SET_PITCH_RATE, 1 + 8 + 4);
data.WriteBit(guid[3]);
data.WriteBit(guid[5]);
data.WriteBit(guid[6]);
data.WriteBit(guid[1]);
data.WriteBit(guid[0]);
data.WriteBit(guid[4]);
data.WriteBit(guid[7]);
data.WriteBit(guid[2]);
data.FlushBits();
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[2]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[4]);
break;
default:
sLog->outError(LOG_FILTER_UNITS, "Unit::SetSpeed: Unsupported move type (%d), data not sent to client.", mtype);
return;
}
{SMSG_SPLINE_MOVE_SET_WALK_SPEED, SMSG_MOVE_SET_WALK_SPEED, SMSG_MOVE_UPDATE_WALK_SPEED },
{SMSG_SPLINE_MOVE_SET_RUN_SPEED, SMSG_MOVE_SET_RUN_SPEED, SMSG_MOVE_UPDATE_RUN_SPEED },
{SMSG_SPLINE_MOVE_SET_RUN_BACK_SPEED, SMSG_MOVE_SET_RUN_BACK_SPEED, SMSG_MOVE_UPDATE_RUN_BACK_SPEED },
{SMSG_SPLINE_MOVE_SET_SWIM_SPEED, SMSG_MOVE_SET_SWIM_SPEED, SMSG_MOVE_UPDATE_SWIM_SPEED },
{SMSG_SPLINE_MOVE_SET_SWIM_BACK_SPEED, SMSG_MOVE_SET_SWIM_BACK_SPEED, SMSG_MOVE_UPDATE_SWIM_BACK_SPEED },
{SMSG_SPLINE_MOVE_SET_TURN_RATE, SMSG_MOVE_SET_TURN_RATE, SMSG_MOVE_UPDATE_TURN_RATE },
{SMSG_SPLINE_MOVE_SET_FLIGHT_SPEED, SMSG_MOVE_SET_FLIGHT_SPEED, SMSG_MOVE_UPDATE_FLIGHT_SPEED },
{SMSG_SPLINE_MOVE_SET_FLIGHT_BACK_SPEED, SMSG_MOVE_SET_FLIGHT_BACK_SPEED, SMSG_MOVE_UPDATE_FLIGHT_BACK_SPEED},
{SMSG_SPLINE_MOVE_SET_PITCH_RATE, SMSG_MOVE_SET_PITCH_RATE, SMSG_MOVE_UPDATE_PITCH_RATE },
};
SendMessageToSet(&data, true);
}
else
if (GetTypeId() == TYPEID_PLAYER)
{
if (GetTypeId() == TYPEID_PLAYER)
{
// register forced speed changes for WorldSession::HandleForceSpeedChangeAck
// and do it only for real sent packets and use run for run/mounted as client expected
++ToPlayer()->m_forced_speed_changes[mtype];
// register forced speed changes for WorldSession::HandleForceSpeedChangeAck
// and do it only for real sent packets and use run for run/mounted as client expected
++ToPlayer()->m_forced_speed_changes[mtype];
if (!isInCombat())
if (Pet* pet = ToPlayer()->GetPet())
pet->SetSpeed(mtype, m_speed_rate[mtype], forced);
}
switch (mtype)
{
case MOVE_WALK:
data.Initialize(SMSG_MOVE_SET_WALK_SPEED, 1 + 8 + 4 + 4);
data.WriteBit(guid[0]);
data.WriteBit(guid[4]);
data.WriteBit(guid[5]);
data.WriteBit(guid[2]);
data.WriteBit(guid[3]);
data.WriteBit(guid[1]);
data.WriteBit(guid[6]);
data.WriteBit(guid[7]);
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[5]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[2]);
data << uint32(m_movementCounter++);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[3]);
break;
case MOVE_RUN:
data.Initialize(SMSG_MOVE_SET_RUN_SPEED, 1 + 8 + 4 + 4);
data.WriteBit(guid[6]);
data.WriteBit(guid[1]);
data.WriteBit(guid[5]);
data.WriteBit(guid[2]);
data.WriteBit(guid[7]);
data.WriteBit(guid[0]);
data.WriteBit(guid[3]);
data.WriteBit(guid[4]);
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[4]);
data << uint32(m_movementCounter++);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[2]);
break;
case MOVE_RUN_BACK:
data.Initialize(SMSG_MOVE_SET_RUN_BACK_SPEED, 1 + 8 + 4 + 4);
data.WriteBit(guid[0]);
data.WriteBit(guid[6]);
data.WriteBit(guid[2]);
data.WriteBit(guid[1]);
data.WriteBit(guid[3]);
data.WriteBit(guid[4]);
data.WriteBit(guid[5]);
data.WriteBit(guid[7]);
data.WriteByteSeq(guid[5]);
data << uint32(m_movementCounter++);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[6]);
break;
case MOVE_SWIM:
data.Initialize(SMSG_MOVE_SET_SWIM_SPEED, 1 + 8 + 4 + 4);
data.WriteBit(guid[5]);
data.WriteBit(guid[4]);
data.WriteBit(guid[7]);
data.WriteBit(guid[3]);
data.WriteBit(guid[2]);
data.WriteBit(guid[0]);
data.WriteBit(guid[1]);
data.WriteBit(guid[6]);
data.WriteByteSeq(guid[0]);
data << uint32(m_movementCounter++);
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[2]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[4]);
break;
case MOVE_SWIM_BACK:
data.Initialize(SMSG_MOVE_SET_SWIM_BACK_SPEED, 1 + 8 + 4 + 4);
data.WriteBit(guid[4]);
data.WriteBit(guid[2]);
data.WriteBit(guid[3]);
data.WriteBit(guid[6]);
data.WriteBit(guid[5]);
data.WriteBit(guid[1]);
data.WriteBit(guid[0]);
data.WriteBit(guid[7]);
data << uint32(m_movementCounter++);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[1]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[2]);
break;
case MOVE_TURN_RATE:
data.Initialize(SMSG_MOVE_SET_TURN_RATE, 1 + 8 + 4 + 4);
data.WriteBit(guid[7]);
data.WriteBit(guid[2]);
data.WriteBit(guid[1]);
data.WriteBit(guid[0]);
data.WriteBit(guid[4]);
data.WriteBit(guid[5]);
data.WriteBit(guid[6]);
data.WriteBit(guid[3]);
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[2]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[0]);
data << uint32(m_movementCounter++);
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[4]);
break;
case MOVE_FLIGHT:
data.Initialize(SMSG_MOVE_SET_FLIGHT_SPEED, 1 + 8 + 4 + 4);
data.WriteBit(guid[0]);
data.WriteBit(guid[5]);
data.WriteBit(guid[1]);
data.WriteBit(guid[6]);
data.WriteBit(guid[3]);
data.WriteBit(guid[2]);
data.WriteBit(guid[7]);
data.WriteBit(guid[4]);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[5]);
data << float(GetSpeed(mtype));
data << uint32(m_movementCounter++);
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[4]);
break;
case MOVE_FLIGHT_BACK:
data.Initialize(SMSG_MOVE_SET_FLIGHT_BACK_SPEED, 1 + 8 + 4 + 4);
data.WriteBit(guid[1]);
data.WriteBit(guid[2]);
data.WriteBit(guid[6]);
data.WriteBit(guid[4]);
data.WriteBit(guid[7]);
data.WriteBit(guid[3]);
data.WriteBit(guid[0]);
data.WriteBit(guid[5]);
data.WriteByteSeq(guid[3]);
data << uint32(m_movementCounter++);
data.WriteByteSeq(guid[6]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[0]);
data.WriteByteSeq(guid[5]);
data.WriteByteSeq(guid[7]);
break;
case MOVE_PITCH_RATE:
data.Initialize(SMSG_MOVE_SET_PITCH_RATE, 1 + 8 + 4 + 4);
data.WriteBit(guid[1]);
data.WriteBit(guid[2]);
data.WriteBit(guid[6]);
data.WriteBit(guid[7]);
data.WriteBit(guid[0]);
data.WriteBit(guid[3]);
data.WriteBit(guid[5]);
data.WriteBit(guid[4]);
data << float(GetSpeed(mtype));
data.WriteByteSeq(guid[6]);
data.WriteByteSeq(guid[4]);
data.WriteByteSeq(guid[0]);
data << uint32(m_movementCounter++);
data.WriteByteSeq(guid[1]);
data.WriteByteSeq(guid[2]);
data.WriteByteSeq(guid[7]);
data.WriteByteSeq(guid[3]);
data.WriteByteSeq(guid[5]);
break;
default:
sLog->outError(LOG_FILTER_UNITS, "Unit::SetSpeed: Unsupported move type (%d), data not sent to client.", mtype);
return;
}
SendMessageToSet(&data, true);
if (!isInCombat())
if (Pet* pet = ToPlayer()->GetPet())
pet->SetSpeed(mtype, m_speed_rate[mtype], forced);
}
static MovementStatusElements const speedVal = MSEExtraFloat;
Movement::ExtraMovementStatusElement extra(&speedVal);
extra.Data.floatData = GetSpeed(mtype);
Movement::PacketSender(this, moveTypeToOpcode[mtype][0], moveTypeToOpcode[mtype][1], moveTypeToOpcode[mtype][2], &extra).Send();
}
void Unit::setDeathState(DeathState s)
@@ -13663,13 +13280,6 @@ void Unit::StopMoving()
init.Launch();
}
void Unit::SendMovementFlagUpdate(bool self /* = false */)
{
WorldPacket data;
BuildHeartBeatMsg(&data);
SendMessageToSet(&data, self);
}
bool Unit::IsSitState() const
{
uint8 s = getStandState();
@@ -16440,13 +16050,7 @@ void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool cas
}
}
void Unit::BuildHeartBeatMsg(WorldPacket* data)
{
data->Initialize(MSG_MOVE_HEARTBEAT, 32);
WriteMovementInfo(*data);
}
void Unit::ReadMovementInfo(WorldPacket& data, MovementInfo* mi)
void Unit::ReadMovementInfo(WorldPacket& data, MovementInfo* mi, Movement::ExtraMovementStatusElement* extras /*= NULL*/)
{
if (GetTypeId() != TYPEID_PLAYER)
return;
@@ -16460,7 +16064,7 @@ void Unit::ReadMovementInfo(WorldPacket& data, MovementInfo* mi)
MovementStatusElements* sequence = GetMovementStatusElementsSequence(data.GetOpcode());
if (sequence == NULL)
{
sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::ReadMovementInfo: No movement sequence found for opcode 0x%04X", uint32(data.GetOpcode()));
sLog->outError(LOG_FILTER_NETWORKIO, "Unit::ReadMovementInfo: No movement sequence found for opcode %s", GetOpcodeNameForLogging(data.GetOpcode()).c_str());
return;
}
@@ -16501,15 +16105,6 @@ void Unit::ReadMovementInfo(WorldPacket& data, MovementInfo* mi)
continue;
}
if (element >= MSESpeedWalk &&
element <= MSESpeedPitchRate)
{
/// @TODO: Possibly verify with current speed - but need to keep in mind that core
/// might trigger multiple changes before client has a chance to reply so only check the last value
data.read_skip<float>();
continue;
}
switch (element)
{
case MSEHasMovementFlags:
@@ -16590,7 +16185,7 @@ void Unit::ReadMovementInfo(WorldPacket& data, MovementInfo* mi)
break;
case MSETransportOrientation:
if (hasTransportData)
mi->pos.SetOrientation(data.read<float>());
mi->t_pos.SetOrientation(data.read<float>());
break;
case MSETransportSeat:
if (hasTransportData)
@@ -16643,6 +16238,9 @@ void Unit::ReadMovementInfo(WorldPacket& data, MovementInfo* mi)
case MSEOneBit:
data.ReadBit();
break;
case MSEExtraElement:
extras->ReadNextElement(data);
break;
default:
ASSERT(false && "Incorrect sequence element detected at ReadMovementInfo");
break;
@@ -16729,7 +16327,7 @@ void Unit::ReadMovementInfo(WorldPacket& data, MovementInfo* mi)
#undef REMOVE_VIOLATING_FLAGS
}
void Unit::WriteMovementInfo(WorldPacket& data)
void Unit::WriteMovementInfo(WorldPacket& data, Movement::ExtraMovementStatusElement* extras /*= NULL*/)
{
Unit const* mover = GetCharmerGUID() ? GetCharmer() : this;
if (Player const* player = ToPlayer())
@@ -16773,7 +16371,7 @@ void Unit::WriteMovementInfo(WorldPacket& data)
MovementStatusElements* sequence = GetMovementStatusElementsSequence(data.GetOpcode());
if (!sequence)
{
sLog->outError(LOG_FILTER_NETWORKIO, "Unit::WriteMovementInfo: No movement sequence found for opcode 0x%04X", uint32(data.GetOpcode()));
sLog->outError(LOG_FILTER_NETWORKIO, "Unit::WriteMovementInfo: No movement sequence found for opcode %s", GetOpcodeNameForLogging(data.GetOpcode()).c_str());
return;
}
@@ -16814,13 +16412,6 @@ void Unit::WriteMovementInfo(WorldPacket& data)
continue;
}
if (element >= MSESpeedWalk &&
element <= MSESpeedPitchRate)
{
data << mover->GetSpeed(UnitMoveType(element - MSESpeedWalk));
continue;
}
switch (element)
{
case MSEHasMovementFlags:
@@ -16956,6 +16547,9 @@ void Unit::WriteMovementInfo(WorldPacket& data)
case MSEOneBit:
data.WriteBit(1);
break;
case MSEExtraElement:
extras->WriteNextElement(data);
break;
default:
ASSERT(false && "Incorrect sequence element detected at ReadMovementInfo");
break;
@@ -16965,7 +16559,7 @@ void Unit::WriteMovementInfo(WorldPacket& data)
void Unit::SendTeleportPacket(Position& pos)
{
// MSG_MOVE_UPDATE_TELEPORT is sent to nearby players to signal the teleport
// SMSG_MOVE_UPDATE_TELEPORT is sent to nearby players to signal the teleport
// MSG_MOVE_TELEPORT is sent to self in order to trigger MSG_MOVE_TELEPORT_ACK and update the position server side
// This oldPos actually contains the destination position if the Unit is a Player.
@@ -16977,7 +16571,7 @@ void Unit::SendTeleportPacket(Position& pos)
ObjectGuid guid = GetGUID();
ObjectGuid transGuid = GetTransGUID();
WorldPacket data(MSG_MOVE_UPDATE_TELEPORT, 38);
WorldPacket data(SMSG_MOVE_UPDATE_TELEPORT, 38);
WriteMovementInfo(data);
if (GetTypeId() == TYPEID_PLAYER)
@@ -17436,63 +17030,59 @@ bool Unit::SetHover(bool enable)
void Unit::SendMovementHover()
{
if (GetTypeId() == TYPEID_PLAYER)
ToPlayer()->SendMovementSetHover(HasUnitMovementFlag(MOVEMENTFLAG_HOVER));
WorldPacket data(MSG_MOVE_HOVER, 64);
WriteMovementInfo(data);
SendMessageToSet(&data, false);
if (HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
Movement::PacketSender(this, SMSG_SPLINE_MOVE_SET_HOVER, SMSG_MOVE_SET_HOVER).Send();
else
Movement::PacketSender(this, SMSG_SPLINE_MOVE_UNSET_HOVER, SMSG_MOVE_UNSET_HOVER).Send();
}
void Unit::SendMovementWaterWalking()
{
if (GetTypeId() == TYPEID_PLAYER)
ToPlayer()->SendMovementSetWaterWalking(HasUnitMovementFlag(MOVEMENTFLAG_WATERWALKING));
WorldPacket data(MSG_MOVE_WATER_WALK, 64);
WriteMovementInfo(data);
SendMessageToSet(&data, false);
if (HasUnitMovementFlag(MOVEMENTFLAG_WATERWALKING))
Movement::PacketSender(this, SMSG_SPLINE_MOVE_SET_WATER_WALK, SMSG_MOVE_WATER_WALK).Send();
else
Movement::PacketSender(this, SMSG_SPLINE_MOVE_SET_LAND_WALK, SMSG_MOVE_LAND_WALK).Send();
}
void Unit::SendMovementFeatherFall()
{
if (GetTypeId() == TYPEID_PLAYER)
ToPlayer()->SendMovementSetFeatherFall(HasUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW));
WorldPacket data(MSG_MOVE_FEATHER_FALL, 64);
WriteMovementInfo(data);
SendMessageToSet(&data, false);
}
void Unit::SendMovementGravityChange()
{
WorldPacket data(MSG_MOVE_GRAVITY_CHNG, 64);
WriteMovementInfo(data);
SendMessageToSet(&data, false);
if (HasUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW))
Movement::PacketSender(this, SMSG_SPLINE_MOVE_SET_FEATHER_FALL, SMSG_MOVE_FEATHER_FALL).Send();
else
Movement::PacketSender(this, SMSG_SPLINE_MOVE_SET_NORMAL_FALL, SMSG_MOVE_NORMAL_FALL).Send();
}
void Unit::SendMovementCanFlyChange()
{
/*!
if ( a3->MoveFlags & MOVEMENTFLAG_CAN_FLY )
{
v4->MoveFlags |= 0x1000000u;
result = 1;
}
else
{
if ( v4->MoveFlags & MOVEMENTFLAG_FLYING )
CMovement::DisableFlying(v4);
v4->MoveFlags &= 0xFEFFFFFFu;
result = 1;
}
*/
if (GetTypeId() == TYPEID_PLAYER)
ToPlayer()->SendMovementSetCanFly(CanFly());
if (HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY))
Movement::PacketSender(this, SMSG_SPLINE_MOVE_SET_FLYING, SMSG_MOVE_SET_CAN_FLY).Send();
else
Movement::PacketSender(this, SMSG_SPLINE_MOVE_UNSET_FLYING, SMSG_MOVE_UNSET_CAN_FLY).Send();
}
WorldPacket data(MSG_MOVE_UPDATE_CAN_FLY, 64);
WriteMovementInfo(data);
SendMessageToSet(&data, false);
void Unit::SendMovementDisableGravity()
{
if (HasUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY))
Movement::PacketSender(this, SMSG_SPLINE_MOVE_GRAVITY_DISABLE, SMSG_MOVE_GRAVITY_DISABLE).Send();
else
Movement::PacketSender(this, SMSG_SPLINE_MOVE_GRAVITY_ENABLE, SMSG_MOVE_GRAVITY_ENABLE).Send();
}
void Unit::SendMovementWalkMode()
{
///@ TODO: Find proper opcode for walk mode setting in player mind controlling a player case
if (HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
Movement::PacketSender(this, SMSG_SPLINE_MOVE_SET_WALK_MODE, SMSG_SPLINE_MOVE_SET_WALK_MODE).Send();
else
Movement::PacketSender(this, SMSG_SPLINE_MOVE_SET_RUN_MODE, SMSG_SPLINE_MOVE_SET_WALK_MODE).Send();
}
void Unit::SendMovementSwimming()
{
if (HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING))
Movement::PacketSender(this, SMSG_SPLINE_MOVE_START_SWIM, NULL_OPCODE).Send();
else
Movement::PacketSender(this, SMSG_SPLINE_MOVE_STOP_SWIM, NULL_OPCODE).Send();
}
bool Unit::IsSplineEnabled() const