]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize code by anticipating hud_panel_physics_text check
authorterencehill <piuntn@gmail.com>
Mon, 29 Jun 2015 16:08:22 +0000 (18:08 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 29 Jun 2015 16:08:22 +0000 (18:08 +0200)
qcsrc/client/hud.qc

index aea6d9b5dc8357661c2446b9cb6050e21be31ff4..7a1634625c76f1ef83598bfd4c87a36737ad2a18 100644 (file)
@@ -4167,17 +4167,20 @@ void HUD_Physics(void)
 
                HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset + tmp_offset, tmp_size, "accelbar", f, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        }
-       tmp_size.x = panel_size.x;
-       tmp_size.y = panel_size.y * text_scale;
-       tmp_offset.x = 0;
-       tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
-
-       int decimals = 2;
-       // workaround for ftos_decimals returning a negative 0
-       if(acceleration > -1 / pow(10, decimals) && acceleration < 0)
-               acceleration = 0;
-       if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
+
+       if(autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
+       {
+               tmp_size.x = panel_size.x;
+               tmp_size.y = panel_size.y * text_scale;
+               tmp_offset.x = 0;
+               tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
+
+               int decimals = 2;
+               // workaround for ftos_decimals returning a negative 0
+               if(acceleration > -1 / pow(10, decimals) && acceleration < 0)
+                       acceleration = 0;
                drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(acceleration, decimals), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       }
 
        draw_endBoldFont();
 }