From 3b47eaadb85ac42b70d35d03d919181830b40a41 Mon Sep 17 00:00:00 2001
From: Ethan Jones <ethan@yasfu.net>
Date: Thu, 16 Sep 2021 01:31:16 -0600
Subject: [PATCH] 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>
---
 src/ClientHandle.cpp | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index b356a649b..cf70f870e 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -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)
 	{