]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize centerprint drawing
authorterencehill <piuntn@gmail.com>
Thu, 19 May 2011 13:20:10 +0000 (15:20 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 19 May 2011 13:20:10 +0000 (15:20 +0200)
- set drawfontscale before drawing all the lines, rather than for each line
- when a line isn't resized (sz == 1) use the previously calculated width (centerprint_width[i]) rather than calculate it again at every frame
- network warning message in ca once per second, message is still visible all the time

qcsrc/client/hud.qc
qcsrc/server/arena.qc

index 91256b9c5d566bb9d1d900368ceb53688992766e..848d069f619d18f92636210277797332ca209d4c 100644 (file)
@@ -302,11 +302,14 @@ void HUD_DrawCenterPrint (void)
                centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
 
        pos = centerprint_start;
+       drawfontscale = sz * '1 1 0';
        for (i=0; i<centerprint_num; i = i + 1)
        {
                ts = centerprint_messages[i];
-               drawfontscale = sz * '1 1 0';
-               pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
+               if (sz == 1)
+                       pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
+               else
+                       pos_x = (vid_conwidth - stringwidth(ts, TRUE, centerprint_fontsize)) * 0.5;
                if (ts != "")
                {
                        drawcolorcodedstring(pos + '0 1 0' * (1 - sz) * 0.5 *centerprint_fontsize_y, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
@@ -315,8 +318,8 @@ void HUD_DrawCenterPrint (void)
                else
                        // half height for empty lines looks better
                        pos_y = pos_y + sz * centerprint_fontsize_y * 0.5;
-               drawfontscale = '1 1 0';
        }
+       drawfontscale = '1 1 0';
 }
 
 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
index a58ccb2a54dbb3061519b37ef40c60ba92ad6609..681e86fa0f5c08637e32a5308fdfbfea1ca4920c 100644 (file)
@@ -375,6 +375,7 @@ void count_alive_players()
  *
  * Gets called in StartFrame()
  */
+float warntime;
 void Spawnqueue_Check()
 {
        count_spawned_players();
@@ -392,8 +393,12 @@ void Spawnqueue_Check()
                        reset_map(TRUE);
                }
                else if(ca_players < required_ca_players) {
-                       FOR_EACH_PLAYER(self)
-                               centerprint(self, strcat("^1Need at least 1 player in each team to play CA", "^7\n"));
+                       if (time > warntime)
+                       {
+                               FOR_EACH_PLAYER(self)
+                                       centerprint(self, strcat("^1Need at least 1 player in each team to play CA", "^7\n"));
+                               warntime = time + 1;
+                       }
                        return;
                }
                else if(!next_round) {