summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-05-26 16:38:14 +0200
committermadmaxoft <github@xoft.cz>2014-05-26 16:38:39 +0200
commit6449b5d11b5a07183812189d5eead0734f9dc191 (patch)
tree78bb47715b07831fd95067f04a3df46386c6d1e5
parentMinor fixes. (diff)
downloadcuberite-6449b5d11b5a07183812189d5eead0734f9dc191.tar
cuberite-6449b5d11b5a07183812189d5eead0734f9dc191.tar.gz
cuberite-6449b5d11b5a07183812189d5eead0734f9dc191.tar.bz2
cuberite-6449b5d11b5a07183812189d5eead0734f9dc191.tar.lz
cuberite-6449b5d11b5a07183812189d5eead0734f9dc191.tar.xz
cuberite-6449b5d11b5a07183812189d5eead0734f9dc191.tar.zst
cuberite-6449b5d11b5a07183812189d5eead0734f9dc191.zip
-rw-r--r--src/ClientHandle.cpp74
-rw-r--r--src/ClientHandle.h2
2 files changed, 17 insertions, 59 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index e7537d74d..83b21ae3c 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -582,37 +582,16 @@ void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ,
return;
}
- if (m_Player->GetHealth() <= 0)
- {
- // The player is dead. He can't move :D
- return;
- }
-
- if (std::isnan(a_PosX) || std::isnan(a_PosY) || std::isnan(a_PosZ) || std::isnan(a_Stance))
- {
- LOGWARN("%s was caught trying to crash the server with an invalid position.", m_Player->GetName().c_str());
- Kick("Nope!");
- return;
- }
-
- // Invalid stance check
- if (!m_Player->IsInBed())
- {
- double Difference = a_Stance - a_PosY;
- if ((Difference > 1.65) || (Difference < 1.0))
- {
- Kick("Illegal stance!");
- LOGWARN("%s had an illegal stance: %f", m_Player->GetName().c_str(), a_Stance);
- return;
- }
- }
-
- if ((std::abs(a_PosX) > 32000000.0) || (std::abs(a_PosZ) > 32000000.0))
+ /*
+ // TODO: Invalid stance check
+ if ((a_PosY >= a_Stance) || (a_Stance > a_PosY + 1.65))
{
- Kick("Illegal position!");
+ LOGD("Invalid stance");
+ SendPlayerMoveLook();
return;
}
-
+ */
+
// If the player has moved too far, "repair" them:
Vector3d Pos(a_PosX, a_PosY, a_PosZ);
if ((m_Player->GetPosition() - Pos).SqrLength() > 100 * 100)
@@ -1410,7 +1389,7 @@ void cClientHandle::HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsO
-void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Yaw, float a_Pitch, bool a_IsOnGround)
+void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround)
{
if ((m_Player == NULL) || (m_State != csPlaying))
{
@@ -1418,42 +1397,21 @@ void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_
return;
}
- if (m_Player->GetHealth() <= 0)
- {
- // The player is dead. He can't move :D
- return;
- }
-
- if (std::isnan(a_PosX) || std::isnan(a_PosY) || std::isnan(a_PosZ) || std::isnan(a_Stance))
- {
- LOGWARN("%s was caught trying to crash the server with an invalid position.", m_Player->GetName().c_str());
- Kick("Nope!");
- return;
- }
-
- // Invalid stance check
- if (!m_Player->IsInBed())
- {
- double Difference = a_Stance - a_PosY;
- if ((Difference > 1.65) || (Difference < 1.0))
- {
- Kick("Illegal stance!");
- LOGWARN("%s had an illegal stance: %f", m_Player->GetName().c_str(), a_Stance);
- return;
- }
- }
-
- if ((std::abs(a_PosX) > 32000000.0) || (std::abs(a_PosZ) > 32000000.0))
+ /*
+ // TODO: Invalid stance check
+ if ((a_PosY >= a_Stance) || (a_Stance > a_PosY + 1.65))
{
- Kick("Illegal position!");
+ LOGD("Invalid stance");
+ SendPlayerMoveLook();
return;
}
+ */
m_Player->MoveTo(Vector3d(a_PosX, a_PosY, a_PosZ));
m_Player->SetStance (a_Stance);
m_Player->SetTouchGround(a_IsOnGround);
- m_Player->SetHeadYaw (a_Yaw);
- m_Player->SetYaw (a_Yaw);
+ m_Player->SetHeadYaw (a_Rotation);
+ m_Player->SetYaw (a_Rotation);
m_Player->SetPitch (a_Pitch);
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 04d93e2c0..659c67658 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -225,7 +225,7 @@ public:
void HandlePing (void);
void HandlePlayerAbilities (bool a_CanFly, bool a_IsFlying, float FlyingSpeed, float WalkingSpeed);
void HandlePlayerLook (float a_Rotation, float a_Pitch, bool a_IsOnGround);
- void HandlePlayerMoveLook (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Yaw, float a_Pitch, bool a_IsOnGround); // While m_bPositionConfirmed (normal gameplay)
+ void HandlePlayerMoveLook (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround); // While m_bPositionConfirmed (normal gameplay)
void HandlePlayerPos (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround);
void HandlePluginMessage (const AString & a_Channel, const AString & a_Message);
void HandleRespawn (void);