Merge pull request #1019 from mc-server/cPlayerSetSpeed
cPlayer set speed
This commit is contained in:
commit
c684812b30
@ -179,14 +179,9 @@ void cEntity::WrapRotation(void)
|
|||||||
|
|
||||||
void cEntity::WrapSpeed(void)
|
void cEntity::WrapSpeed(void)
|
||||||
{
|
{
|
||||||
// There shoudn't be a need for flipping the flag on because this function is called
|
m_Speed.x = Clamp(m_Speed.x, -78.0, 78.0);
|
||||||
// after any update, so the flag is already turned on
|
m_Speed.y = Clamp(m_Speed.y, -78.0, 78.0);
|
||||||
if (m_Speed.x > 78.0f) m_Speed.x = 78.0f;
|
m_Speed.z = Clamp(m_Speed.z, -78.0, 78.0);
|
||||||
else if (m_Speed.x < -78.0f) m_Speed.x = -78.0f;
|
|
||||||
if (m_Speed.y > 78.0f) m_Speed.y = 78.0f;
|
|
||||||
else if (m_Speed.y < -78.0f) m_Speed.y = -78.0f;
|
|
||||||
if (m_Speed.z > 78.0f) m_Speed.z = 78.0f;
|
|
||||||
else if (m_Speed.z < -78.0f) m_Speed.z = -78.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1076,6 +1071,17 @@ void cEntity::SetSwimState(cChunk & a_Chunk)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cEntity::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
|
||||||
|
{
|
||||||
|
m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ);
|
||||||
|
|
||||||
|
WrapSpeed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cEntity::HandleAir(void)
|
void cEntity::HandleAir(void)
|
||||||
{
|
{
|
||||||
// Ref.: http://www.minecraftwiki.net/wiki/Chunk_format
|
// Ref.: http://www.minecraftwiki.net/wiki/Chunk_format
|
||||||
@ -1428,9 +1434,7 @@ void cEntity::SetRoll(double a_Roll)
|
|||||||
|
|
||||||
void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
|
void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
|
||||||
{
|
{
|
||||||
m_Speed.Set(a_SpeedX, a_SpeedY, a_SpeedZ);
|
DoSetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ);
|
||||||
|
|
||||||
WrapSpeed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1438,9 +1442,7 @@ void cEntity::SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
|
|||||||
|
|
||||||
void cEntity::SetSpeedX(double a_SpeedX)
|
void cEntity::SetSpeedX(double a_SpeedX)
|
||||||
{
|
{
|
||||||
m_Speed.x = a_SpeedX;
|
SetSpeed(a_SpeedX, m_Speed.y, m_Speed.z);
|
||||||
|
|
||||||
WrapSpeed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1448,9 +1450,7 @@ void cEntity::SetSpeedX(double a_SpeedX)
|
|||||||
|
|
||||||
void cEntity::SetSpeedY(double a_SpeedY)
|
void cEntity::SetSpeedY(double a_SpeedY)
|
||||||
{
|
{
|
||||||
m_Speed.y = a_SpeedY;
|
SetSpeed(m_Speed.x, a_SpeedY, m_Speed.z);
|
||||||
|
|
||||||
WrapSpeed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1458,9 +1458,7 @@ void cEntity::SetSpeedY(double a_SpeedY)
|
|||||||
|
|
||||||
void cEntity::SetSpeedZ(double a_SpeedZ)
|
void cEntity::SetSpeedZ(double a_SpeedZ)
|
||||||
{
|
{
|
||||||
m_Speed.z = a_SpeedZ;
|
SetSpeed(m_Speed.x, m_Speed.y, a_SpeedZ);
|
||||||
|
|
||||||
WrapSpeed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,11 +215,22 @@ public:
|
|||||||
void SetYaw (double a_Yaw); // In degrees, normalizes to [-180, +180)
|
void SetYaw (double a_Yaw); // In degrees, normalizes to [-180, +180)
|
||||||
void SetPitch (double a_Pitch); // 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 SetRoll (double a_Roll); // In degrees, normalizes to [-180, +180)
|
||||||
void SetSpeed (double a_SpeedX, double a_SpeedY, double a_SpeedZ);
|
|
||||||
void SetSpeed (const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); }
|
/** Sets the speed of the entity, measured in m / sec */
|
||||||
void SetSpeedX (double a_SpeedX);
|
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
|
||||||
void SetSpeedY (double a_SpeedY);
|
|
||||||
void SetSpeedZ (double a_SpeedZ);
|
/** Sets the speed of the entity, measured in m / sec */
|
||||||
|
void SetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed.x, a_Speed.y, a_Speed.z); }
|
||||||
|
|
||||||
|
/** Sets the speed in the X axis, leaving the other speed components intact. Measured in m / sec. */
|
||||||
|
void SetSpeedX(double a_SpeedX);
|
||||||
|
|
||||||
|
/** Sets the speed in the Y axis, leaving the other speed components intact. Measured in m / sec. */
|
||||||
|
void SetSpeedY(double a_SpeedY);
|
||||||
|
|
||||||
|
/** Sets the speed in the Z axis, leaving the other speed components intact. Measured in m / sec. */
|
||||||
|
void SetSpeedZ(double a_SpeedZ);
|
||||||
|
|
||||||
void SetWidth (double a_Width);
|
void SetWidth (double a_Width);
|
||||||
|
|
||||||
void AddPosX (double a_AddPosX);
|
void AddPosX (double a_AddPosX);
|
||||||
@ -429,6 +440,9 @@ protected:
|
|||||||
static cCriticalSection m_CSCount;
|
static cCriticalSection m_CSCount;
|
||||||
static int m_EntityCount;
|
static int m_EntityCount;
|
||||||
|
|
||||||
|
/** Measured in meter/second (m/s) */
|
||||||
|
Vector3d m_Speed;
|
||||||
|
|
||||||
int m_UniqueID;
|
int m_UniqueID;
|
||||||
|
|
||||||
int m_Health;
|
int m_Health;
|
||||||
@ -486,11 +500,15 @@ protected:
|
|||||||
/// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void.
|
/// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void.
|
||||||
int m_TicksSinceLastVoidDamage;
|
int m_TicksSinceLastVoidDamage;
|
||||||
|
|
||||||
|
|
||||||
|
/** Does the actual speed-setting. The default implementation just sets the member variable value;
|
||||||
|
overrides can provide further processing, such as forcing players to move at the given speed. */
|
||||||
|
virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ);
|
||||||
|
|
||||||
virtual void Destroyed(void) {} // Called after the entity has been destroyed
|
virtual void Destroyed(void) {} // Called after the entity has been destroyed
|
||||||
|
|
||||||
/** Called in each tick to handle air-related processing i.e. drowning */
|
/** Called in each tick to handle air-related processing i.e. drowning */
|
||||||
virtual void HandleAir();
|
virtual void HandleAir(void);
|
||||||
|
|
||||||
/** Called once per tick to set IsSwimming and IsSubmerged */
|
/** Called once per tick to set IsSwimming and IsSubmerged */
|
||||||
virtual void SetSwimState(cChunk & a_Chunk);
|
virtual void SetSwimState(cChunk & a_Chunk);
|
||||||
@ -506,9 +524,6 @@ private:
|
|||||||
/** Measured in degrees, [-180, +180) */
|
/** Measured in degrees, [-180, +180) */
|
||||||
double m_HeadYaw;
|
double m_HeadYaw;
|
||||||
|
|
||||||
/** Measured in meter/second (m/s) */
|
|
||||||
Vector3d m_Speed;
|
|
||||||
|
|
||||||
/** Measured in degrees, [-180, +180) */
|
/** Measured in degrees, [-180, +180) */
|
||||||
Vector3d m_Rot;
|
Vector3d m_Rot;
|
||||||
|
|
||||||
|
@ -1257,6 +1257,17 @@ Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const
|
|||||||
void cPlayer::ForceSetSpeed(const Vector3d & a_Speed)
|
void cPlayer::ForceSetSpeed(const Vector3d & a_Speed)
|
||||||
{
|
{
|
||||||
SetSpeed(a_Speed);
|
SetSpeed(a_Speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cPlayer::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
|
||||||
|
{
|
||||||
|
super::DoSetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ);
|
||||||
|
|
||||||
|
// Send the speed to the client so he actualy moves
|
||||||
m_ClientHandle->SendEntityVelocity(*this);
|
m_ClientHandle->SendEntityVelocity(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +194,8 @@ public:
|
|||||||
// Sets the current gamemode, doesn't check validity, doesn't send update packets to client
|
// Sets the current gamemode, doesn't check validity, doesn't send update packets to client
|
||||||
void LoginSetGameMode(eGameMode a_GameMode);
|
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
|
void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export
|
||||||
|
|
||||||
/** Tries to move to a new position, with attachment-related checks (y == -999) */
|
/** Tries to move to a new position, with attachment-related checks (y == -999) */
|
||||||
@ -512,6 +513,9 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Sets the speed and sends it to the client, so that they are forced to move so. */
|
||||||
|
virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override;
|
||||||
|
|
||||||
void ResolvePermissions(void);
|
void ResolvePermissions(void);
|
||||||
void ResolveGroups(void);
|
void ResolveGroups(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user