From 0bd2c5f24ed786c47039222b846a3bf8a006ff4e Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Sun, 12 Jan 2025 14:58:43 +0100 Subject: [PATCH] strafehud: the correct friction value is now used if you are on a non-slick surface while PHYS_FRICTION is zero, reported by k9er --- qcsrc/client/hud/panel/strafehud.qc | 18 ++++++------------ qcsrc/client/hud/panel/strafehud/extra.qc | 4 ++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 45e7bad2b..a1375ee54 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -96,17 +96,10 @@ void HUD_StrafeHUD() static bool onslick_last = false; if(onground) { - if(PHYS_FRICTION(strafeplayer) == 0) - { - onslick = true; - } - else // do not use IS_ONSLICK(), it only works for the local player and only if client prediction is enabled - { - trace_dphitq3surfaceflags = 0; - tracebox(strafeplayer.origin, strafeplayer.mins, strafeplayer.maxs, strafeplayer.origin - '0 0 1', MOVE_NOMONSTERS, strafeplayer); - onslick = trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK; - } - real_onslick = onslick; + // do not use IS_ONSLICK(), it only works for the local player and only if client prediction is enabled + trace_dphitq3surfaceflags = 0; + tracebox(strafeplayer.origin, strafeplayer.mins, strafeplayer.maxs, strafeplayer.origin - '0 0 1', MOVE_NOMONSTERS, strafeplayer); + real_onslick = onslick = trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK; onground_lasttime = time; onslick_last = onslick; @@ -547,7 +540,8 @@ void HUD_StrafeHUD() float text_offset_top; float text_offset_bottom; - text_offset_top = text_offset_bottom = StrafeHUD_DrawSlickDetector(strafeplayer, real_onslick); + bool all_slick = PHYS_FRICTION(strafeplayer) == 0; + text_offset_top = text_offset_bottom = StrafeHUD_DrawSlickDetector(strafeplayer, all_slick && real_onground ? true : real_onslick); if(autocvar_hud_panel_strafehud_direction) StrafeHUD_DrawDirectionIndicator(direction, opposite_direction, fwd); diff --git a/qcsrc/client/hud/panel/strafehud/extra.qc b/qcsrc/client/hud/panel/strafehud/extra.qc index 356303e89..0d12a035f 100644 --- a/qcsrc/client/hud/panel/strafehud/extra.qc +++ b/qcsrc/client/hud/panel/strafehud/extra.qc @@ -20,7 +20,7 @@ // slick detector // scans for slick in every direction downwards from the player's feet // may cause performance issues on slower machines -float StrafeHUD_DrawSlickDetector(entity e, bool onslick) +float StrafeHUD_DrawSlickDetector(entity e, bool already_detected) { float slickdetector_height = bound(0, autocvar_hud_panel_strafehud_slickdetector_height, 1); slickdetector_height *= panel_size.y; @@ -37,7 +37,7 @@ float StrafeHUD_DrawSlickDetector(entity e, bool onslick) slicksteps = 90 * DEG2RAD / 2 ** slicksteps; // don't need to traceline if already touching slick - slickdetected = onslick; + slickdetected = already_detected; // coordinates at the bottom center of the player bbox vector traceorigin = e.origin + eZ * e.mins.z; -- 2.39.5