1
0

Ignore dead movement (#5292)

* Ignore player updates from dead players #5289

* move the condition down a bit, add parentheses

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
This commit is contained in:
Ethan Jones 2021-09-16 01:31:16 -06:00 committed by GitHub
parent 9712c5507c
commit 3b47eaadb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1498,12 +1498,6 @@ void cClientHandle::HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsO
void cClientHandle::HandlePlayerMove(double a_PosX, double a_PosY, double a_PosZ, bool a_IsOnGround)
{
if (m_Player->IsFrozen())
{
// Ignore client-side updates if the player is frozen:
return;
}
const Vector3d NewPosition(a_PosX, a_PosY, a_PosZ);
const Vector3d OldPosition = GetPlayer()->GetPosition();
const auto PreviousIsOnGround = GetPlayer()->IsOnGround();
@ -1526,6 +1520,13 @@ void cClientHandle::HandlePlayerMove(double a_PosX, double a_PosY, double a_PosZ
#pragma clang diagnostic pop
#endif
if (m_Player->IsFrozen() || (m_Player->GetHealth() <= 0))
{
// "Repair" if the client tries to move while frozen or dead:
SendPlayerMoveLook();
return;
}
// If the player has moved too far, "repair" them:
if ((OldPosition - NewPosition).SqrLength() > 100 * 100)
{