From: terencehill Date: Mon, 27 Jun 2011 12:58:08 +0000 (+0200) Subject: Optimize centerprint panel code: if there is nothing to display free all the msgs... X-Git-Tag: xonotic-v0.5.0~174 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7ac173a3751fc32b7222c0a36d421c7918e79fd3;p=xonotic%2Fxonotic-data.pk3dir.git Optimize centerprint panel code: if there is nothing to display free all the msgs and wait for another msg before executing again the code to draw the msgs --- diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 01475f383..9c5f99366 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4355,6 +4355,7 @@ float centerprint_msgID[CENTERPRINT_MAX_MSGS]; float centerprint_time[CENTERPRINT_MAX_MSGS]; float centerprint_expire_time[CENTERPRINT_MAX_MSGS]; float centerprint_countdown_num[CENTERPRINT_MAX_MSGS]; +float centerprint_showing; void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num) { @@ -4383,6 +4384,9 @@ void centerprint_generic(float new_id, string strMessage, float duration, float if(strMessage == "" && new_id == 0) return; + if (!centerprint_showing) + centerprint_showing = TRUE; + if(duration == 0) duration = max(1, autocvar_hud_panel_centerprint_time); @@ -4484,6 +4488,10 @@ void HUD_CenterPrint (void) } HUD_Panel_DrawBg(1); + + if (!centerprint_showing) + return; + if(panel_bg_padding) { panel_pos += '1 1 0' * panel_bg_padding; @@ -4504,6 +4512,8 @@ void HUD_CenterPrint (void) vector pos; string ts; + n = -1; // if no msg will be displayed, n stays -1 + pos = panel_pos; if (autocvar_hud_panel_centerprint_flip) pos_y += panel_size_y; @@ -4600,6 +4610,11 @@ void HUD_CenterPrint (void) } } drawfontscale = '1 1 0'; + if (n == -1) + { + centerprint_showing = FALSE; + reset_centerprint_messages(); + } } /*