From 3a24956e188f830523df02f21a9681f5bff72c8c Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Mon, 9 Sep 2024 18:49:55 +0200 Subject: [PATCH] strafehud: clean up mess from previous commits, minor refactoring --- qcsrc/client/hud/panel/strafehud.qc | 17 +++++++---------- qcsrc/client/hud/panel/strafehud/core.qc | 23 ++++++++++------------- qcsrc/client/hud/panel/strafehud/core.qh | 4 +--- qcsrc/client/hud/panel/strafehud/util.qc | 13 +------------ qcsrc/client/hud/panel/strafehud/util.qh | 1 - 5 files changed, 19 insertions(+), 39 deletions(-) diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 5f72f4627..63cdef577 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -376,20 +376,17 @@ void HUD_StrafeHUD() } // shift hud if operating in view angle centered mode - float shift_angle = 0; + float shiftangle = 0; if(mode == STRAFEHUD_MODE_VIEW_CENTERED) { - shift_angle = -angle; - bestangle += shift_angle; - changeangle += shift_angle; - opposite_bestangle += shift_angle; - opposite_changeangle += shift_angle; + shiftangle = -angle; + bestangle += shiftangle; + changeangle += shiftangle; + opposite_bestangle += shiftangle; + opposite_changeangle += shiftangle; } - StrafeHUD_DrawStrafeMeter( - speed, bestspeed, frictionspeed, shift_angle, wishangle, changeangle, bestangle, - absolute_bestangle, absolute_prebestangle, opposite_bestangle, opposite_changeangle, - moving, opposite_direction, direction, hudangle); + StrafeHUD_DrawStrafeMeter(shiftangle, wishangle, absolute_bestangle, absolute_prebestangle, moving, hudangle); float text_offset_top; float text_offset_bottom; diff --git a/qcsrc/client/hud/panel/strafehud/core.qc b/qcsrc/client/hud/panel/strafehud/core.qc index 19e526f14..3f54129f1 100644 --- a/qcsrc/client/hud/panel/strafehud/core.qc +++ b/qcsrc/client/hud/panel/strafehud/core.qc @@ -3,11 +3,8 @@ #include void StrafeHUD_DrawStrafeMeter( - float speed, float bestspeed, float frictionspeed, float shift_angle, float wishangle, - float changeangle, float bestangle, float absolute_bestangle, - float absolute_prebestangle, float opposite_bestangle, - float opposite_changeangle, bool moving, bool opposite_direction, - int direction, float hudangle) + float shiftangle, float wishangle, float absolute_bestangle, + float absolute_prebestangle, bool moving, float hudangle) { // the neutral zone fills the whole strafe bar if(!moving) @@ -75,15 +72,15 @@ void StrafeHUD_DrawStrafeMeter( neutral_offsetangle = 360 - current_startangle; // calculate how far off-center the strafe zones currently are - shift_angle += neutral_offsetangle / 2 - wishangle; + shiftangle += neutral_offsetangle / 2 - wishangle; // shift strafe zones into correct place - neutral_startangle += shift_angle; - accelzone_left_startangle += shift_angle; - accelzone_right_startangle += shift_angle; - preaccelzone_left_startangle += shift_angle; - preaccelzone_right_startangle += shift_angle; - overturn_startangle += shift_angle; + neutral_startangle += shiftangle; + accelzone_left_startangle += shiftangle; + accelzone_right_startangle += shiftangle; + preaccelzone_left_startangle += shiftangle; + preaccelzone_right_startangle += shiftangle; + overturn_startangle += shiftangle; // draw left acceleration zone StrafeHUD_drawStrafeHUD( @@ -147,9 +144,9 @@ void StrafeHUD_DrawAngleIndicator( // bound to HUD area angle = bound(-hudangle / 2, angle, hudangle / 2); - angle = StrafeHUD_projectAngle(angle, hudangle, false); float offset = StrafeHUD_angleToOffset(angle, hudangle); + offset = StrafeHUD_projectOffset(offset, hudangle, false); StrafeHUD_DrawAngleIndicatorLine(line_size, offset, num_dashes, color, alpha); diff --git a/qcsrc/client/hud/panel/strafehud/core.qh b/qcsrc/client/hud/panel/strafehud/core.qh index 9f9dd081a..944ed426d 100644 --- a/qcsrc/client/hud/panel/strafehud/core.qh +++ b/qcsrc/client/hud/panel/strafehud/core.qh @@ -5,6 +5,4 @@ void StrafeHUD_DrawAngleIndicator(float, vector, float, int, bool, bool, vector, void StrafeHUD_DrawAngleIndicatorLine(vector, float, int, vector, float); void StrafeHUD_DrawAngleIndicatorArrow(float, float, vector, vector, float, bool); void StrafeHUD_DrawDirectionIndicator(int, bool, bool); -void StrafeHUD_DrawStrafeMeter( - float, float, float, float, float, float, float, - float, float, float, float, bool, bool, int, float); +void StrafeHUD_DrawStrafeMeter(float, float, float, float, bool, float); diff --git a/qcsrc/client/hud/panel/strafehud/util.qc b/qcsrc/client/hud/panel/strafehud/util.qc index 19ac844fe..51dc60b8f 100644 --- a/qcsrc/client/hud/panel/strafehud/util.qc +++ b/qcsrc/client/hud/panel/strafehud/util.qc @@ -50,17 +50,6 @@ float StrafeHUD_project(float ratio, float range, bool reverse) return ratio; } -float StrafeHUD_projectAngle(float angle, float range, bool reverse) -{ - if(autocvar_hud_panel_strafehud_projection == STRAFEHUD_PROJECTION_LINEAR) - return angle; - - float ratio = (angle % 360) / (range / 2); - ratio = StrafeHUD_project(ratio, range, reverse); - angle = ratio * (range / 2); - return angle; -} - float StrafeHUD_projectOffset(float offset, float range, bool reverse) { if(autocvar_hud_panel_strafehud_projection == STRAFEHUD_PROJECTION_LINEAR) @@ -139,7 +128,7 @@ float DetectFrameTime() { float dt_client = input_timelength; - if(dt_client > .05) // server splits frames longer than 50 ms into two moves + if(dt_client > .05) // server splits frames longer than 50 ms into two moves (DarkPlaces behaviour) dt_client /= 2; // does not ensure frames are smaller than 50 ms, just splits large frames in half, matches server behaviour // calculate average frametime diff --git a/qcsrc/client/hud/panel/strafehud/util.qh b/qcsrc/client/hud/panel/strafehud/util.qh index b00adf9ae..ebe5b1ee5 100644 --- a/qcsrc/client/hud/panel/strafehud/util.qh +++ b/qcsrc/client/hud/panel/strafehud/util.qh @@ -4,7 +4,6 @@ float GetLengthUnitFactor(int); string GetLengthUnit(int); float StrafeHUD_project(float, float, bool); -float StrafeHUD_projectAngle(float, float, bool); float StrafeHUD_projectOffset(float, float, bool); float StrafeHUD_projectWidth(float, float, float); float StrafeHUD_angleToWidth(float, float); -- 2.39.2