]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added a score-distribution/place/score block left of the hud
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 13 Jun 2007 23:29:13 +0000 (23:29 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 13 Jun 2007 23:29:13 +0000 (23:29 +0000)
added a time remaining clock left of the hud (which shows time in level
instead if no timelimit is active or if the server does not send it)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7410 d7cf8633-e32d-0410-b094-e92efae38249

quakedef.h
sbar.c
sv_main.c

index ade02aee250e51d032c1e67dfcbbce534591ffff..0033e47a16177b7a5c9ff445657ed636bd2ae2f0 100644 (file)
@@ -94,6 +94,8 @@ extern char engineversion[128];
 //#define STAT_TIME                    17 // FTE
 //#define STAT_VIEW2           20 // FTE
 #define STAT_VIEWZOOM          21 // DP
+#define STAT_FRAGLIMIT                                                         235 // DP
+#define STAT_TIMELIMIT                                                         236 // DP
 #define STAT_MOVEVARS_WALLFRICTION                                     237 // DP
 #define STAT_MOVEVARS_FRICTION                                         238 // DP
 #define STAT_MOVEVARS_WATERFRICTION                                    239 // DP
diff --git a/sbar.c b/sbar.c
index cae355910f6a13e05d7f1e6dda09433d246f3355..baedcd1d963bf93eac5979ee25c6ebef53630235 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -471,7 +471,13 @@ void Sbar_DrawXNum (int x, int y, int num, int digits, int lettersize, float r,
        char str[32], *ptr;
        int l, frame;
 
-       l = sprintf(str, "%i", num);
+       if (digits < 0)
+       {
+               digits = -digits;
+               l = sprintf(str, "%0*i", digits, num);
+       }
+       else
+               l = sprintf(str, "%i", num);
        ptr = str;
        if (l > digits)
                ptr += (l-digits);
@@ -1112,6 +1118,7 @@ Sbar_Draw
 */
 extern float v_dmg_time, v_dmg_roll, v_dmg_pitch;
 extern cvar_t v_kicktime;
+void Sbar_Score (void);
 void Sbar_Draw (void)
 {
        cachepic_t *pic;
@@ -1261,6 +1268,8 @@ void Sbar_Draw (void)
 
                                if (sbar_x + 320 + 160 <= vid_conwidth.integer)
                                        Sbar_MiniDeathmatchOverlay (sbar_x + 320, sbar_y);
+                               if (sbar_x > 0)
+                                       Sbar_Score();
                        }
                        else if (sb_lines)
                        {
@@ -1344,6 +1353,9 @@ void Sbar_Draw (void)
 
                                if (sbar_x + 600 + 160 <= vid_conwidth.integer)
                                        Sbar_MiniDeathmatchOverlay (sbar_x + 600, sbar_y);
+
+                               if (sbar_x > 0)
+                                       Sbar_Score();
                        }
                }
                else if (gamemode == GAME_ZYMOTIC)
@@ -1528,6 +1540,8 @@ void Sbar_Draw (void)
                                        Sbar_MiniDeathmatchOverlay (0, 0);
                                else
                                        Sbar_MiniDeathmatchOverlay (324, vid_conheight.integer - sb_lines);
+                               if (sbar_x > 0)
+                                       Sbar_Score();
                        }
                }
        }
@@ -1684,7 +1698,7 @@ void Sbar_DeathmatchOverlay (void)
 
 /*
 ==================
-Sbar_DeathmatchOverlay
+Sbar_MiniDeathmatchOverlay
 
 ==================
 */
@@ -1759,6 +1773,90 @@ void Sbar_MiniDeathmatchOverlay (int x, int y)
        }
 }
 
+void Sbar_Score (void)
+{
+       int i, me, score, otherleader, place, distribution, minutes, seconds;
+       double timeleft;
+
+       sbar_y = vid_conheight.value - (32+12);
+       me = cl.playerentity - 1;
+       if (me >= 0 && me < cl.maxclients)
+       {
+               // find leading score other than ourselves, to calculate distribution
+               // find our place in the scoreboard
+               score = cl.scores[me].frags;
+               for (i = 0, otherleader = -1, place = 1;i < cl.maxclients;i++)
+               {
+                       if (cl.scores[i].name[0] && i != me)
+                       {
+                               if (otherleader == -1 || cl.scores[i].frags > cl.scores[otherleader].frags)
+                                       otherleader = i;
+                               if (score < cl.scores[i].frags || (score == cl.scores[i].frags && i < me))
+                                       place++;
+                       }
+               }
+               distribution = otherleader >= 0 ? score - cl.scores[otherleader].frags : 0;
+               if (place == 1)
+                       Sbar_DrawXNum(-3*12-24, -12, place, 3, 12, 0, 1, 1, 1, 0);
+               else if (place == 2)
+                       Sbar_DrawXNum(-3*12-24, -12, place, 3, 12, 1, 1, 1, 1, 0);
+               else if (place == 3)
+                       Sbar_DrawXNum(-3*12-24, -12, place, 3, 12, 1, 1, 0, 1, 0);
+               else
+                       Sbar_DrawXNum(-3*12-24, -12, place, 3, 12, 1, 0, 0, 1, 0);
+               if (otherleader < 0)
+                       Sbar_DrawXNum(-32*4-24,   0, score, 4, 32, 1, 1, 1, 1, 0);
+               else if (distribution >= 5)
+               {
+                       Sbar_DrawXNum(-7*12-24, -12, distribution, 4, 12, 0, 1, 1, 1, 0);
+                       Sbar_DrawXNum(-32*4-24,   0, score, 4, 32, 0, 1, 1, 1, 0);
+               }
+               else if (distribution >= 0)
+               {
+                       Sbar_DrawXNum(-7*12-24, -12, distribution, 4, 12, 1, 1, 1, 1, 0);
+                       Sbar_DrawXNum(-32*4-24,   0, score, 4, 32, 1, 1, 1, 1, 0);
+               }
+               else if (distribution >= -5)
+               {
+                       Sbar_DrawXNum(-7*12-24, -12, distribution, 4, 12, 1, 1, 0, 1, 0);
+                       Sbar_DrawXNum(-32*4-24,   0, score, 4, 32, 1, 1, 0, 1, 0);
+               }
+               else
+               {
+                       Sbar_DrawXNum(-7*12-24, -12, distribution, 4, 12, 1, 0, 0, 1, 0);
+                       Sbar_DrawXNum(-32*4-24,   0, score, 4, 32, 1, 0, 0, 1, 0);
+               }
+       }
+
+       if (cl.statsf[STAT_TIMELIMIT])
+       {
+               timeleft = max(0, cl.statsf[STAT_TIMELIMIT] * 60 - cl.time);
+               minutes = (int)floor(timeleft / 60);
+               seconds = (int)(floor(timeleft) - minutes * 60);
+               if (minutes >= 5)
+               {
+                       Sbar_DrawXNum(-12*6-24, 32, minutes,  3, 12, 1, 1, 1, 1, 0);
+                       Sbar_DrawXNum(-12*2-24, 32, seconds, -2, 12, 1, 1, 1, 1, 0);
+               }
+               else if (minutes >= 1)
+               {
+                       Sbar_DrawXNum(-12*6-24, 32, minutes,  3, 12, 1, 1, 0, 1, 0);
+                       Sbar_DrawXNum(-12*2-24, 32, seconds, -2, 12, 1, 1, 0, 1, 0);
+               }
+               else if ((int)(timeleft * 4) & 1)
+                       Sbar_DrawXNum(-12*2-24, 32, seconds, -2, 12, 1, 1, 1, 1, 0);
+               else
+                       Sbar_DrawXNum(-12*2-24, 32, seconds, -2, 12, 1, 0, 0, 1, 0);
+       }
+       else
+       {
+               minutes = (int)floor(cl.time / 60);
+               seconds = (int)(floor(cl.time) - minutes * 60);
+               Sbar_DrawXNum(-12*6-24, 32, minutes,  3, 12, 0, 1, 1, 1, 0);
+               Sbar_DrawXNum(-12*2-24, 32, seconds, -2, 12, 0, 1, 1, 1, 0);
+       }
+}
+
 /*
 ==================
 Sbar_IntermissionOverlay
index 3d31072856fa28cc77313e41fe42a71f26f76afa..c1a6feb2e7d1bded4e6aaa920dd8798d1d09c9e4 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -1392,6 +1392,8 @@ void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t
        statsf[STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION] = sv_airaccel_sideways_friction.value;
        statsf[STAT_MOVEVARS_FRICTION] = sv_friction.value;
        statsf[STAT_MOVEVARS_WATERFRICTION] = sv_waterfriction.value >= 0 ? sv_waterfriction.value : sv_friction.value;
+       statsf[STAT_FRAGLIMIT] = fraglimit.value;
+       statsf[STAT_TIMELIMIT] = timelimit.value;
 
        if (sv.protocol == PROTOCOL_QUAKE || sv.protocol == PROTOCOL_QUAKEDP || sv.protocol == PROTOCOL_NEHAHRAMOVIE || sv.protocol == PROTOCOL_DARKPLACES1 || sv.protocol == PROTOCOL_DARKPLACES2 || sv.protocol == PROTOCOL_DARKPLACES3 || sv.protocol == PROTOCOL_DARKPLACES4 || sv.protocol == PROTOCOL_DARKPLACES5)
        {