]> git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/hud.qc
Properly strunzone strings
[voretournament/voretournament.git] / data / qcsrc / client / hud.qc
index 976c1ec6a8354eb81366e547f8bd17e7dea54c66..1a3b4c20ed0d061c8e38137ec27b4af2881407af 100644 (file)
@@ -25,6 +25,9 @@ float sbar_accuracy_hud;
 float sbar_scoreboard_alpha_name;\r
 float sbar_scoreboard_alpha_name_self;\r
 \r
+string portrait_image, portrait_name;\r
+float portrait_time;\r
+\r
 float ps_primary, ps_secondary;\r
 float ts_primary, ts_secondary;\r
 \r
@@ -1677,6 +1680,24 @@ void Sbar_DrawRaceStatus(vector pos)
        }\r
 }\r
 \r
+void Sbar_Portrait()\r
+{\r
+       // draws the portrait, using the values set in Ent_ReadPortrait\r
+\r
+       vector left;\r
+       left_x = 0;\r
+       left_y = vid_conheight / 2;\r
+\r
+       if(!cvar("sbar_portrait"))\r
+               return;\r
+\r
+       if(portrait_time + cvar("sbar_portrait_time") >= time)\r
+       {\r
+               drawpic(left + '10 -80 0', portrait_image, '120 160 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+               drawcolorcodedstring(left + '10 80 0', portrait_name, '12 12 0', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+       }\r
+}\r
+\r
 void Sbar_Score()\r
 {\r
        float score, distribution, leader;\r
@@ -3207,11 +3228,12 @@ void Sbar_Draw (void)
                        Sbar_PrintStomachboardItemPred(bottomleft - '-76 150 0', pred);\r
                }\r
 \r
-               // draw status, scores, timer, and ring\r
+               // draw status, scores, timer, ring and portrait\r
                Sbar_Status();\r
                Sbar_Score();\r
                Sbar_Timer();\r
                Sbar_Ring();\r
+               Sbar_Portrait();\r
 \r
                // draw strength/invincibility icon and timer\r
                CSQC_Strength_Timer();\r
@@ -3553,12 +3575,24 @@ void CSQC_race_hud(void)
 \r
 void Ent_ReadPortrait()\r
 {\r
+       // receives portrait values, which are used in Sbar_Portrait\r
+\r
        string pl_model, pl_name, img;\r
        float pl_skin;\r
+\r
        pl_model = ReadString();\r
        pl_skin = ReadByte();\r
        pl_name = ReadString();\r
 \r
+       // update existing portraits\r
+       if(portrait_name)\r
+               strunzone(portrait_name);\r
+       if(portrait_image)\r
+               strunzone(portrait_image);\r
+\r
+       portrait_time = time;\r
+       portrait_name = strzone(pl_name);\r
+\r
        // obtain the image name from the text file\r
        float glob, i, fh;\r
        string fn;\r
@@ -3577,7 +3611,7 @@ void Ent_ReadPortrait()
                img = fgets(fh);\r
                if(pl_skin == stof(fgets(fh)))\r
                if(pl_model == fgets(fh))\r
-                       dprint(strcat(img, " ----------------\n"));\r
+                       portrait_image = strzone(img);\r
 \r
                fclose(fh);\r
        }\r