]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Code cleanup in various files
authorotta8634 <k9wolf@pm.me>
Thu, 5 Dec 2024 02:05:39 +0000 (10:05 +0800)
committerotta8634 <k9wolf@pm.me>
Thu, 5 Dec 2024 02:05:39 +0000 (10:05 +0800)
Some suggestions by @drjaska
Made client/hud/common_physics.qc formatting consistent with CONTRIBUTING.md

qcsrc/client/hud/common_physics.qc
qcsrc/client/hud/panel/physics.qc
qcsrc/common/physics/player.qh

index ed2c151eb23cd7a061dafa013e2e96dda0de4bdf..27d572307f6af257a842701d75b7e00c1c2533a3 100644 (file)
@@ -11,7 +11,7 @@
 void HUD_Physics_Init()
 {
        // find out whether the local csqcmodel entity is valid
-       if(spectatee_status > 0 || isdemo())
+       if (spectatee_status > 0 || isdemo())
        {
                islocal = false;
                strafeplayer = CSQCModel_server2csqc(player_localentnum - 1);
@@ -22,14 +22,9 @@ void HUD_Physics_Init()
                strafeplayer = csqcplayer;
        }
 
-       if(csqcplayer && strafeplayer)
-               csqc_and_strafe_player = true;
-       else
-       {
-               csqc_and_strafe_player = false;
-               // Since both huds return (essentially) when this is false, no variables beyond this point need to be computed
-               return;
-       }
+       csqc_and_strafe_player = (csqcplayer && strafeplayer);
+       if (!csqc_and_strafe_player)
+               return; // Since both huds return (essentially) when this is false, no variables beyond this point need to be computed
 
        predicted = csqcplayer_status == CSQCPLAYERSTATUS_PREDICTED;
 
@@ -54,14 +49,14 @@ void HUD_Physics_Init()
        keys = STAT(PRESSED_KEYS);
        // try to ignore if track_canjump is enabled, doesn't work in spectator mode if spectated player uses +jetpack or cl_movement_track_canjump
        jumpheld = false;
-       if(islocal)
+       if (islocal)
        {
-               if((PHYS_INPUT_BUTTON_JUMP(strafeplayer) || PHYS_INPUT_BUTTON_JETPACK(strafeplayer)) && !PHYS_CL_TRACK_CANJUMP(strafeplayer))
+               if ((PHYS_INPUT_BUTTON_JUMP(strafeplayer) || PHYS_INPUT_BUTTON_JETPACK(strafeplayer)) && !PHYS_CL_TRACK_CANJUMP(strafeplayer))
                        jumpheld = true;
        }
        else
        {
-               if((keys & KEY_JUMP) && !PHYS_TRACK_CANJUMP(strafeplayer))
+               if ((keys & KEY_JUMP) && !PHYS_TRACK_CANJUMP(strafeplayer))
                        jumpheld = true;
        }
 
@@ -92,15 +87,13 @@ void HUD_Physics_Init()
        view_angle    = PHYS_INPUT_ANGLES(strafeplayer).y;
 
        airstopaccel  = PHYS_AIRSTOPACCELERATE(strafeplayer);
-       if(!airstopaccel)
+       if (!airstopaccel)
                airstopaccel = 1; // values of 0 are equivalent to 1
 
-       if(onground)
+       if (onground)
        {
-               if(friction_phys == 0)
-               {
+               if (friction_phys == 0)
                        onslick = true;
-               }
                else // don't use IS_ONSLICK(), it only works for the local player and only if client prediction is enabled
                {
                        trace_dphitq3surfaceflags = 0;
@@ -112,10 +105,8 @@ void HUD_Physics_Init()
                onground_lasttime = time;
                onslick_last = onslick;
        }
-       else if(jumpheld || swimming)
-       {
+       else if (jumpheld || swimming)
                onground_lasttime = 0;
-       }
 
        strafefriction = onslick ? friction_slick : friction_phys;
        alive_player   = (!IS_DEAD(strafeplayer) && IS_PLAYER(strafeplayer));
index 852c25e66ac908ea6dd1c35a06d519387800c0e4..79759328fa963f63f77304dba8a2e0449ff1036c 100644 (file)
@@ -51,7 +51,7 @@ void HUD_Physics()
        HUD_Panel_DrawBg();
        if (panel_bg_padding)
        {
-               panel_pos += '1 1 0' * panel_bg_padding;
+               panel_pos  += '1 1 0' * panel_bg_padding;
                panel_size -= '2 2 0' * panel_bg_padding;
        }
 
@@ -118,7 +118,7 @@ void HUD_Physics()
        float panel_ar = panel_size.x / panel_size.y;
        vector speed_offset = '0 0 0', accel_offset = '0 0 0';
        if (autocvar_hud_panel_physics_force_layout == PHYSICS_LAYOUT_HORIZONTAL
-               || (autocvar_hud_panel_physics_force_layout != PHYSICS_LAYOUT_VERTICAL && panel_ar >= 5 && !accel_progressbar_scale))
+       || (autocvar_hud_panel_physics_force_layout != PHYSICS_LAYOUT_VERTICAL && panel_ar >= 5 && !accel_progressbar_scale))
        {
                panel_size.x *= 0.5;
                if (autocvar_hud_panel_physics_flip)
@@ -160,14 +160,16 @@ void HUD_Physics()
 
        // draw speed
        if (!immobile)
-       if (autocvar_hud_panel_physics_progressbar == PHYSICS_PROGRESSBAR_BOTH || autocvar_hud_panel_physics_progressbar == PHYSICS_PROGRESSBAR_SPEED)
+       if (autocvar_hud_panel_physics_progressbar == PHYSICS_PROGRESSBAR_BOTH
+       ||  autocvar_hud_panel_physics_progressbar == PHYSICS_PROGRESSBAR_SPEED)
                HUD_Panel_DrawProgressBar(panel_pos + speed_offset, panel_size, "progressbar", speed / max_speed, 0, speed_baralign,
                        autocvar_hud_progressbar_speed_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
 
        // compute jumpspeed text
        float jump_speed_f = 0;
        if (autocvar_hud_panel_physics_jumpspeed)
-       if (autocvar_hud_panel_physics_text == PHYSICS_TEXT_BOTH || autocvar_hud_panel_physics_text == PHYSICS_TEXT_SPEED)
+       if (autocvar_hud_panel_physics_text == PHYSICS_TEXT_BOTH
+       ||  autocvar_hud_panel_physics_text == PHYSICS_TEXT_SPEED)
        {
                text_bits |= BIT(1);
                if (autocvar__hud_configure)
@@ -193,7 +195,8 @@ void HUD_Physics()
        // compute and draw topspeed
        float top_speed_f = 0;
        if (autocvar_hud_panel_physics_topspeed)
-       if (autocvar_hud_panel_physics_text == PHYSICS_TEXT_BOTH || autocvar_hud_panel_physics_text == PHYSICS_TEXT_SPEED)
+       if (autocvar_hud_panel_physics_text == PHYSICS_TEXT_BOTH
+       ||  autocvar_hud_panel_physics_text == PHYSICS_TEXT_SPEED)
        {
                text_bits |= BIT(0);
                if (autocvar__hud_configure)
@@ -220,7 +223,8 @@ void HUD_Physics()
                if (top_speed_f > 0)
                {
                        if (speed < top_speed)
-                       if (autocvar_hud_panel_physics_progressbar == PHYSICS_PROGRESSBAR_BOTH || autocvar_hud_panel_physics_progressbar == PHYSICS_PROGRESSBAR_SPEED)
+                       if (autocvar_hud_panel_physics_progressbar == PHYSICS_PROGRESSBAR_BOTH
+                       ||  autocvar_hud_panel_physics_progressbar == PHYSICS_PROGRESSBAR_SPEED)
                        {
                                float peak_offsetX;
                                vector peak_size = '0 0 0';
@@ -263,7 +267,8 @@ void HUD_Physics()
        }
 
        // draw speed text
-       if (autocvar_hud_panel_physics_text == PHYSICS_TEXT_BOTH || autocvar_hud_panel_physics_text == PHYSICS_TEXT_SPEED)
+       if (autocvar_hud_panel_physics_text == PHYSICS_TEXT_BOTH
+       ||  autocvar_hud_panel_physics_text == PHYSICS_TEXT_SPEED)
        {
                tmp_size.x   = panel_size.x * speed_size;
                tmp_size.y   = panel_size.y * text_scale;
@@ -277,7 +282,8 @@ void HUD_Physics()
 
        // draw acceleration
        if (accel)
-       if (autocvar_hud_panel_physics_progressbar == PHYSICS_PROGRESSBAR_BOTH || autocvar_hud_panel_physics_progressbar == PHYSICS_PROGRESSBAR_ACCEL)
+       if (autocvar_hud_panel_physics_progressbar == PHYSICS_PROGRESSBAR_BOTH
+       ||  autocvar_hud_panel_physics_progressbar == PHYSICS_PROGRESSBAR_ACCEL)
        {
                vector progressbar_color;
                if (accel < 0)
@@ -315,7 +321,8 @@ void HUD_Physics()
        }
 
        // draw acceleration text
-       if (autocvar_hud_panel_physics_text == PHYSICS_TEXT_BOTH || autocvar_hud_panel_physics_text == PHYSICS_TEXT_ACCEL)
+       if (autocvar_hud_panel_physics_text == PHYSICS_TEXT_BOTH
+       ||  autocvar_hud_panel_physics_text == PHYSICS_TEXT_ACCEL)
        {
                tmp_size.x = panel_size.x;
                tmp_size.y = panel_size.y * text_scale;
index f66860f6fcf0c26f772c50a4d4b1b6880562700b..2d8fb6552fa9270c28bba86b81d888c2c673320c 100644 (file)
@@ -214,6 +214,7 @@ STATIC_INIT(PHYS_INPUT_BUTTON)
 .float teleport_time;
 
 #ifdef CSQC
+
        #define PHYS_FIXANGLE(s) ('0 0 0')
 
        string autocvar_cl_jumpspeedcap_min;