1
0

cPlayer now uses BroadcastMovementUpdate during its Tick function

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1395 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
keyboard.osh@gmail.com 2013-04-19 04:32:18 +00:00
parent 01b7c1fbfb
commit 0ceadbe7e0

View File

@ -165,50 +165,16 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
}
super::Tick(a_Dt, a_Chunk);
//TODO: Change this to use the BroadcastMovementUpdate function
if (m_bDirtyOrientation && !m_bDirtyPosition)
{
m_World->BroadcastEntLook(*this, m_ClientHandle);
m_World->BroadcastEntHeadLook(*this, m_ClientHandle);
m_bDirtyOrientation = false;
}
else if (m_bDirtyPosition)
if (m_bDirtyPosition)
{
cRoot::Get()->GetPluginManager()->CallHookPlayerMoving(*this);
float DiffX = (float)(GetPosX() - m_LastPosX );
float DiffY = (float)(GetPosY() - m_LastPosY );
float DiffZ = (float)(GetPosZ() - m_LastPosZ );
float SqrDist = DiffX * DiffX + DiffY * DiffY + DiffZ * DiffZ;
if (
(SqrDist > 4 * 4) || // 4 blocks is max Relative Move
(m_World->GetWorldAge() - m_TimeLastTeleportPacket > 40) // Send an absolute position every 2 seconds
)
{
// LOG("Teleported %f", sqrtf(SqrDist) );
m_World->BroadcastTeleportEntity(*this, m_ClientHandle);
m_TimeLastTeleportPacket = m_World->GetWorldAge();
}
else
{
// Relative move sucks balls! It's always wrong wtf!
if (m_bDirtyOrientation)
{
m_World->BroadcastEntRelMoveLook(*this, (char)(DiffX * 32), (char)(DiffY * 32), (char)(DiffZ * 32), m_ClientHandle);
m_World->BroadcastEntHeadLook(*this, m_ClientHandle);
m_bDirtyOrientation = false;
}
else
{
m_World->BroadcastEntRelMove(*this, (char)(DiffX * 32), (char)(DiffY * 32), (char)(DiffZ * 32), m_ClientHandle);
}
}
m_LastPosX = GetPosX();
m_LastPosY = GetPosY();
m_LastPosZ = GetPosZ();
m_bDirtyPosition = false;
BroadcastMovementUpdate(m_ClientHandle);
m_ClientHandle->StreamChunks();
}
else
{
BroadcastMovementUpdate(m_ClientHandle);
}
if (m_Health > 0) // make sure player is alive
{