From ee50790398791c38e563eee04cf12780fab74baf Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 16 Jun 2014 15:12:50 +0100 Subject: Merge branch 'master' of github.com:mc-server/MCServer --- src/Entities/Entity.cpp | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'src/Entities/Entity.cpp') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 8f736a269..ee7ce06ac 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -179,14 +179,9 @@ void cEntity::WrapRotation(void) void cEntity::WrapSpeed(void) { - // There shoudn't be a need for flipping the flag on because this function is called - // after any update, so the flag is already turned on - if (m_Speed.x > 78.0f) m_Speed.x = 78.0f; - else if (m_Speed.x < -78.0f) m_Speed.x = -78.0f; - if (m_Speed.y > 78.0f) m_Speed.y = 78.0f; - else if (m_Speed.y < -78.0f) m_Speed.y = -78.0f; - if (m_Speed.z > 78.0f) m_Speed.z = 78.0f; - else if (m_Speed.z < -78.0f) m_Speed.z = -78.0f; + m_Speed.x = Clamp(m_Speed.x, -78.0, 78.0); + m_Speed.y = Clamp(m_Speed.y, -78.0, 78.0); + m_Speed.z = Clamp(m_Speed.z, -78.0, 78.0); } @@ -1076,6 +1071,17 @@ void cEntity::SetSwimState(cChunk & a_Chunk) +void cEntity::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) +{ + m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ); + + WrapSpeed(); +} + + + + + void cEntity::HandleAir(void) { // Ref.: http://www.minecraftwiki.net/wiki/Chunk_format @@ -1428,9 +1434,7 @@ void cEntity::SetRoll(double a_Roll) void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) { - m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ); - - WrapSpeed(); + DoSetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ); } @@ -1438,9 +1442,7 @@ void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) void cEntity::SetSpeedX(double a_SpeedX) { - m_Speed.x = a_SpeedX; - - WrapSpeed(); + SetSpeed(a_SpeedX, m_Speed.y, m_Speed.z); } @@ -1448,9 +1450,7 @@ void cEntity::SetSpeedX(double a_SpeedX) void cEntity::SetSpeedY(double a_SpeedY) { - m_Speed.y = a_SpeedY; - - WrapSpeed(); + SetSpeed(m_Speed.x, a_SpeedY, m_Speed.z); } @@ -1458,9 +1458,7 @@ void cEntity::SetSpeedY(double a_SpeedY) void cEntity::SetSpeedZ(double a_SpeedZ) { - m_Speed.z = a_SpeedZ; - - WrapSpeed(); + SetSpeed(m_Speed.x, m_Speed.y, a_SpeedZ); } -- cgit v1.2.3