From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Tue, 24 Sep 2024 20:34:56 +0000 (+0200) Subject: strafehud: more consistent variable naming X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f2baa0b60433fafbfd2c0c0860263191f4b4e9ae;p=xonotic%2Fxonotic-data.pk3dir.git strafehud: more consistent variable naming --- diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index d9213897e..2a9001050 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -336,12 +336,12 @@ void HUD_StrafeHUD() // best angle to strafe at float bestangle; float prebestangle; - float overturn_angle; + float overturnangle; if(!moving) { // these are unused (neutral fills whole strafe bar) prebestangle = bestangle = 0; - overturn_angle = 180; + overturnangle = 180; } else if(onground && autocvar_hud_panel_strafehud_onground_friction) { @@ -367,12 +367,12 @@ void HUD_StrafeHUD() float overturn_numer = speed * speed - strafespeed * strafespeed - maxaccel * maxaccel; float overturn_denom = 2 * maxaccel * strafespeed; // delta_max = acos((v^2 - v_f^2 - a^2) / (2av_f)), or just acos(-a / 2v) if in air - overturn_angle = overturn_denom > fabs(overturn_numer) + overturnangle = overturn_denom > fabs(overturn_numer) ? acos(overturn_numer / overturn_denom) * RAD2DEG // case 1 : (overturn_numer < 0 ? 180 : 0); // case 2 : case 3 // case 1: normal. case 2: low speed, turning anywhere will gain speed. case 3: landed at high speed, turning anywhere will lose speed (due to friction) } - if(overturn_angle < bestangle || bestangle < prebestangle) + if(overturnangle < bestangle || bestangle < prebestangle) { // these conditions occur when you land at high speed (above max onground speed), such that every wishangle will result in a speed loss due to friction if(autocvar_hud_panel_strafehud_onground_mode == STRAFEHUD_ONGROUND_OVERTURN) @@ -380,7 +380,7 @@ void HUD_StrafeHUD() // make overturn fill the whole strafe bar // most correct option by the true definition of accel, since every angle results in deceleration prebestangle = bestangle = 0; - overturn_angle = 0; + overturnangle = 0; } else if(autocvar_hud_panel_strafehud_onground_mode == STRAFEHUD_ONGROUND_GROUND) { @@ -391,7 +391,7 @@ void HUD_StrafeHUD() * overall showing it accurately is just confusing and unnecessary to add * thankfully the bestangle formula is unchanged, so the least confusing option is likely as follows: */ - overturn_angle = bestangle; + overturnangle = bestangle; prebestangle = bestangle; } else @@ -400,7 +400,7 @@ void HUD_StrafeHUD() // no need to check if numerator < denominator, since all numerators < max onground speed < speed = all denominators bestangle = acos(bestspeed / speed) * RAD2DEG; prebestangle = acos(movespeed / speed) * RAD2DEG; - overturn_angle = acos(-(airstopaccel * maxaccel / 2) / speed) * RAD2DEG; + overturnangle = acos(-(airstopaccel * maxaccel / 2) / speed) * RAD2DEG; } } } @@ -414,14 +414,14 @@ void HUD_StrafeHUD() ? acos(movespeed / speed) * RAD2DEG : 0; // with airstopaccel, delta_max = acos(airstopaccel * -a / 2v), only in air - overturn_angle = speed > airstopaccel * maxaccel / 2 + overturnangle = speed > airstopaccel * maxaccel / 2 ? acos(-(airstopaccel * maxaccel / 2) / speed) * RAD2DEG : 180; } // absolute_* variables which are always positive with no wishangle offset float absolute_bestangle = bestangle; float absolute_prebestangle = prebestangle; - float absolute_overturn_angle = overturn_angle; + float absolute_overturnangle = overturnangle; float aircontrol = PHYS_AIRCONTROL(strafeplayer); bool aircontrol_backwards = PHYS_AIRCONTROL_BACKWARDS(strafeplayer) == 1; @@ -490,7 +490,7 @@ void HUD_StrafeHUD() : -45; } - float hudangle = StrafeHUD_DetermineHudAngle(absolute_wishangle, absolute_overturn_angle, strafity); + float hudangle = StrafeHUD_DetermineHudAngle(absolute_wishangle, absolute_overturnangle, strafity); float antiflicker_angle = bound(0, autocvar_hud_panel_strafehud_antiflicker_angle, 180); float direction = StrafeHUD_DetermineDirection(angle, wishangle, antiflicker_angle); @@ -500,7 +500,7 @@ void HUD_StrafeHUD() n_bestangle *= -1; bestangle *= -1; prebestangle *= -1; - overturn_angle *= -1; + overturnangle *= -1; } float opposite_bestangle = -bestangle; float n_opposite_bestangle = -n_bestangle; @@ -509,7 +509,7 @@ void HUD_StrafeHUD() opposite_bestangle -= wishangle; n_opposite_bestangle -= wishangle; prebestangle -= wishangle; - overturn_angle -= wishangle; + overturnangle -= wishangle; int mode; if(autocvar_hud_panel_strafehud_mode >= 0 && autocvar_hud_panel_strafehud_mode <= 1) @@ -556,7 +556,7 @@ void HUD_StrafeHUD() wturn_right_bestangle += shiftangle; } - StrafeHUD_DrawStrafeMeter(shiftangle, wishangle, absolute_bestangle, absolute_prebestangle, absolute_overturn_angle, moving, hudangle); + StrafeHUD_DrawStrafeMeter(shiftangle, wishangle, absolute_bestangle, absolute_prebestangle, absolute_overturnangle, moving, hudangle); float text_offset_top; float text_offset_bottom; @@ -574,15 +574,15 @@ void HUD_StrafeHUD() if(moveangle > 180) moveangle = 360 - moveangle; // restricted to between 0 and 180 // player is overturning - if(moveangle >= absolute_overturn_angle) + if(moveangle >= absolute_overturnangle) { - if(moveangle == absolute_overturn_angle && absolute_overturn_angle == 180) + if(moveangle == absolute_overturnangle && absolute_overturnangle == 180) ; // everywhere gives acceleration, keep strafe_ratio as 0 else { currentangle_color = autocvar_hud_panel_strafehud_angle_overturn_color; - strafe_ratio = (moveangle - absolute_overturn_angle) / (180 - absolute_overturn_angle); - // moveangle is always <= 180, so this code won't run if absolute_overturn_angle == 180 + strafe_ratio = (moveangle - absolute_overturnangle) / (180 - absolute_overturnangle); + // moveangle is always <= 180, so this code won't run if absolute_overturnangle == 180 strafe_ratio *= -1; } } @@ -590,8 +590,8 @@ void HUD_StrafeHUD() else if(moveangle >= absolute_bestangle) { currentangle_color = autocvar_hud_panel_strafehud_angle_accel_color; - strafe_ratio = (absolute_overturn_angle - moveangle) / (absolute_overturn_angle - absolute_bestangle); - // if absolute_overturn_angle == absolute_bestangle, this code won't run, no need to check if their difference is 0 + strafe_ratio = (absolute_overturnangle - moveangle) / (absolute_overturnangle - absolute_bestangle); + // if absolute_overturnangle == absolute_bestangle, this code won't run, no need to check if their difference is 0 } else if(moveangle >= absolute_prebestangle) { diff --git a/qcsrc/client/hud/panel/strafehud/core.qc b/qcsrc/client/hud/panel/strafehud/core.qc index dae979549..94058f76a 100644 --- a/qcsrc/client/hud/panel/strafehud/core.qc +++ b/qcsrc/client/hud/panel/strafehud/core.qc @@ -4,7 +4,7 @@ void StrafeHUD_DrawStrafeMeter( float shiftangle, float wishangle, float absolute_bestangle, - float absolute_prebestangle, float absolute_overturn_angle, + float absolute_prebestangle, float absolute_overturnangle, bool moving, float hudangle) { // the neutral zone fills the whole strafe bar @@ -43,10 +43,10 @@ void StrafeHUD_DrawStrafeMeter( float neutral_startangle; float overturn_startangle; - float accelzone_offsetangle = absolute_overturn_angle - absolute_bestangle; + float accelzone_offsetangle = absolute_overturnangle - absolute_bestangle; float preaccelzone_offsetangle = fabs(absolute_bestangle - absolute_prebestangle); float neutral_offsetangle = 360; - float overturn_offsetangle = 360 - absolute_overturn_angle * 2; + float overturn_offsetangle = 360 - absolute_overturnangle * 2; if(!autocvar_hud_panel_strafehud_bar_preaccel) preaccelzone_offsetangle = 0; diff --git a/qcsrc/client/hud/panel/strafehud/util.qc b/qcsrc/client/hud/panel/strafehud/util.qc index 9f29d466c..b430a5260 100644 --- a/qcsrc/client/hud/panel/strafehud/util.qc +++ b/qcsrc/client/hud/panel/strafehud/util.qc @@ -203,19 +203,19 @@ float StrafeHUD_DetermineWishAngle(vector movement, int keys, bool islocal) return wishangle; } -float StrafeHUD_DetermineHudAngle(float absolute_wishangle, float absolute_overturn_angle, float strafity) +float StrafeHUD_DetermineHudAngle(float absolute_wishangle, float absolute_overturnangle, float strafity) { // determine the minimal required HUD angle to contain the full strafing angle range // this is useful for the velocity centered mode where the zones do not follow the strafing angle // how it works: // the angle where the most acceleration occurs moves relative to the player velocity - // from 0 - wishangle to absolute_overturn_angle - wishangle + // from 0 - wishangle to absolute_overturnangle - wishangle // the angle farther away from the center is the maximum the optimal strafing angle can // diverge from the direction of velocity // this angle has to be multiplied by two since the HUD extends in both directions which // halves the amount it extends in a single direction - float range_minangle = max(absolute_wishangle, absolute_overturn_angle - absolute_wishangle) * 2; + float range_minangle = max(absolute_wishangle, absolute_overturnangle - absolute_wishangle) * 2; float range_normal = autocvar_hud_panel_strafehud_range; float range_side = autocvar_hud_panel_strafehud_range_sidestrafe;