summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-03-20 15:45:42 +0100
committermadmaxoft <github@xoft.cz>2014-03-20 15:45:42 +0100
commit64d9390069650bbbc1850d5602b9854a1c1a7257 (patch)
tree02d504711e730d235cd6b1c2c874e797a6359902 /src
parentProtoProxy: Fixed MSVC compilation. (diff)
downloadcuberite-64d9390069650bbbc1850d5602b9854a1c1a7257.tar
cuberite-64d9390069650bbbc1850d5602b9854a1c1a7257.tar.gz
cuberite-64d9390069650bbbc1850d5602b9854a1c1a7257.tar.bz2
cuberite-64d9390069650bbbc1850d5602b9854a1c1a7257.tar.lz
cuberite-64d9390069650bbbc1850d5602b9854a1c1a7257.tar.xz
cuberite-64d9390069650bbbc1850d5602b9854a1c1a7257.tar.zst
cuberite-64d9390069650bbbc1850d5602b9854a1c1a7257.zip
Diffstat (limited to 'src')
-rw-r--r--src/Entities/Player.cpp4
-rw-r--r--src/Entities/Player.h14
-rw-r--r--src/Protocol/Protocol16x.cpp4
-rw-r--r--src/Protocol/Protocol17x.cpp7
4 files changed, 17 insertions, 12 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 440d30595..47d0d9c61 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -43,8 +43,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_GameMode(eGameMode_NotSet)
, m_IP("")
, m_ClientHandle(a_Client)
- , m_NormalMaxSpeed(0.1)
- , m_SprintingMaxSpeed(0.13)
+ , m_NormalMaxSpeed(1.0)
+ , m_SprintingMaxSpeed(1.3)
, m_IsCrouched(false)
, m_IsSprinting(false)
, m_IsFlying(false)
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index c25053c21..451dde8fc 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -331,13 +331,13 @@ public:
// tolua_begin
- /// Returns the current maximum speed, as reported in the 1.6.1+ protocol (takes current sprinting state into account)
+ /// Returns the current relative maximum speed (takes current sprinting state into account)
double GetMaxSpeed(void) const;
- /// Gets the normal maximum speed, as reported in the 1.6.1+ protocol, in the protocol units
+ /// Gets the normal relative maximum speed
double GetNormalMaxSpeed(void) const { return m_NormalMaxSpeed; }
- /// Gets the sprinting maximum speed, as reported in the 1.6.1+ protocol, in the protocol units
+ /// Gets the sprinting relative maximum speed
double GetSprintingMaxSpeed(void) const { return m_SprintingMaxSpeed; }
/// Sets the normal maximum speed, as reported in the 1.6.1+ protocol. Sends the update to player, if needed.
@@ -432,10 +432,14 @@ protected:
cSlotNums m_InventoryPaintSlots;
- /// Max speed, in ENTITY_PROPERTIES packet's units, when the player is walking. 0.1 by default
+ /** Max speed, relative to the game default.
+ 1 means regular speed, 2 means twice as fast, 0.5 means half-speed.
+ Default value is 1. */
double m_NormalMaxSpeed;
- /// Max speed, in ENTITY_PROPERTIES packet's units, when the player is sprinting. 0.13 by default
+ /** Max speed, relative to the game default max speed.
+ 1 means regular speed, 2 means twice as fast, 0.5 means half-speed.
+ Default value is 1.3 */
double m_SprintingMaxSpeed;
bool m_IsCrouched;
diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp
index f6ec0a199..ecb24254f 100644
--- a/src/Protocol/Protocol16x.cpp
+++ b/src/Protocol/Protocol16x.cpp
@@ -135,7 +135,7 @@ void cProtocol161::SendPlayerMaxSpeed(void)
WriteInt(m_Client->GetPlayer()->GetUniqueID());
WriteInt(1);
WriteString("generic.movementSpeed");
- WriteDouble(m_Client->GetPlayer()->GetMaxSpeed());
+ WriteDouble(0.1 * m_Client->GetPlayer()->GetMaxSpeed());
Flush();
}
@@ -267,7 +267,7 @@ void cProtocol162::SendPlayerMaxSpeed(void)
WriteInt(m_Client->GetPlayer()->GetUniqueID());
WriteInt(1);
WriteString("generic.movementSpeed");
- WriteDouble(m_Client->GetPlayer()->GetMaxSpeed());
+ WriteDouble(0.1 * m_Client->GetPlayer()->GetMaxSpeed());
WriteShort(0);
Flush();
}
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 6fc344eaf..21c77e903 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -689,7 +689,7 @@ void cProtocol172::SendPlayerAbilities(void)
Pkt.WriteByte(Flags);
// TODO: Pkt.WriteFloat(m_Client->GetPlayer()->GetMaxFlyingSpeed());
Pkt.WriteFloat(0.05f);
- Pkt.WriteFloat((float)m_Client->GetPlayer()->GetMaxSpeed());
+ Pkt.WriteFloat((float)(0.1 * m_Client->GetPlayer()->GetMaxSpeed()));
}
@@ -743,13 +743,14 @@ void cProtocol172::SendPlayerMaxSpeed(void)
Pkt.WriteInt(m_Client->GetPlayer()->GetUniqueID());
Pkt.WriteInt(1); // Count
Pkt.WriteString("generic.movementSpeed");
- Pkt.WriteDouble(0.1);
+ // The default game speed is 0.1, multiply that value by the relative speed:
+ Pkt.WriteDouble(0.1 * m_Client->GetPlayer()->GetNormalMaxSpeed());
if (m_Client->GetPlayer()->IsSprinting())
{
Pkt.WriteShort(1); // Modifier count
Pkt.WriteInt64(0x662a6b8dda3e4c1c);
Pkt.WriteInt64(0x881396ea6097278d); // UUID of the modifier
- Pkt.WriteDouble(0.3);
+ Pkt.WriteDouble(m_Client->GetPlayer()->GetSprintingMaxSpeed() - m_Client->GetPlayer()->GetNormalMaxSpeed());
Pkt.WriteByte(2);
}
else