diff options
author | Mattes D <github@xoft.cz> | 2014-05-06 21:44:55 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-05-06 21:44:55 +0200 |
commit | e400b1acd8b0c1457f33bc1730996a3530fa0a4f (patch) | |
tree | cd26c0d2b87b62882bcc7b64503de408dd391e6f /src/Entities/Player.cpp | |
parent | Changed cPieceGenerator to support pairings. (diff) | |
parent | Merge branch 'master' into fixes (diff) | |
download | cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.tar cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.tar.gz cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.tar.bz2 cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.tar.lz cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.tar.xz cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.tar.zst cuberite-e400b1acd8b0c1457f33bc1730996a3530fa0a4f.zip |
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r-- | src/Entities/Player.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 08b7d3984..6ac11c270 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -76,11 +76,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) cTimer t1; m_LastPlayerListTime = t1.GetNowTime(); - - m_TimeLastTeleportPacket = 0; m_PlayerName = a_PlayerName; - m_bDirtyPosition = true; // So chunks are streamed to player at spawn if (!LoadFromDisk()) { @@ -209,25 +206,22 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) m_BowCharge += 1; } - //handle updating experience + // Handle updating experience if (m_bDirtyExperience) { SendExperience(); } - if (m_bDirtyPosition) + if (GetPosition() != m_LastPos) // Change in position from last tick? { // Apply food exhaustion from movement: ApplyFoodExhaustionFromMovement(); cRoot::Get()->GetPluginManager()->CallHookPlayerMoving(*this); - BroadcastMovementUpdate(m_ClientHandle); m_ClientHandle->StreamChunks(); } - else - { - BroadcastMovementUpdate(m_ClientHandle); - } + + BroadcastMovementUpdate(m_ClientHandle); if (m_Health > 0) // make sure player is alive { @@ -1596,10 +1590,7 @@ bool cPlayer::LoadFromDisk() SetPosX(JSON_PlayerPosition[(unsigned int)0].asDouble()); SetPosY(JSON_PlayerPosition[(unsigned int)1].asDouble()); SetPosZ(JSON_PlayerPosition[(unsigned int)2].asDouble()); - m_LastPosX = GetPosX(); - m_LastPosY = GetPosY(); - m_LastPosZ = GetPosZ(); - m_LastFoodPos = GetPosition(); + m_LastPos = GetPosition(); } Json::Value & JSON_PlayerRotation = root["rotation"]; @@ -1860,17 +1851,16 @@ void cPlayer::ApplyFoodExhaustionFromMovement() { return; } - - // Calculate the distance travelled, update the last pos: - Vector3d Movement(GetPosition() - m_LastFoodPos); - Movement.y = 0; // Only take XZ movement into account - m_LastFoodPos = GetPosition(); - + // If riding anything, apply no food exhaustion if (m_AttachedTo != NULL) { return; } + + // Calculate the distance travelled, update the last pos: + Vector3d Movement(GetPosition() - m_LastPos); + Movement.y = 0; // Only take XZ movement into account // Apply the exhaustion based on distance travelled: double BaseExhaustion = Movement.Length(); |