From: terencehill Date: Mon, 29 Jun 2015 16:08:22 +0000 (+0200) Subject: Optimize code by anticipating hud_panel_physics_text check X-Git-Tag: xonotic-v0.8.1~52^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7dd493616f3c7dd903d271f99c7cd9fe4e509de1;p=xonotic%2Fxonotic-data.pk3dir.git Optimize code by anticipating hud_panel_physics_text check --- 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(); }