]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/radar.qc
Cleanup radar code. I'll adapt the radar menu to the new changes later
[voretournament/voretournament.git] / data / qcsrc / client / radar.qc
index 97ea2444574695e3536c07a7f2b48ed146da883c..f266d2970dd855a78b086c71810002a271e53dc6 100644 (file)
@@ -55,34 +55,41 @@ vector yinvert(vector v)
 \r
 void draw_radar_background(float ca, float bg, float fg)\r
 {\r
-       vector cgc;\r
+       vector col, rgb;\r
+       vector pos1, pos2, pos3, pos4;\r
+       pos1 = '1 0 0' * (radar_origin2d_x - radar_size2d_x * 0.5 + radar_extraclip_mins_x) + '0 1 0' * (radar_origin2d_y - radar_size2d_y * 0.5 + radar_extraclip_mins_y);\r
+       pos2 = '1 0 0' * (radar_origin2d_x + radar_size2d_x * 0.5 + radar_extraclip_maxs_x) + '0 1 0' * (radar_origin2d_y - radar_size2d_y * 0.5 + radar_extraclip_mins_y);\r
+       pos3 = '1 0 0' * (radar_origin2d_x + radar_size2d_x * 0.5 + radar_extraclip_maxs_x) + '0 1 0' * (radar_origin2d_y + radar_size2d_y * 0.5 + radar_extraclip_maxs_y);\r
+       pos4 = '1 0 0' * (radar_origin2d_x - radar_size2d_x * 0.5 + radar_extraclip_mins_x) + '0 1 0' * (radar_origin2d_y + radar_size2d_y * 0.5 + radar_extraclip_maxs_y);\r
+       rgb = GetTeamRGB(GetPlayerColor(player_localentnum - 1));\r
+\r
        if(bg > 0)\r
        {\r
                R_BeginPolygon("gfx/hud/bg_radar.tga", DRAWFLAG_NORMAL);\r
-               R_PolygonVertex('1 0 0' * (radar_origin2d_x - radar_size2d_x * 0.5 + radar_extraclip_mins_x) + '0 1 0' * (radar_origin2d_y - radar_size2d_y * 0.5 + radar_extraclip_mins_y), yinvert(mi_pictexcoord1), '1 1 1', bg);\r
-               R_PolygonVertex('1 0 0' * (radar_origin2d_x + radar_size2d_x * 0.5 + radar_extraclip_maxs_x) + '0 1 0' * (radar_origin2d_y - radar_size2d_y * 0.5 + radar_extraclip_mins_y), yinvert(mi_pictexcoord2), '1 1 1', bg);\r
-               R_PolygonVertex('1 0 0' * (radar_origin2d_x + radar_size2d_x * 0.5 + radar_extraclip_maxs_x) + '0 1 0' * (radar_origin2d_y + radar_size2d_y * 0.5 + radar_extraclip_maxs_y), yinvert(mi_pictexcoord3), '1 1 1', bg);\r
-               R_PolygonVertex('1 0 0' * (radar_origin2d_x - radar_size2d_x * 0.5 + radar_extraclip_mins_x) + '0 1 0' * (radar_origin2d_y + radar_size2d_y * 0.5 + radar_extraclip_maxs_y), yinvert(mi_pictexcoord0), '1 1 1', bg);\r
+               R_PolygonVertex(pos1, yinvert(mi_pictexcoord1), '1 1 1', bg);\r
+               R_PolygonVertex(pos2, yinvert(mi_pictexcoord2), '1 1 1', bg);\r
+               R_PolygonVertex(pos3, yinvert(mi_pictexcoord3), '1 1 1', bg);\r
+               R_PolygonVertex(pos4, yinvert(mi_pictexcoord0), '1 1 1', bg);\r
                R_EndPolygon();\r
        }\r
 \r
        if(ca > 0 && minimapname != "")\r
        {\r
-               cgc = '1 1 1' * ca;\r
+               col = '1 1 1' * ca;\r
                R_BeginPolygon(minimapname, DRAWFLAG_SCREEN | DRAWFLAG_MIPMAP);\r
                if(v_flipped)\r
                {\r
-                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), cgc, 1);\r
-                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), cgc, 1);\r
-                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), cgc, 1);\r
-                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), cgc, 1);\r
+                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), col, 1);\r
+                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), col, 1);\r
+                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), col, 1);\r
+                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), col, 1);\r
                }\r
                else\r
                {\r
-                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), cgc, 1);\r
-                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), cgc, 1);\r
-                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), cgc, 1);\r
-                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), cgc, 1);\r
+                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), col, 1);\r
+                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), col, 1);\r
+                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), col, 1);\r
+                       R_PolygonVertex(radar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), col, 1);\r
                }\r
                R_EndPolygon();\r
        }\r
@@ -90,21 +97,17 @@ void draw_radar_background(float ca, float bg, float fg)
        if(fg > 0)\r
        {\r
                R_BeginPolygon("gfx/hud/fg_radar.tga", DRAWFLAG_NORMAL);\r
-               R_PolygonVertex('1 0 0' * (radar_origin2d_x - radar_size2d_x * 0.5 + radar_extraclip_mins_x) + '0 1 0' * (radar_origin2d_y - radar_size2d_y * 0.5 + radar_extraclip_mins_y), yinvert(mi_pictexcoord1), '1 1 1', fg);\r
-               R_PolygonVertex('1 0 0' * (radar_origin2d_x + radar_size2d_x * 0.5 + radar_extraclip_maxs_x) + '0 1 0' * (radar_origin2d_y - radar_size2d_y * 0.5 + radar_extraclip_mins_y), yinvert(mi_pictexcoord2), '1 1 1', fg);\r
-               R_PolygonVertex('1 0 0' * (radar_origin2d_x + radar_size2d_x * 0.5 + radar_extraclip_maxs_x) + '0 1 0' * (radar_origin2d_y + radar_size2d_y * 0.5 + radar_extraclip_maxs_y), yinvert(mi_pictexcoord3), '1 1 1', fg);\r
-               R_PolygonVertex('1 0 0' * (radar_origin2d_x - radar_size2d_x * 0.5 + radar_extraclip_mins_x) + '0 1 0' * (radar_origin2d_y + radar_size2d_y * 0.5 + radar_extraclip_maxs_y), yinvert(mi_pictexcoord0), '1 1 1', fg);\r
+               R_PolygonVertex(pos1, yinvert(mi_pictexcoord1), '1 1 1', fg);\r
+               R_PolygonVertex(pos2, yinvert(mi_pictexcoord2), '1 1 1', fg);\r
+               R_PolygonVertex(pos3, yinvert(mi_pictexcoord3), '1 1 1', fg);\r
+               R_PolygonVertex(pos4, yinvert(mi_pictexcoord0), '1 1 1', fg);\r
                R_EndPolygon();\r
-       }\r
-       vector rgb;\r
-       rgb = GetTeamRGB(GetPlayerColor(player_localentnum - 1));\r
-       if(fg > 0)\r
-       {\r
+\r
                R_BeginPolygon("gfx/hud/fg_radar_team.tga", DRAWFLAG_NORMAL);\r
-               R_PolygonVertex('1 0 0' * (radar_origin2d_x - radar_size2d_x * 0.5 + radar_extraclip_mins_x) + '0 1 0' * (radar_origin2d_y - radar_size2d_y * 0.5 + radar_extraclip_mins_y), yinvert(mi_pictexcoord1), rgb, fg);\r
-               R_PolygonVertex('1 0 0' * (radar_origin2d_x + radar_size2d_x * 0.5 + radar_extraclip_maxs_x) + '0 1 0' * (radar_origin2d_y - radar_size2d_y * 0.5 + radar_extraclip_mins_y), yinvert(mi_pictexcoord2), rgb, fg);\r
-               R_PolygonVertex('1 0 0' * (radar_origin2d_x + radar_size2d_x * 0.5 + radar_extraclip_maxs_x) + '0 1 0' * (radar_origin2d_y + radar_size2d_y * 0.5 + radar_extraclip_maxs_y), yinvert(mi_pictexcoord3), rgb, fg);\r
-               R_PolygonVertex('1 0 0' * (radar_origin2d_x - radar_size2d_x * 0.5 + radar_extraclip_mins_x) + '0 1 0' * (radar_origin2d_y + radar_size2d_y * 0.5 + radar_extraclip_maxs_y), yinvert(mi_pictexcoord0), rgb, fg);\r
+               R_PolygonVertex(pos1, yinvert(mi_pictexcoord1), rgb, fg);\r
+               R_PolygonVertex(pos2, yinvert(mi_pictexcoord2), rgb, fg);\r
+               R_PolygonVertex(pos3, yinvert(mi_pictexcoord3), rgb, fg);\r
+               R_PolygonVertex(pos4, yinvert(mi_pictexcoord0), rgb, fg);\r
                R_EndPolygon();\r
        }\r
 }\r
@@ -208,7 +211,7 @@ float cl_radar_zoommode;
 void radar_loadcvars()\r
 {\r
        v_flipped = cvar("v_flipped");\r
-       if(ons_showmap)\r
+       if(showmap)\r
        {\r
                cl_radar_scale = 42; // dummy, not used (see zoommode)\r
                cl_radar_content_alpha = 1 * (1 - cvar("_menu_alpha"));\r
@@ -250,12 +253,12 @@ void radar_loadcvars()
 \r
 void() radar_view =\r
 {\r
-       local float color1; // color already declared as a global in hud.qc\r
+       local float col; // color already declared as a global in hud.qc\r
        local entity tm;\r
        float scale2d, normalsize, bigsize;\r
        float f;\r
 \r
-       if(minimapname == "" && !ons_showmap)\r
+       if(minimapname == "" && !showmap)\r
                return;\r
 \r
        radar_loadcvars();\r
@@ -354,7 +357,7 @@ void() radar_view =
 \r
        draw_radar_background(cl_radar_content_alpha, cl_radar_background_alpha, cl_radar_foreground_alpha);\r
 \r
-       if(ons_showmap)\r
+       if(showmap)\r
        {\r
                drawresetcliparea();\r
                drawsetcliparea(\r
@@ -371,9 +374,9 @@ void() radar_view =
                draw_radar_icon(tm.origin, tm.radar_icon, tm, tm.radar_color, tm.alpha * sbar_alpha_fg);\r
        for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )\r
        {\r
-               color1 = GetPlayerColor(tm.sv_entnum);\r
-               //if(color == COLOR_SPECTATOR || color == color1)\r
-                       draw_radar_player(tm.origin, tm.angles, GetTeamRGB(color1));\r
+               col = GetPlayerColor(tm.sv_entnum);\r
+               //if(color == COLOR_SPECTATOR || color == col)\r
+                       draw_radar_player(tm.origin, tm.angles, GetTeamRGB(col));\r
        }\r
        draw_radar_player(view_origin, view_angles, '1 1 1');\r
 \r