From 7c139f0e281676329e1a31a70c98c23a335b3e9c Mon Sep 17 00:00:00 2001 From: Dan Peavey Date: Fri, 6 Nov 2026 18:39:26 -0800 Subject: [PATCH 1/2] Stop dead players making footstep sounds Players could hear footsteps from a body for up to 10 seconds after killing someone who was running, until the dead player became an observer. Since #2151, CNEO_Player::IsMakingFootstepSounds takes its speed from GetAbsVelocity, and it never checked that the player was alive. Other clients rebuild that velocity only on updates that keep the same interpolation frame. While a player is dead, CHL2_Player::PreThink runs PlayerDeathThink on every command, and that increments the interpolation frame each time, so other clients kept the speed the player died with. IsMakingFootstepSounds now returns false once m_lifeState is no longer LIFE_ALIVE. It reads m_lifeState because IsAlive is not const. The check is shared, so the server and every client make the same step decision. The check sits after the out parameters are written, as UpdateStepSound reads them even for a silent step. The water entry sound also asks IsMakingFootstepSounds, so a dead player no longer plays Player.Wade. Corpse impact and scrape sounds come from ragdoll physics and are unaffected. --- src/game/shared/neo/neo_player_shared.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/game/shared/neo/neo_player_shared.cpp b/src/game/shared/neo/neo_player_shared.cpp index 124ac963e8..540bd74256 100644 --- a/src/game/shared/neo/neo_player_shared.cpp +++ b/src/game/shared/neo/neo_player_shared.cpp @@ -401,6 +401,11 @@ bool CNEO_Player::IsMakingFootstepSounds(float* pVelRun, float* pSpeed, int* pLa GetStepSoundVelocities(&velwalk, &velrun); if (pVelRun) *pVelRun = velrun; + // Other clients rebuild a dead player's velocity from origin changes, so it can read as moving for a moment after + // death. Checked after the out parameters are written, as UpdateStepSound reads them either way + if (m_lifeState != LIFE_ALIVE) + return false; + bool onground = (GetFlags() & FL_ONGROUND); bool movingalongground = (groundspeed > 0.0001f); // Below this nothing plays, on a ladder or off. It catches drift that is not movement at all, such as being From 8d082760cd8da1a187b9994931139cf08772bcbd Mon Sep 17 00:00:00 2001 From: Dan Peavey Date: Thu, 12 Nov 2026 20:15:22 -0800 Subject: [PATCH 2/2] Write footstep out parameters before the early returns UpdateStepSound passes uninitialized locals to IsMakingFootstepSounds and reads them back even for a silent step, to set the step timer and pick the ladder branch. Before #2151 the frozen, freeze time, noclip or observer and sv_footsteps checks returned from UpdateStepSound itself, so those locals were never read. Since #2151 they return false from IsMakingFootstepSounds before the out parameters are written, and UpdateStepSound reads whatever was on the stack. The out parameters are now written first. The life check moves up to join the other early returns, so a dead player skips the rest of the step decision. --- src/game/shared/neo/neo_player_shared.cpp | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/game/shared/neo/neo_player_shared.cpp b/src/game/shared/neo/neo_player_shared.cpp index 540bd74256..df79afb082 100644 --- a/src/game/shared/neo/neo_player_shared.cpp +++ b/src/game/shared/neo/neo_player_shared.cpp @@ -377,6 +377,21 @@ namespace bool CNEO_Player::IsMakingFootstepSounds(float* pVelRun, float* pSpeed, int* pLadder) const { + // UpdateStepSound reads the out parameters even for a silent step, so they are written before any early return + const Vector& absVel = GetAbsVelocity(); + const float speed = absVel.Length(); + if (pSpeed) *pSpeed = speed; + const bool isOnLadder = (GetMoveType() == MOVETYPE_LADDER); + if (pLadder) *pLadder = isOnLadder; + + float velwalk, velrun; + GetStepSoundVelocities(&velwalk, &velrun); + if (pVelRun) *pVelRun = velrun; + + // Dead players make no footsteps. Other clients keep the speed a player died with until that player is an observer + if (m_lifeState != LIFE_ALIVE) + return false; + if (GetFlags() & (FL_FROZEN|FL_ATCONTROLS)) return false; @@ -390,22 +405,7 @@ bool CNEO_Player::IsMakingFootstepSounds(float* pVelRun, float* pSpeed, int* pLa if (!sv_footsteps.GetFloat()) return false; - const Vector& absVel = GetAbsVelocity(); - const float speed = absVel.Length(); - if (pSpeed) *pSpeed = speed; const float groundspeed = absVel.AsVector2D().Length(); - const bool isOnLadder = (GetMoveType() == MOVETYPE_LADDER); - if (pLadder) *pLadder = isOnLadder; - - float velwalk, velrun; - GetStepSoundVelocities(&velwalk, &velrun); - if (pVelRun) *pVelRun = velrun; - - // Other clients rebuild a dead player's velocity from origin changes, so it can read as moving for a moment after - // death. Checked after the out parameters are written, as UpdateStepSound reads them either way - if (m_lifeState != LIFE_ALIVE) - return false; - bool onground = (GetFlags() & FL_ONGROUND); bool movingalongground = (groundspeed > 0.0001f); // Below this nothing plays, on a ladder or off. It catches drift that is not movement at all, such as being