From 0ceadbe7e0308484fd787d2a1ee05392f91c7178 Mon Sep 17 00:00:00 2001 From: "keyboard.osh@gmail.com" Date: Fri, 19 Apr 2013 04:32:18 +0000 Subject: cPlayer now uses BroadcastMovementUpdate during its Tick function git-svn-id: http://mc-server.googlecode.com/svn/trunk@1395 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Player.cpp | 46 ++++++---------------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/source/Player.cpp b/source/Player.cpp index 2cb96ca9c..544503e5e 100644 --- a/source/Player.cpp +++ b/source/Player.cpp @@ -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 { -- cgit v1.2.3