]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize centerprint panel code: if there is nothing to display free all the msgs...
authorterencehill <piuntn@gmail.com>
Mon, 27 Jun 2011 12:58:08 +0000 (14:58 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 27 Jun 2011 13:19:17 +0000 (15:19 +0200)
qcsrc/client/hud.qc

index 01475f383a86fd810f9909a013921a20db08350c..9c5f993669060fec15d12bcd5b22e91250d3ebbe 100644 (file)
@@ -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();
+       }
 }
 
 /*