From 7dd493616f3c7dd903d271f99c7cd9fe4e509de1 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 29 Jun 2015 18:08:22 +0200 Subject: [PATCH] Optimize code by anticipating hud_panel_physics_text check --- qcsrc/client/hud.qc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index aea6d9b5d..7a1634625 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -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(); } -- 2.39.2