]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/modicons.qc
Merge branch 'master' into martin-t/dmgtext
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / modicons.qc
index c3e91d3e9c7070838a2973d180f353459dbf69c0..4d1691a7fd57798ac639b7023f6a04f81e476a36 100644 (file)
@@ -1,8 +1,11 @@
 #include "modicons.qh"
 
+#include <client/miscfunctions.qh>
+#include <client/autocvars.qh>
 #include <common/mapinfo.qh>
 #include <common/ent_cs.qh>
-#include <server/mutators/mutator/gamemode_ctf.qh> // TODO: remove
+#include <common/scores.qh>
+#include <common/gamemodes/_mod.qh>
 
 // Mod icons (#10)
 
@@ -10,7 +13,7 @@ bool mod_active; // is there any active mod icon?
 
 void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
 {
-    TC(int, layout); TC(int, i);
+       TC(int, layout); TC(int, i);
        int stat = -1;
        string pic = "";
        vector color = '0 0 0';
@@ -51,9 +54,9 @@ void HUD_Mod_CA(vector myPos, vector mySize)
        mod_active = 1; // required in each mod function that always shows something
 
        int layout;
-       if(gametype == MAPINFO_TYPE_CA)
+       if(ISGAMETYPE(CA))
                layout = autocvar_hud_panel_modicons_ca_layout;
-       else //if(gametype == MAPINFO_TYPE_FREEZETAG)
+       else //if(ISGAMETYPE(FREEZETAG))
                layout = autocvar_hud_panel_modicons_freezetag_layout;
        int rows, columns;
        float aspect_ratio;
@@ -512,18 +515,20 @@ void race_showTime(string text, vector pos, vector timeText_ofs, float theTime,
 
 void HUD_Mod_Race(vector pos, vector mySize)
 {
-       mod_active = 1; // race should never hide the mod icons panel
-       entity me;
-       me = playerslots[player_localnum];
-       float score;
-       score = me.(scores(ps_primary));
+       entity me = playerslots[player_localnum];
+       float score = me.(scores(ps_primary));
 
        if(!(scores_flags(ps_primary) & SFL_TIME) || teamplay) // race/cts record display on HUD
+       {
+               mod_active = 0; // hide it in this case!
                return; // no records in the actual race
+       }
+
+       mod_active = 1;
 
        // clientside personal record
        string rr;
-       if(gametype == MAPINFO_TYPE_CTS)
+       if(ISGAMETYPE(CTS))
                rr = CTS_RECORD;
        else
                rr = RACE_RECORD;
@@ -551,7 +556,7 @@ void HUD_Mod_Race(vector pos, vector mySize)
                squareSize = min(mySize.y, mySize.x/2);
                vector ofs = vec2(0.5 * max(0, mySize.x/2 - squareSize), 0.5 * (mySize.y - squareSize));
                textPos = pos + ofs;
-               ofs.y += 0.5 * mySize.x;
+               ofs.x += 0.5 * mySize.x;
                medalPos = pos + ofs;
        } else {
                // text on top
@@ -578,30 +583,19 @@ void HUD_Mod_Race(vector pos, vector mySize)
        if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
                race_status_time = time + 5;
                race_status_prev = race_status;
-               if (race_status_name_prev)
-                       strunzone(race_status_name_prev);
-               race_status_name_prev = strzone(race_status_name);
+               strcpy(race_status_name_prev, race_status_name);
        }
 
        // race "awards"
-       float a;
-       a = bound(0, race_status_time - time, 1);
+       float a = bound(0, race_status_time - time, 1);
+       string s = textShortenToWidth(ColorTranslateRGB(race_status_name), squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
 
-       string s;
-       s = textShortenToWidth(ColorTranslateRGB(race_status_name), squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
-
-       float rank;
+       float rank = 0;
        if(race_status > 0)
                rank = race_CheckName(race_status_name);
-       else
-               rank = 0;
-       string rankname;
-       rankname = count_ordinal(rank);
-
-       vector namepos;
-       namepos = medalPos + '0 0.8 0' * squareSize;
-       vector rankpos;
-       rankpos = medalPos + '0 0.15 0' * squareSize;
+       string rankname = count_ordinal(rank);
+       vector namepos = medalPos + '0 0.8 0' * squareSize;
+       vector rankpos = medalPos + '0 0.15 0' * squareSize;
 
        if(race_status == 0)
                drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
@@ -625,18 +619,14 @@ void HUD_Mod_Race(vector pos, vector mySize)
        if (race_status_time - time <= 0) {
                race_status_prev = -1;
                race_status = -1;
-               if(race_status_name)
-                       strunzone(race_status_name);
-               race_status_name = string_null;
-               if(race_status_name_prev)
-                       strunzone(race_status_name_prev);
-               race_status_name_prev = string_null;
+               strfree(race_status_name);
+               strfree(race_status_name_prev);
        }
 }
 
 void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
 {
-    TC(int, layout); TC(int, i);
+       TC(int, layout); TC(int, i);
        float stat = -1;
        string pic = "";
        vector color = '0 0 0';