summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-03-20 16:14:40 +0100
committermadmaxoft <github@xoft.cz>2014-03-20 16:14:40 +0100
commitb370cacf0c0e1234aef1efd9c442ff335a379258 (patch)
treef33cde746f321e2c7dda44f6110f246a90b1822e /src/Entities/Player.cpp
parentAPIDump: Fixed wrong escaped strings. (diff)
downloadcuberite-b370cacf0c0e1234aef1efd9c442ff335a379258.tar
cuberite-b370cacf0c0e1234aef1efd9c442ff335a379258.tar.gz
cuberite-b370cacf0c0e1234aef1efd9c442ff335a379258.tar.bz2
cuberite-b370cacf0c0e1234aef1efd9c442ff335a379258.tar.lz
cuberite-b370cacf0c0e1234aef1efd9c442ff335a379258.tar.xz
cuberite-b370cacf0c0e1234aef1efd9c442ff335a379258.tar.zst
cuberite-b370cacf0c0e1234aef1efd9c442ff335a379258.zip
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r--src/Entities/Player.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 47d0d9c61..863aaa799 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -45,6 +45,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_ClientHandle(a_Client)
, m_NormalMaxSpeed(1.0)
, m_SprintingMaxSpeed(1.3)
+ , m_FlyingMaxSpeed(1.0)
, m_IsCrouched(false)
, m_IsSprinting(false)
, m_IsFlying(false)
@@ -684,7 +685,21 @@ const cSlotNums & cPlayer::GetInventoryPaintSlots(void) const
double cPlayer::GetMaxSpeed(void) const
{
- return m_IsSprinting ? m_SprintingMaxSpeed : m_NormalMaxSpeed;
+ if (m_IsFlying)
+ {
+ return m_FlyingMaxSpeed;
+ }
+ else
+ {
+ if (m_IsSprinting)
+ {
+ return m_SprintingMaxSpeed;
+ }
+ else
+ {
+ return m_NormalMaxSpeed;
+ }
+ }
}
@@ -694,7 +709,7 @@ double cPlayer::GetMaxSpeed(void) const
void cPlayer::SetNormalMaxSpeed(double a_Speed)
{
m_NormalMaxSpeed = a_Speed;
- if (!m_IsSprinting)
+ if (!m_IsSprinting && !m_IsFlying)
{
m_ClientHandle->SendPlayerMaxSpeed();
}
@@ -707,7 +722,7 @@ void cPlayer::SetNormalMaxSpeed(double a_Speed)
void cPlayer::SetSprintingMaxSpeed(double a_Speed)
{
m_SprintingMaxSpeed = a_Speed;
- if (m_IsSprinting)
+ if (m_IsSprinting && !m_IsFlying)
{
m_ClientHandle->SendPlayerMaxSpeed();
}
@@ -717,6 +732,18 @@ void cPlayer::SetSprintingMaxSpeed(double a_Speed)
+void cPlayer::SetFlyingMaxSpeed(double a_Speed)
+{
+ m_FlyingMaxSpeed = a_Speed;
+
+ // Update the flying speed, always:
+ m_ClientHandle->SendPlayerAbilities();
+}
+
+
+
+
+
void cPlayer::SetCrouch(bool a_IsCrouched)
{
// Set the crouch status, broadcast to all visible players