]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sbar.c
patch from div0: clamp "ping" reply valies in 0..9999 to prevent misparsing in case...
[xonotic/darkplaces.git] / sbar.c
diff --git a/sbar.c b/sbar.c
index 01df2be4947e2bc004a919f5546c3e2ae5d21955..264a6ef9cfa8a021c55996845c497dc2dcfd2c52 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -553,19 +553,30 @@ void Sbar_SortFrags (void)
                {
                        if (color != (cl.scores[fragsort[i]].colors & 15))
                        {
+                               const char* teamname;
+
                                color = cl.scores[fragsort[i]].colors & 15;
                                teamlines++;
 
-                               if (color == 4)
-                                       strcpy(teams[teamlines-1].name, "^1Red Team");
-                               else if (color == 13)
-                                       strcpy(teams[teamlines-1].name, "^4Blue Team");
-                               else if (color == 9)
-                                       strcpy(teams[teamlines-1].name, "^6Pink Team");
-                               else if (color == 12)
-                                       strcpy(teams[teamlines-1].name, "^3Yellow Team");
-                               else
-                                       strcpy(teams[teamlines-1].name, "Total Team Score");
+                               switch (color)
+                               {
+                                       case 4:
+                                               teamname = "^1Red Team";
+                                               break;
+                                       case 13:
+                                               teamname = "^4Blue Team";
+                                               break;
+                                       case 9:
+                                               teamname = "^6Pink Team";
+                                               break;
+                                       case 12:
+                                               teamname = "^3Yellow Team";
+                                               break;
+                                       default:
+                                               teamname = "Total Team Score";
+                                               break;
+                               }
+                               strlcpy(teams[teamlines-1].name, teamname, sizeof(teams[teamlines-1].name));
 
                                teams[teamlines-1].frags = 0;
                                teams[teamlines-1].colors = color + 16 * color;
@@ -642,7 +653,9 @@ Sbar_DrawScoreboard
 void Sbar_DrawScoreboard (void)
 {
        Sbar_SoloScoreboard ();
-       if (cl.gametype == GAME_DEATHMATCH)
+       // LordHavoc: changed to draw the deathmatch overlays in any multiplayer mode
+       //if (cl.gametype == GAME_DEATHMATCH)
+       if (!cl.islocalgame)
                Sbar_DeathmatchOverlay ();
 }
 
@@ -1234,7 +1247,9 @@ void Sbar_Draw (void)
                else // Quake and others
                {
                        sbar_y = vid_conheight.integer - SBAR_HEIGHT;
-                       if (cl.gametype == GAME_DEATHMATCH && gamemode != GAME_TRANSFUSION)
+                       // LordHavoc: changed to draw the deathmatch overlays in any multiplayer mode
+                       //if (cl.gametype == GAME_DEATHMATCH && gamemode != GAME_TRANSFUSION)
+                       if (!cl.islocalgame && gamemode != GAME_TRANSFUSION)
                                sbar_x = 0;
                        else
                                sbar_x = (vid_conwidth.integer - 320)/2;
@@ -1339,7 +1354,9 @@ void Sbar_Draw (void)
 
                        }
 
-                       if (vid_conwidth.integer > 320 && cl.gametype == GAME_DEATHMATCH)
+                       // LordHavoc: changed to draw the deathmatch overlays in any multiplayer mode
+                       //if (vid_conwidth.integer > 320 && cl.gametype == GAME_DEATHMATCH)
+                       if (!cl.islocalgame && vid_conwidth.integer > 320)
                        {
                                if (gamemode == GAME_TRANSFUSION)
                                        Sbar_MiniDeathmatchOverlay (0, 0);
@@ -1370,9 +1387,14 @@ float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
 {
        int minutes;
        unsigned char *c;
-       minutes = (int)((cl.intermission ? cl.completed_time - s->qw_entertime : realtime - s->qw_entertime) / 60.0);
+       minutes = (int)((cl.intermission ? cl.completed_time - s->qw_entertime : cl.time - s->qw_entertime) / 60.0);
        if (s->qw_spectator)
-               DrawQ_ColoredString(x, y, va("%4i %3i %4i spect %-4s %c%s", bound(0, s->qw_ping, 9999), bound(0, s->qw_packetloss, 99), minutes, cl.qw_teamplay ? s->qw_team : "", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL );
+       {
+               if (s->qw_ping || s->qw_packetloss)
+                       DrawQ_ColoredString(x, y, va("%4i %3i %4i spect %-4s %c%s", bound(0, s->qw_ping, 9999), bound(0, s->qw_packetloss, 99), minutes, cl.qw_teamplay ? s->qw_team : "", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL );
+               else
+                       DrawQ_ColoredString(x, y, va("         %4i spect %-4s %c%s", minutes, cl.qw_teamplay ? s->qw_team : "", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL );
+       }
        else
        {
                // draw colors behind score
@@ -1382,7 +1404,10 @@ float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
                DrawQ_Pic(x + 14*8, y+4, NULL, 40, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0);
                // print the text
                //DrawQ_String(x, y, va("%c%4i %s", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
-               DrawQ_ColoredString(x, y, va("%4i %3i %4i %5i %-4s %c%s", bound(0, s->qw_ping, 9999), bound(0, s->qw_packetloss, 99), minutes,(int) s->frags, cl.qw_teamplay ? s->qw_team : "", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL );
+               if (s->qw_ping || s->qw_packetloss)
+                       DrawQ_ColoredString(x, y, va("%4i %3i %4i %5i %-4s %c%s", bound(0, s->qw_ping, 9999), bound(0, s->qw_packetloss, 99), minutes,(int) s->frags, cl.qw_teamplay ? s->qw_team : "", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL );
+               else
+                       DrawQ_ColoredString(x, y, va("         %4i %5i %-4s %c%s", minutes,(int) s->frags, cl.qw_teamplay ? s->qw_team : "", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL );
        }
        return 8;
 }
@@ -1400,8 +1425,16 @@ void Sbar_DeathmatchOverlay (void)
                        MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
                        MSG_WriteString(&cls.netcon->message, "pings");
                }
+               else if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE || cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4 || cls.protocol == PROTOCOL_DARKPLACES5 || cls.protocol == PROTOCOL_DARKPLACES6 || cls.protocol == PROTOCOL_DARKPLACES7)
+               {
+                       // these servers usually lack the pings command and so a less efficient "ping" command must be sent, which on modern DP servers will also reply with a pingplreport command after the ping listing
+                       cl.parsingtextexpectingpingforscores = true; // hide the output of the next ping report
+                       MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
+                       MSG_WriteString(&cls.netcon->message, "ping");
+               }
                else
                {
+                       // newer server definitely has pings command, so use it for more efficiency
                        MSG_WriteByte(&cls.netcon->message, clc_stringcmd);
                        MSG_WriteString(&cls.netcon->message, "pings");
                }
@@ -1485,7 +1518,9 @@ void Sbar_IntermissionOverlay (void)
        int             dig;
        int             num;
 
-       if (cl.gametype == GAME_DEATHMATCH)
+       // LordHavoc: changed to draw the deathmatch overlays in any multiplayer mode
+       //if (cl.gametype == GAME_DEATHMATCH)
+       if (!cl.islocalgame)
        {
                Sbar_DeathmatchOverlay ();
                return;