From 1247f7270b9ae664d373aa0c6d85e4c1e537a977 Mon Sep 17 00:00:00 2001
From: Juhu <5894800-Juhu_@users.noreply.gitlab.com>
Date: Tue, 23 Jun 2020 16:39:03 +0200
Subject: [PATCH] strafehud: remove timeout value for left/right strafe again
 as it is buggy and unnecessary

---
 _hud_common.cfg                     |  3 +--
 qcsrc/client/autocvars.qh           |  3 +--
 qcsrc/client/hud/panel/strafehud.qc | 26 ++++----------------------
 3 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/_hud_common.cfg b/_hud_common.cfg
index 37be5ca36..94bba1ba4 100644
--- a/_hud_common.cfg
+++ b/_hud_common.cfg
@@ -146,8 +146,7 @@ seta hud_panel_strafehud_direction_length "0.0225" "direction indicator length r
 seta hud_panel_strafehud_timeout_air "0" "time after take off before changing strafehud mode (prevents flickering on slick ramps)"
 seta hud_panel_strafehud_timeout_ground "0.03333333" "time after landing before changing strafehud mode (prevents flickering on regular strafe turns)"
 seta hud_panel_strafehud_timeout_strafe "0.1" "time after releasing the strafe keys before changing mode (prevents flickering when switching between left/right strafe turning)"
-seta hud_panel_strafehud_timeout_fwd_bkwd "0.5" "time it takes until direction changes (forward or backward movement) are detected"
-seta hud_panel_strafehud_timeout_left_right "0" "time it takes until direction changes (left or right movement) are detected"
+seta hud_panel_strafehud_timeout_direction "0.5" "time it takes until direction changes (forward or backward movement) are detected"
 seta hud_panel_strafehud_unstyled "0" "don't apply any progressbar styles to the strafehud"
 seta hud_panel_strafehud_antiflicker_angle "0.01" "how many degrees from 0° to 180° the hud ignores if it could cause visual disturbances otherwise"
 seta hud_panel_strafehud_antiflicker_speed "0.0001" "how many qu/s the hud ignores if it could cause visual disturbances otherwise"
diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh
index cf97f8b42..018672f44 100644
--- a/qcsrc/client/autocvars.qh
+++ b/qcsrc/client/autocvars.qh
@@ -344,8 +344,7 @@ float autocvar_hud_panel_strafehud_direction_length = 0.0225;
 float autocvar_hud_panel_strafehud_timeout_air = 0;
 float autocvar_hud_panel_strafehud_timeout_ground = 0.03333333;
 float autocvar_hud_panel_strafehud_timeout_strafe = 0.1;
-float autocvar_hud_panel_strafehud_timeout_fwd_bkwd = 0.5;
-float autocvar_hud_panel_strafehud_timeout_left_right = 0;
+float autocvar_hud_panel_strafehud_timeout_direction = 0.5;
 bool autocvar_hud_panel_strafehud_unstyled = false;
 float autocvar_hud_panel_strafehud_antiflicker_angle = 0.01;
 float autocvar_hud_panel_strafehud_antiflicker_speed = 0.0001;
diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc
index 890cc2651..479cb2b18 100644
--- a/qcsrc/client/hud/panel/strafehud.qc
+++ b/qcsrc/client/hud/panel/strafehud.qc
@@ -21,9 +21,6 @@ void HUD_StrafeHUD_Export(int fh)
 bool fwd = true;
 bool state_fwd = true;
 bool state_fwd_prev = true;
-int direction = 0;
-bool state_direction = true;
-bool state_direction_prev = true;
 float hidden_width;
 float demo_angle = -37;
 float demo_direction = 1;
@@ -31,7 +28,6 @@ float demo_time = 0;
 float state_onground_time = 0;
 float state_strafekeys_time = 0;
 float state_fwd_time = 0;
-float state_direction_time = 0;
 bool state_onground = false;
 bool state_strafekeys = false;
 bool turn = false;
@@ -99,6 +95,7 @@ void HUD_StrafeHUD()
         float  vel_angle                     = vectoangles(strafeplayer.velocity).y;
         float  view_angle                    = view_angles.y + 180;
         float  angle;
+        int    direction;
         vector movement                      = PHYS_INPUT_MOVEVALUES(strafeplayer);
         int    keys                          = STAT(PRESSED_KEYS);
         int    keys_fwd;
@@ -349,7 +346,7 @@ void HUD_StrafeHUD()
                 }
                 state_fwd_prev = state_fwd;
 
-                if((time - state_fwd_time) >= autocvar_hud_panel_strafehud_timeout_fwd_bkwd || speed < maxspeed) // timeout when changing between forwards and backwards movement
+                if((time - state_fwd_time) >= autocvar_hud_panel_strafehud_timeout_direction || speed < maxspeed) // timeout when changing between forwards and backwards movement
                 {
                     fwd = state_fwd;
                 }
@@ -405,26 +402,11 @@ void HUD_StrafeHUD()
         // determine whether the player is strafing left or right
         if(wishangle != 0)
         {
-            state_direction = wishangle > 0 ? 1 : -1;
+            direction = wishangle > 0 ? 1 : -1;
         }
         else
         {
-            state_direction = (angle > antiflicker_angle && angle < (180 - antiflicker_angle)) ? 1 : (angle < -antiflicker_angle && angle > (-180 + antiflicker_angle)) ? -1 : 0;
-        }
-
-        if(state_direction_prev != state_direction)
-        {
-            state_direction_time = time;
-        }
-        state_direction_prev = state_direction;
-
-        if((time - state_direction_time) >= autocvar_hud_panel_strafehud_timeout_left_right || speed < maxspeed || direction == 0) // timeout when changing between left and right movement
-        {
-            direction = state_direction;
-        }
-        if(direction != 0)
-        {
-            wishangle = direction * fabs(wishangle);
+            direction = (angle > antiflicker_angle && angle < (180 - antiflicker_angle)) ? 1 : (angle < -antiflicker_angle && angle > (-180 + antiflicker_angle)) ? -1 : 0;
         }
 
         // decelerating at this angle
-- 
2.39.5