summaryrefslogtreecommitdiffstats
path: root/source/Player.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-07-07 16:13:43 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-07-07 16:13:43 +0200
commit0224a4f7fc17400dd100a2333c7bbf9c898426c4 (patch)
tree5b909dc5b57a6859334591e0c5295547d8e9061f /source/Player.cpp
parentImproved function names for protocol packet sending; alpha-sorted the function lists (diff)
downloadcuberite-0224a4f7fc17400dd100a2333c7bbf9c898426c4.tar
cuberite-0224a4f7fc17400dd100a2333c7bbf9c898426c4.tar.gz
cuberite-0224a4f7fc17400dd100a2333c7bbf9c898426c4.tar.bz2
cuberite-0224a4f7fc17400dd100a2333c7bbf9c898426c4.tar.lz
cuberite-0224a4f7fc17400dd100a2333c7bbf9c898426c4.tar.xz
cuberite-0224a4f7fc17400dd100a2333c7bbf9c898426c4.tar.zst
cuberite-0224a4f7fc17400dd100a2333c7bbf9c898426c4.zip
Diffstat (limited to 'source/Player.cpp')
-rw-r--r--source/Player.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/source/Player.cpp b/source/Player.cpp
index 4dea1c3d7..35c0dcb83 100644
--- a/source/Player.cpp
+++ b/source/Player.cpp
@@ -50,7 +50,10 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_ClientHandle( a_Client )
, m_FoodExhaustionLevel(0.f)
, m_FoodTickTimer(0)
+ , m_NormalMaxSpeed(0.1)
+ , m_SprintingMaxSpeed(0.13)
, m_IsCrouched(false)
+ , m_IsSprinting(false)
{
LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
@@ -356,6 +359,41 @@ const cSlotNums & cPlayer::GetInventoryPaintSlots(void) const
+double cPlayer::GetMaxSpeed(void) const
+{
+ return m_IsSprinting ? m_SprintingMaxSpeed : m_NormalMaxSpeed;
+}
+
+
+
+
+
+void cPlayer::SetNormalMaxSpeed(double a_Speed)
+{
+ m_NormalMaxSpeed = a_Speed;
+ if (!m_IsSprinting)
+ {
+ m_ClientHandle->SendPlayerMaxSpeed();
+ }
+}
+
+
+
+
+
+void cPlayer::SetSprintingMaxSpeed(double a_Speed)
+{
+ m_SprintingMaxSpeed = a_Speed;
+ if (m_IsSprinting)
+ {
+ m_ClientHandle->SendPlayerMaxSpeed();
+ }
+}
+
+
+
+
+
void cPlayer::SetCrouch(bool a_IsCrouched)
{
// Set the crouch status, broadcast to all visible players
@@ -373,6 +411,22 @@ void cPlayer::SetCrouch(bool a_IsCrouched)
+void cPlayer::SetSprint(bool a_IsSprinting)
+{
+ if (a_IsSprinting == m_IsSprinting)
+ {
+ // No change
+ return;
+ }
+
+ m_IsSprinting = a_IsSprinting;
+ m_ClientHandle->SendPlayerMaxSpeed();
+}
+
+
+
+
+
void cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (m_GameMode == eGameMode_Creative)