本文整理汇总了C++中MovementInfo::UpdateTime方法的典型用法代码示例。如果您正苦于以下问题:C++ MovementInfo::UpdateTime方法的具体用法?C++ MovementInfo::UpdateTime怎么用?C++ MovementInfo::UpdateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MovementInfo
的用法示例。
在下文中一共展示了MovementInfo::UpdateTime方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleMoveRootAck
void WorldSession::HandleMoveRootAck(WorldPacket& recv_data)
{
DEBUG_LOG("WORLD: CMSG_FORCE_MOVE_ROOT_ACK");
ObjectGuid guid;
recv_data >> guid;
// now can skip not our packet
if (_player->GetObjectGuid() != guid)
{
recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return;
}
MovementInfo movementInfo;
recv_data.read_skip<uint32>(); // unk
recv_data >> movementInfo;
movementInfo.UpdateTime(recv_data.GetPacketTime());
if (!VerifyMovementInfo(movementInfo))
return;
if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data))
return;
// Position change
HandleMoverRelocation(movementInfo);
_player->UpdateFallInformationIfNeed(movementInfo, recv_data.GetOpcode());
WorldPacket data(MSG_MOVE_ROOT, recv_data.size());
data << _player->GetPackGUID();
movementInfo.Write(data);
_player->SendMovementMessageToSet(std::move(data), true, _player);
}
示例2: SynchronizeMovement
void WorldSession::SynchronizeMovement(MovementInfo &movementInfo)
{
// Get time based on server
uint32 currMsTime = WorldTimer::getMSTime();
// Invalidate syncs older than 750ms (and start new one)
if (lastMoveTimeServer < currMsTime - 750)
{
lastMoveTimeServer = currMsTime;
}
else
{
// The time that is between last clients time and current client time gets applie to last server time
uint32 clientMsDiff = movementInfo.time - lastMoveTimeClient;
if (clientMsDiff > 750)
lastMoveTimeServer = currMsTime;
else
{
uint32 serverDiffApplied = lastMoveTimeServer + clientMsDiff;
lastMoveTimeServer = serverDiffApplied;
}
if (lastMoveTimeServer > currMsTime)
lastMoveTimeServer = currMsTime;
}
lastMoveTimeClient = movementInfo.time;
movementInfo.UpdateTime(lastMoveTimeServer);
}
示例3: HandleFeatherFallAck
void WorldSession::HandleFeatherFallAck(WorldPacket &recv_data)
{
DEBUG_LOG("WORLD: CMSG_MOVE_FEATHER_FALL_ACK size %u", recv_data.wpos());
ObjectGuid guid;
MovementInfo movementInfo;
recv_data >> guid; // guid
recv_data.read_skip<uint32>(); // counter
recv_data >> movementInfo;
movementInfo.UpdateTime(recv_data.GetPacketTime());
if (guid != _clientMoverGuid)
return;
if (!VerifyMovementInfo(movementInfo))
return;
if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data))
return;
// Position change
HandleMoverRelocation(movementInfo);
_player->UpdateFallInformationIfNeed(movementInfo, recv_data.GetOpcode());
WorldPacket data(MSG_MOVE_FEATHER_FALL, recv_data.size());
data << guid.WriteAsPacked();
movementInfo.Write(data);
_player->SendMovementMessageToSet(std::move(data), true, _player);
}
示例4: HandleMoveKnockBackAck
void WorldSession::HandleMoveKnockBackAck(WorldPacket & recv_data)
{
DEBUG_LOG("CMSG_MOVE_KNOCK_BACK_ACK");
Unit *mover = _player->GetMover();
Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL;
// ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck
if (plMover && plMover->IsBeingTeleported())
{
recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return;
}
ObjectGuid guid;
MovementInfo movementInfo;
recv_data >> guid;
recv_data >> Unused<uint32>(); // knockback packets counter
recv_data >> movementInfo;
movementInfo.UpdateTime(recv_data.GetPacketTime());
if (guid != _clientMoverGuid)
return;
if (!VerifyMovementInfo(movementInfo, guid))
return;
if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data))
return;
HandleMoverRelocation(movementInfo);
// Actually other clients don't need this packet ...
// CMSG_MOVE_KNOCK_BACK_ACK only use is to update position server side for now.
/*
WorldPacket data(MSG_MOVE_KNOCK_BACK, recv_data.size() + 12);
data << guid.WriteAsPacked();
data << movementInfo;
data << movementInfo.GetJumpInfo().sinAngle;
data << movementInfo.GetJumpInfo().cosAngle;
data << movementInfo.GetJumpInfo().xyspeed;
data << movementInfo.GetJumpInfo().velocity;
mover->SendMovementMessageToSet(&data, true, _player);*/
}
示例5: HandleMovementOpcodes
void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
{
uint32 opcode = recv_data.GetOpcode();
DEBUG_LOG("WORLD: Recvd %s (%u, 0x%X) opcode", opCodes.LookupOpcode(opcode)->name, opcode, opcode);
Unit *mover = _player; // for better code compatibiltiy until mover not backported from master
Player *plMover = _player;
// ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck
if(plMover && plMover->IsBeingTeleported())
{
recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return;
}
/* extract packet */
MovementInfo movementInfo;
recv_data >> movementInfo;
/*----------------*/
if (!MaNGOS::IsValidMapCoord(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o))
{
recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return;
}
/* handle special cases */
if (movementInfo.HasMovementFlag(MOVEFLAG_ONTRANSPORT))
{
// transports size limited
// (also received at zeppelin/lift leave by some reason with t_* as absolute in continent coordinates, can be safely skipped)
if( movementInfo.GetTransportPos()->x > 50 || movementInfo.GetTransportPos()->y > 50 || movementInfo.GetTransportPos()->z > 100 )
{
recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return;
}
if( !MaNGOS::IsValidMapCoord(movementInfo.GetPos()->x + movementInfo.GetTransportPos()->x, movementInfo.GetPos()->y + movementInfo.GetTransportPos()->y,
movementInfo.GetPos()->z + movementInfo.GetTransportPos()->z, movementInfo.GetPos()->o + movementInfo.GetTransportPos()->o) )
{
recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return;
}
// if we boarded a transport, add us to it
if (plMover && !plMover->m_transport)
{
// elevators also cause the client to send MOVEFLAG_ONTRANSPORT - just unmount if the guid can be found in the transport list
for (MapManager::TransportSet::const_iterator iter = sMapMgr.m_Transports.begin(); iter != sMapMgr.m_Transports.end(); ++iter)
{
if ((*iter)->GetObjectGuid() == movementInfo.GetTransportGuid())
{
// unmount before boarding
plMover->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
GetPlayer()->m_transport = (*iter);
(*iter)->AddPassenger(plMover);
break;
}
}
}
}
else if (plMover && plMover->m_transport) // if we were on a transport, leave
{
plMover->m_transport->RemovePassenger(plMover);
plMover->m_transport = NULL;
movementInfo.ClearTransportData();
}
// fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
if (opcode == MSG_MOVE_FALL_LAND && plMover && !plMover->isInFlight())
plMover->HandleFall(movementInfo);
if (plMover && (movementInfo.HasMovementFlag(MOVEFLAG_SWIMMING) != plMover->IsInWater()))
{
// now client not include swimming flag in case jumping under water
plMover->SetInWater( !plMover->IsInWater() || plMover->GetBaseMap()->IsUnderWater(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z) );
}
/*----------------------*/
/* process position-change */
movementInfo.UpdateTime(getMSTime());
WorldPacket data(opcode, recv_data.size());
data.appendPackGUID(mover->GetGUID()); // write guid
movementInfo.Write(data); // write data
mover->SendMessageToSetExcept(&data, _player);
if(plMover) // nothing is charmed, or player charmed
{
plMover->SetPosition(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o);
plMover->m_movementInfo = movementInfo;
plMover->UpdateFallInformationIfNeed(movementInfo, opcode);
// after move info set
if ((opcode == MSG_MOVE_SET_WALK_MODE || opcode == MSG_MOVE_SET_RUN_MODE))
plMover->UpdateWalkMode(plMover, false);
if(plMover->isMovingOrTurning())
//.........这里部分代码省略.........
示例6: HandleMoverRelocation
void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo)
{
movementInfo.UpdateTime(getMSTime());
Unit *mover = _player->GetMover();
if (Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL)
{
if (movementInfo.HasMovementFlag(MOVEFLAG_ONTRANSPORT))
{
if (!plMover->GetTransport())
{
float trans_rad = movementInfo.GetTransportPos()->x*movementInfo.GetTransportPos()->x + movementInfo.GetTransportPos()->y*movementInfo.GetTransportPos()->y + movementInfo.GetTransportPos()->z*movementInfo.GetTransportPos()->z;
if (trans_rad > 3600.0f) // transport radius = 60 yards //cheater with on_transport_flag
{
return;
}
// elevators also cause the client to send MOVEFLAG_ONTRANSPORT - just unmount if the guid can be found in the transport list
for (MapManager::TransportSet::const_iterator iter = sMapMgr.m_Transports.begin(); iter != sMapMgr.m_Transports.end(); ++iter)
{
Transport* transport = *iter;
if (transport->GetObjectGuid() == movementInfo.GetTransportGuid())
{
plMover->SetTransport(transport);
transport->AddPassenger(plMover);
if (plMover->GetVehicleKit())
plMover->GetVehicleKit()->RemoveAllPassengers();
break;
}
}
}
}
else if (plMover->GetTransport()) // if we were on a transport, leave
{
plMover->GetTransport()->RemovePassenger(plMover);
plMover->SetTransport(NULL);
movementInfo.ClearTransportData();
}
if (movementInfo.HasMovementFlag(MOVEFLAG_SWIMMING) != plMover->IsInWater())
{
// now client not include swimming flag in case jumping under water
plMover->SetInWater( !plMover->IsInWater() || plMover->GetTerrain()->IsUnderWater(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z) );
}
if(plMover->GetTerrain()->IsUnderWater(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z-7.0f))
{
plMover->m_anti_BeginFallZ=INVALID_HEIGHT;
}
plMover->SetPosition(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o);
plMover->m_movementInfo = movementInfo;
if(movementInfo.GetPos()->z < -500.0f)
{
if(plMover->InBattleGround()
&& plMover->GetBattleGround()
&& plMover->GetBattleGround()->HandlePlayerUnderMap(_player))
{
// do nothing, the handle already did if returned true
}
else
{
// NOTE: this is actually called many times while falling
// even after the player has been teleported away
// TODO: discard movement packets after the player is rooted
if(plMover->isAlive())
{
plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, plMover->GetMaxHealth());
// pl can be alive if GM/etc
if(!plMover->isAlive())
{
// change the death state to CORPSE to prevent the death timer from
// starting in the next player update
plMover->KillPlayer();
plMover->BuildPlayerRepop();
}
}
// cancel the death timer here if started
plMover->RepopAtGraveyard();
}
}
}
}
示例7: HandleMovementOpcodes
//.........这里部分代码省略.........
Anti__CheatOccurred(CurTime,"Fly hack",
((uint8)(GetPlayer()->HasAuraType(SPELL_AURA_FLY))) +
((uint8)(GetPlayer()->HasAuraType(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED))*2),
NULL,GetPlayer()->GetPositionZ()-Anti__MapZ);
}
// Need a better way to do that - currently a lot of fake alarms
else if ((Anti__MapZ+DIFF_AIRJUMP < GetPlayer()->GetPositionZ() &&
(movementInfo.GetMovementFlags() & (MOVEFLAG_FALLINGFAR | MOVEFLAG_PENDINGSTOP))==0) ||
(Anti__MapZ < GetPlayer()->GetPositionZ() && opcode==MSG_MOVE_JUMP) &&
!GetPlayer()->HasAuraType(SPELL_AURA_FEATHER_FALL))
{
if (sWorld.GetMvAnticheatJumpCheck())
Anti__CheatOccurred(CurTime,"Possible Air Jump Hack",0.0f,LookupOpcodeName(opcode),0.0f,movementInfo.GetMovementFlags());
}
}
/*if (Anti__FloorZ < -199900.0f && Anti__GroundZ >= -199900.0f &&
GetPlayer()->GetPositionZ()+5.0f < Anti__GroundZ)
{
Anti__CheatOccurred(CurTime,"Teleport2Plane hack",
GetPlayer()->GetPositionZ(),NULL,Anti__GroundZ);
}*/
//Teleport To Plane checks
if (movementInfo.GetPos()->z < 0.0001f && movementInfo.GetPos()->z > -0.0001f && (!movementInfo.HasMovementFlag(MovementFlags(MOVEFLAG_SWIMMING | MOVEFLAG_CAN_FLY | MOVEFLAG_FLYING))))
{
if (sWorld.GetMvAnticheatTeleport2PlaneCheck())
{
// Prevent using TeleportToPlan.
Map *map = GetPlayer()->GetMap();
if (map)
{
float plane_z = map->GetHeight(movementInfo.GetPos()->x, movementInfo.GetPos()->y, MAX_HEIGHT) - movementInfo.GetPos()->z;
plane_z = (plane_z < -500.0f) ? 0 : plane_z; //check holes in heigth map
if (plane_z > 0.1f || plane_z < -0.1f)
{
if (sWorld.GetMvAnticheatTeleport2PlaneCheck())
Anti__CheatOccurred(CurTime,"Teleport2Plane hack",GetPlayer()->GetPositionZ(),NULL,plane_z);
}
}
}
}
}
// <<---- anti-cheat features
/* process position-change */
movementInfo.UpdateTime(getMSTime());
WorldPacket data(opcode, recv_data.size());
data.appendPackGUID(mover->GetGUID()); // write guid
movementInfo.Write(data); // write data
mover->SendMessageToSetExcept(&data, _player);
mover->m_movementInfo = movementInfo;
mover->SetPosition(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o);
if (plMover) // nothing is charmed, or player charmed
{
plMover->UpdateFallInformationIfNeed(movementInfo, opcode);
// after move info set
if ((opcode == MSG_MOVE_SET_WALK_MODE || opcode == MSG_MOVE_SET_RUN_MODE))
plMover->UpdateWalkMode(plMover, false);
if (plMover->isMovingOrTurning())
plMover->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
if (movementInfo.GetPos()->z < -500.0f)
{
if (plMover->InBattleGround()
&& plMover->GetBattleGround()
&& plMover->GetBattleGround()->HandlePlayerUnderMap(_player))
{
// do nothing, the handle already did if returned true
}
else
{
// NOTE: this is actually called many times while falling
// even after the player has been teleported away
// TODO: discard movement packets after the player is rooted
if (plMover->isAlive())
{
plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, plMover->GetMaxHealth());
// pl can be alive if GM/etc
if (!plMover->isAlive())
{
// change the death state to CORPSE to prevent the death timer from
// starting in the next player update
plMover->KillPlayer();
plMover->BuildPlayerRepop();
}
}
// cancel the death timer here if started
plMover->RepopAtGraveyard();
}
}
}
}
示例8: HandleMoverRelocation
void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo)
{
if (m_clientTimeDelay == 0)
m_clientTimeDelay = WorldTimer::getMSTime() - movementInfo.GetTime();
movementInfo.UpdateTime(movementInfo.GetTime() + m_clientTimeDelay + MOVEMENT_PACKET_TIME_DELAY);
Unit* mover = _player->GetMover();
if (Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : nullptr)
{
if (movementInfo.HasMovementFlag(MOVEFLAG_ONTRANSPORT))
{
if (!plMover->m_transport)
{
// elevators also cause the client to send MOVEFLAG_ONTRANSPORT - just unmount if the guid can be found in the transport list
for (MapManager::TransportSet::const_iterator iter = sMapMgr.m_Transports.begin(); iter != sMapMgr.m_Transports.end(); ++iter)
{
if ((*iter)->GetObjectGuid() == movementInfo.GetTransportGuid())
{
plMover->m_transport = (*iter);
(*iter)->AddPassenger(plMover);
break;
}
}
}
}
else if (plMover->m_transport) // if we were on a transport, leave
{
plMover->m_transport->RemovePassenger(plMover);
plMover->m_transport = nullptr;
movementInfo.ClearTransportData();
}
if (movementInfo.HasMovementFlag(MOVEFLAG_SWIMMING) != plMover->IsInWater())
{
// now client not include swimming flag in case jumping under water
plMover->SetInWater(!plMover->IsInWater() || plMover->GetTerrain()->IsUnderWater(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z));
}
plMover->SetPosition(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o);
plMover->m_movementInfo = movementInfo;
if (movementInfo.GetPos()->z < -500.0f)
{
if (plMover->GetBattleGround()
&& plMover->GetBattleGround()->HandlePlayerUnderMap(_player))
{
// do nothing, the handle already did if returned true
}
else
{
// NOTE: this is actually called many times while falling
// even after the player has been teleported away
// TODO: discard movement packets after the player is rooted
if (plMover->isAlive())
{
plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, plMover->GetMaxHealth());
// pl can be alive if GM/etc
if (!plMover->isAlive())
{
// change the death state to CORPSE to prevent the death timer from
// starting in the next player update
plMover->KillPlayer();
plMover->BuildPlayerRepop();
}
}
// cancel the death timer here if started
plMover->RepopAtGraveyard();
}
}
}
else // creature charmed
{
if (mover->IsInWorld())
mover->GetMap()->CreatureRelocation((Creature*)mover, movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o);
}
}
示例9: HandleForceSpeedChangeAckOpcodes
void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket &recv_data)
{
uint32 opcode = recv_data.GetOpcode();
DEBUG_LOG("WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode);
/* extract packet */
ObjectGuid guid;
MovementInfo movementInfo;
float newspeed;
recv_data >> guid;
recv_data >> Unused<uint32>(); // counter or moveEvent
recv_data >> movementInfo;
recv_data >> newspeed;
movementInfo.UpdateTime(recv_data.GetPacketTime());
// now can skip not our packet
ObjectGuid moverGuid = _player->GetMover()->GetObjectGuid();
if (guid != moverGuid && guid != _clientMoverGuid)
return;
if (!VerifyMovementInfo(movementInfo))
return;
// Process anticheat checks, remember client-side speed ...
if (_player->IsSelfMover() && !_player->GetCheatData()->HandleSpeedChangeAck(movementInfo, this, &recv_data, newspeed))
return;
// Process position-change
HandleMoverRelocation(movementInfo);
_player->UpdateFallInformationIfNeed(movementInfo, opcode);
/*----------------*/
// client ACK send one packet for mounted/run case and need skip all except last from its
// in other cases anti-cheat check can be fail in false case
UnitMoveType move_type;
switch (opcode)
{
case CMSG_FORCE_WALK_SPEED_CHANGE_ACK:
move_type = MOVE_WALK;
break;
case CMSG_FORCE_RUN_SPEED_CHANGE_ACK:
move_type = MOVE_RUN;
break;
case CMSG_FORCE_RUN_BACK_SPEED_CHANGE_ACK:
move_type = MOVE_RUN_BACK;
break;
case CMSG_FORCE_SWIM_SPEED_CHANGE_ACK:
move_type = MOVE_SWIM;
break;
case CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK:
move_type = MOVE_SWIM_BACK;
break;
case CMSG_FORCE_TURN_RATE_CHANGE_ACK:
move_type = MOVE_TURN_RATE;
break;
default:
sLog.outError("WorldSession::HandleForceSpeedChangeAck: Unknown move type opcode: %u", opcode);
return;
}
// Daemon TODO: enregistrement de cette position ?
// Daemon: mise a jour de la vitesse pour les joueurs a cote.
// Cf Unit::SetSpeedRate pour plus d'infos.
const uint16 SetSpeed2Opc_table[MAX_MOVE_TYPE][2] =
{
{MSG_MOVE_SET_WALK_SPEED, SMSG_FORCE_WALK_SPEED_CHANGE},
{MSG_MOVE_SET_RUN_SPEED, SMSG_FORCE_RUN_SPEED_CHANGE},
{MSG_MOVE_SET_RUN_BACK_SPEED, SMSG_FORCE_RUN_BACK_SPEED_CHANGE},
{MSG_MOVE_SET_SWIM_SPEED, SMSG_FORCE_SWIM_SPEED_CHANGE},
{MSG_MOVE_SET_SWIM_BACK_SPEED, SMSG_FORCE_SWIM_BACK_SPEED_CHANGE},
{MSG_MOVE_SET_TURN_RATE, SMSG_FORCE_TURN_RATE_CHANGE},
};
WorldPacket data(SetSpeed2Opc_table[move_type][0], 31);
data << _player->GetMover()->GetPackGUID();
data << movementInfo;
data << float(newspeed);
_player->SendMovementMessageToSet(std::move(data), false);
if (!_player->GetMover()->movespline->Finalized())
{
WorldPacket splineData(SMSG_MONSTER_MOVE, 31);
splineData << _player->GetMover()->GetPackGUID();
Movement::PacketBuilder::WriteMonsterMove(*(_player->GetMover()->movespline), splineData);
_player->SendMovementMessageToSet(std::move(splineData), false);
}
}
示例10: HandleMovementOpcodes
void WorldSession::HandleMovementOpcodes(WorldPacket & recv_data)
{
uint32 opcode = recv_data.GetOpcode();
DEBUG_LOG("WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode);
Unit *mover = _player->GetMover();
if (mover->GetObjectGuid() != _clientMoverGuid)
return;
Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL;
// ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck
if (plMover && plMover->IsBeingTeleported())
{
recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return;
}
/* extract packet */
MovementInfo movementInfo = plMover ? plMover->m_movementInfo : MovementInfo();
recv_data >> movementInfo;
movementInfo.UpdateTime(recv_data.GetPacketTime());
/*----------------*/
if (!VerifyMovementInfo(movementInfo))
return;
if (plMover && !plMover->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data))
return;
// this must be called after HandleAnticheatTests because that function will update order counters (for things like slow fall, water walk, etc.)
if (plMover && !plMover->GetCheatData()->CheckTeleport(opcode, movementInfo))
return;
// Interrupt spell cast at move
if (movementInfo.HasMovementFlag(MOVEFLAG_MASK_MOVING))
mover->InterruptSpellsWithInterruptFlags(SPELL_INTERRUPT_FLAG_MOVEMENT);
HandleMoverRelocation(movementInfo);
// fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
if (opcode == MSG_MOVE_FALL_LAND && plMover && !plMover->IsTaxiFlying())
plMover->HandleFall(movementInfo);
// TODO: remove it
// reset knockback state when fall to ground or water
if (plMover)
{
if ((opcode == MSG_MOVE_FALL_LAND || opcode == MSG_MOVE_START_SWIM) && plMover->IsLaunched())
{
plMover->SetLaunched(false);
plMover->SetXYSpeed(0.0f);
}
}
if (plMover)
plMover->UpdateFallInformationIfNeed(movementInfo, opcode);
WorldPacket data(opcode, recv_data.size());
data << _clientMoverGuid.WriteAsPacked(); // write guid
movementInfo.Write(data); // write data
mover->SendMovementMessageToSet(std::move(data), true, _player);
}
示例11: HandleMovementOpcodes
void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
{
uint32 opcode = recv_data.GetOpcode();
DEBUG_LOG("WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode);
recv_data.hexlike();
Unit *mover = _player->GetMover();
Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL;
// ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck
if(plMover && plMover->IsBeingTeleported())
{
recv_data.rpos(recv_data.wpos()); // prevent warnings spam
return;
}
/* extract packet */
ObjectGuid guid;
MovementInfo movementInfo;
recv_data >> guid.ReadAsPacked();
recv_data >> movementInfo;
/*----------------*/
if (!VerifyMovementInfo(movementInfo, guid))
return;
// fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
if (opcode == MSG_MOVE_FALL_LAND && plMover && !plMover->IsTaxiFlying())
plMover->HandleFall(movementInfo);
/* process position-change */
HandleMoverRelocation(movementInfo);
if (plMover)
plMover->UpdateFallInformationIfNeed(movementInfo, opcode);
/* process position-change */
if (!plMover)
return;
movementInfo.UpdateTime(getMSTime());
if(plMover) // nothing is charmed, or player charmed
{
WorldPacket data(opcode, recv_data.size());
data << mover->GetPackGUID(); // write guid
movementInfo.Write(data); // write data
mover->SendMessageToSetExcept(&data, _player);
plMover->SetPosition(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o);
plMover->m_movementInfo = movementInfo;
plMover->UpdateFallInformationIfNeed(movementInfo, opcode);
// after move info set
if (opcode == MSG_MOVE_SET_WALK_MODE || opcode == MSG_MOVE_SET_RUN_MODE)
mover->UpdateWalkMode(mover, false);
if(plMover->isMovingOrTurning())
plMover->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
if(movementInfo.GetPos()->z < -500.0f)
{
if(plMover->InBattleGround()
&& plMover->GetBattleGround()
&& plMover->GetBattleGround()->HandlePlayerUnderMap(_player))
{
// do nothing, the handle already did if returned true
}
else
{
// NOTE: this is actually called many times while falling
// even after the player has been teleported away
// TODO: discard movement packets after the player is rooted
if(plMover->isAlive())
{
plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, plMover->GetMaxHealth());
// pl can be alive if GM/etc
if(!plMover->isAlive())
{
// change the death state to CORPSE to prevent the death timer from
// starting in the next player update
plMover->KillPlayer();
plMover->BuildPlayerRepop();
}
}
// cancel the death timer here if started
plMover->RepopAtGraveyard();
}
}
}
else // creature charmed
{
if(mover->IsInWorld())
mover->GetMap()->CreatureRelocation((Creature*)mover, movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o);
}
}