summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Entities/Entity.h24
-rw-r--r--src/Entities/Player.cpp65
-rw-r--r--src/Entities/Player.h11
3 files changed, 92 insertions, 8 deletions
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 85ad42d54..fed856b30 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -215,11 +215,24 @@ public:
void SetYaw (double a_Yaw); // In degrees, normalizes to [-180, +180)
void SetPitch (double a_Pitch); // In degrees, normalizes to [-180, +180)
void SetRoll (double a_Roll); // In degrees, normalizes to [-180, +180)
- void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ);
+ // tolua_end
+
+ /** Measured in meter/second (m/s) */
+ Vector3d m_Speed;
+
+ // tolua_begin
+ /** Sets the speed of the entity and moves them in the given speed. */
+ virtual void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ);
+ /** Sets the speed of the entity and moves them in the given speed. */
void SetSpeed (const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); }
- void SetSpeedX (double a_SpeedX);
- void SetSpeedY (double a_SpeedY);
- void SetSpeedZ (double a_SpeedZ);
+
+ /** Sets the speed for the X axis */
+ virtual void SetSpeedX (double a_SpeedX);
+ /** Sets the speed for the Y axis */
+ virtual void SetSpeedY (double a_SpeedY);
+ /** Sets the speed for the Z axis */
+ virtual void SetSpeedZ (double a_SpeedZ);
+
void SetWidth (double a_Width);
void AddPosX (double a_AddPosX);
@@ -506,9 +519,6 @@ private:
/** Measured in degrees, [-180, +180) */
double m_HeadYaw;
- /** Measured in meter/second (m/s) */
- Vector3d m_Speed;
-
/** Measured in degrees, [-180, +180) */
Vector3d m_Rot;
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index feb09b5d2..33b339f8e 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1264,6 +1264,71 @@ void cPlayer::ForceSetSpeed(const Vector3d & a_Speed)
+void cPlayer::SetSpeed(const Vector3d & a_Speed)
+{
+ m_Speed.Set(a_Speed.x, a_Speed.y, a_Speed.z);
+ WrapSpeed();
+
+ // Send the speed to the client so he actualy moves
+ m_ClientHandle->SendEntityVelocity(*this);
+}
+
+
+
+
+
+void cPlayer::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
+{
+ m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ);
+ WrapSpeed();
+
+ // Send the speed to the client so he actualy moves
+ m_ClientHandle->SendEntityVelocity(*this);
+}
+
+
+
+
+
+void cPlayer::SetSpeedX(double a_SpeedX)
+{
+ m_Speed.x = a_SpeedX;
+ WrapSpeed();
+
+ // Send the speed to the client so he actualy moves
+ m_ClientHandle->SendEntityVelocity(*this);
+}
+
+
+
+
+
+void cPlayer::SetSpeedY(double a_SpeedY)
+{
+ m_Speed.y = a_SpeedY;
+ WrapSpeed();
+
+ // Send the speed to the client so he actualy moves
+ m_ClientHandle->SendEntityVelocity(*this);
+}
+
+
+
+
+
+void cPlayer::SetSpeedZ(double a_SpeedZ)
+{
+ m_Speed.z = a_SpeedZ;
+ WrapSpeed();
+
+ // Send the speed to the client so he actualy moves
+ m_ClientHandle->SendEntityVelocity(*this);
+}
+
+
+
+
+
void cPlayer::MoveTo( const Vector3d & a_NewPos )
{
if ((a_NewPos.y < -990) && (GetPosY() > -100))
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 83b9ad593..165963e6e 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -194,9 +194,18 @@ public:
// Sets the current gamemode, doesn't check validity, doesn't send update packets to client
void LoginSetGameMode(eGameMode a_GameMode);
- /** Forces the player to move in the given direction. */
+ /** Forces the player to move in the given direction.
+ * @deprecated Use SetSpeed instead.
+ */
void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export
+ /** Sets the speed of the player and moves them in the given speed. */
+ void SetSpeed (const Vector3d & a_Speed);
+ virtual void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ) override;
+ virtual void SetSpeedX (double a_SpeedX) override;
+ virtual void SetSpeedY (double a_SpeedY) override;
+ virtual void SetSpeedZ (double a_SpeedZ) override;
+
/** Tries to move to a new position, with attachment-related checks (y == -999) */
void MoveTo(const Vector3d & a_NewPos); // tolua_export