From: TimePath <andrew.hardaker1995@gmail.com>
Date: Thu, 8 Oct 2015 03:39:10 +0000 (+1100)
Subject: Radar icons: fix colour
X-Git-Tag: xonotic-v0.8.2~1850
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=81b0f2bc5760bb652515453ac450f2822a98b725;p=xonotic%2Fxonotic-data.pk3dir.git

Radar icons: fix colour
---

diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc
index eb577f46bf..b229917249 100644
--- a/qcsrc/client/hud.qc
+++ b/qcsrc/client/hud.qc
@@ -16,6 +16,7 @@
 #include "../common/mapinfo.qh"
 #include "../common/nades/all.qh"
 
+#include "../common/mutators/mutator/waypoints/all.qh"
 #include "../server/mutators/gamemode_ctf.qh"
 
 #include "../common/stats.qh"
@@ -2240,8 +2241,8 @@ void HUD_Radar(void)
 				drawpic(coord - '8 8 0', "gfx/teamradar_icon_glow", '16 16 0', brightcolor, panel_fg_alpha, 0);
 			}
 		}
-
-		draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
+		entity icon = RadarIcons[tm.teamradar_icon];
+		draw_teamradar_icon(tm.origin, icon, tm, spritelookupcolor(tm, icon.netname, tm.teamradar_color), panel_fg_alpha);
 	}
 	for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
 	{
diff --git a/qcsrc/client/teamradar.qc b/qcsrc/client/teamradar.qc
index 8eaf7e4c22..7623e9df86 100644
--- a/qcsrc/client/teamradar.qc
+++ b/qcsrc/client/teamradar.qc
@@ -132,10 +132,10 @@ void draw_teamradar_player(vector coord3d, vector pangles, vector rgb)
 	R_EndPolygon();
 }
 
-void draw_teamradar_icon(vector coord, float icon, entity pingdata, vector rgb, float a)
+void draw_teamradar_icon(vector coord, entity icon, entity pingdata, vector rgb, float a)
 {
 	coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord));
-	drawpic(coord - '4 4 0', strcat("gfx/teamradar_icon_", ftos(icon)), '8 8 0', rgb, a, 0);
+	drawpic(coord - '4 4 0', strcat("gfx/teamradar_icon_", ftos(icon.m_radaricon)), '8 8 0', rgb, a, 0);
 
 	if(pingdata)
 	{
diff --git a/qcsrc/client/teamradar.qh b/qcsrc/client/teamradar.qh
index 8aefc0fad1..78ef5ee714 100644
--- a/qcsrc/client/teamradar.qh
+++ b/qcsrc/client/teamradar.qh
@@ -41,7 +41,7 @@ void draw_teamradar_background(float fg);
 
 void draw_teamradar_player(vector coord3d, vector pangles, vector rgb);
 
-void draw_teamradar_icon(vector coord, float icon, entity pingdata, vector rgb, float a);
+void draw_teamradar_icon(vector coord, entity icon, entity pingdata, vector rgb, float a);
 
 void draw_teamradar_link(vector start, vector end, int colors);
 
diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh
index 2fcd63c24f..a4329ad445 100644
--- a/qcsrc/common/constants.qh
+++ b/qcsrc/common/constants.qh
@@ -134,20 +134,6 @@ const int SPRITERULE_DEFAULT = 0;
 const int SPRITERULE_TEAMPLAY = 1;
 const int SPRITERULE_SPECTATOR = 2;
 
-const int RADARICON_NONE = 0;
-const int RADARICON_FLAG = 1;
-const int RADARICON_FLAGCARRIER = 1;
-const int RADARICON_HERE = 1; // TODO make these 3 and 4, and make images for them
-const int RADARICON_DANGER = 1;
-const int RADARICON_WAYPOINT = 1;
-const int RADARICON_HELPME = 1;
-const int RADARICON_CONTROLPOINT = 1;
-const int RADARICON_GENERATOR = 1;
-const int RADARICON_OBJECTIVE = 1;
-const int RADARICON_DOMPOINT = 1;
-const int RADARICON_POWERUP = 1;
-const int RADARICON_TAGGED = 1;
-
 ///////////////////////////
 // keys pressed
 const int KEY_FORWARD = 1;
diff --git a/qcsrc/common/mutators/mutator/waypoints/all.inc b/qcsrc/common/mutators/mutator/waypoints/all.inc
index e1153c2b82..47fafe7ed5 100644
--- a/qcsrc/common/mutators/mutator/waypoints/all.inc
+++ b/qcsrc/common/mutators/mutator/waypoints/all.inc
@@ -1,6 +1,4 @@
 /** If you register a new waypoint, make sure to add it to this list */
-REGISTER_WAYPOINT(, "", '0 0 0', 1);
-#define WP_Null WP_
 
 REGISTER_WAYPOINT(Waypoint, _("Waypoint"), '0 1 1', 1);
 REGISTER_WAYPOINT(Helpme, _("Help me!"), '1 0.5 0', 1);
diff --git a/qcsrc/common/mutators/mutator/waypoints/all.qh b/qcsrc/common/mutators/mutator/waypoints/all.qh
index 6120888dba..f7fd03837d 100644
--- a/qcsrc/common/mutators/mutator/waypoints/all.qh
+++ b/qcsrc/common/mutators/mutator/waypoints/all.qh
@@ -25,6 +25,34 @@ ENDCLASS(Waypoint)
 
 #define REGISTER_WAYPOINT(id, text, color, blink) REGISTER_WAYPOINT_(id, NEW(Waypoint, #id, text, color, blink))
 
+REGISTRY(RadarIcons, BITS(7))
+REGISTER_REGISTRY(RegisterRadarIcons)
+.int m_radaricon;
+#define REGISTER_RADARICON(id, num) REGISTER(RegisterRadarIcons, RADARICON, RadarIcons, id, m_id, new(RadarIcon)) { this.m_radaricon = num; this.netname = #id; }
+
+REGISTER_WAYPOINT(Null, "", '0 0 0', 1);
+
+REGISTER_RADARICON(NONE,            0);
+REGISTER_RADARICON(FLAG,            1);
+REGISTER_RADARICON(FLAGCARRIER,     1);
+
+// TODO make these 3 and 4, and make images for them
+REGISTER_RADARICON(HERE,            1);
+REGISTER_RADARICON(DANGER,          1);
+
+REGISTER_RADARICON(WAYPOINT,        1);
+REGISTER_RADARICON(HELPME,          1);
+REGISTER_RADARICON(CONTROLPOINT,    1);
+REGISTER_RADARICON(GENERATOR,       1);
+REGISTER_RADARICON(OBJECTIVE,       1);
+REGISTER_RADARICON(DOMPOINT,        1);
+REGISTER_RADARICON(TAGGED,          1);
+
+REGISTER_RADARICON(Buff,            1);
+REGISTER_RADARICON(Item,            1);
+REGISTER_RADARICON(Vehicle,         1);
+REGISTER_RADARICON(Weapon,          1);
+
 #include "all.inc"
 
 #endif
diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
index 9adf1a95ba..3be3266bc3 100644
--- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
+++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
@@ -210,8 +210,8 @@ void Ent_WaypointSprite()
     if (sendflags & 32)
     {
         int f = ReadByte();
-        self.teamradar_icon = (f & 0x7F);
-        if (f & 0x80)
+        self.teamradar_icon = f & BITS(7);
+        if (f & BIT(7))
         {
             self.(teamradar_times[self.teamradar_time_index]) = time;
             self.teamradar_time_index = (self.teamradar_time_index + 1) % MAX_TEAMRADAR_TIMES;
@@ -242,11 +242,11 @@ float spritelookupblinkvalue(string s)
     return 1;
 }
 
-vector spritelookupcolor(string s, vector def)
-{SELFPARAM();
-    if (s == WP_Weapon.netname) return get_weaponinfo(self.wp_extra).wpcolor;
-    if (s == WP_Item.netname) return Items[self.wp_extra].m_color;
-    if (s == WP_Buff.netname) return Buffs[self.wp_extra].m_color;
+vector spritelookupcolor(entity this, string s, vector def)
+{
+    if (s == WP_Weapon.netname  || s == RADARICON_Weapon.netname) return get_weaponinfo(this.wp_extra).wpcolor;
+    if (s == WP_Item.netname    || s == RADARICON_Item.netname) return Items[this.wp_extra].m_color;
+    if (s == WP_Buff.netname    || s == RADARICON_Buff.netname) return Buffs[this.wp_extra].m_color;
     return def;
 }
 
@@ -529,7 +529,7 @@ void Draw_WaypointSprite(entity this)
     else if (self.maxdistance > 0)
         a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
 
-    vector rgb = spritelookupcolor(spriteimage, self.teamradar_color);
+    vector rgb = spritelookupcolor(self, spriteimage, self.teamradar_color);
     if (rgb == '0 0 0')
     {
         self.teamradar_color = '1 0 1';
@@ -827,10 +827,11 @@ void WaypointSprite_UpdateRule(entity e, float t, float r)
     e.SendFlags |= 1;
 }
 
-void WaypointSprite_UpdateTeamRadar(entity e, float icon, vector col)
+void WaypointSprite_UpdateTeamRadar(entity e, entity icon, vector col)
 {
     // no check, as this is never called without doing an actual change (usually only once)
-    e.cnt = (icon & 0x7F) | (e.cnt & 0x80);
+    int i = icon.m_id;
+    e.cnt = (e.cnt & BIT(7)) | (i & BITS(7));
     e.colormod = col;
     e.SendFlags |= 32;
 }
@@ -841,7 +842,7 @@ void WaypointSprite_Ping(entity e)
     if (time < e.waypointsprite_pingtime) return;
     e.waypointsprite_pingtime = time + 0.3;
     // ALWAYS sends (this causes a radar circle), thus no check
-    e.cnt |= 0x80;
+    e.cnt |= BIT(7);
     e.SendFlags |= 32;
 }
 
@@ -1001,7 +1002,7 @@ entity WaypointSprite_Spawn(
     entity showto, float t, // show to whom? Use a flag to indicate a team
     entity own, .entity ownfield, // remove when own gets killed
     float hideable, // true when it should be controlled by cl_hidewaypoints
-    float icon // initial icon
+    entity icon // initial icon
 )
 {
     entity wp = new(sprite_waypoint);
@@ -1033,7 +1034,7 @@ entity WaypointSprite_Spawn(
     wp.customizeentityforclient = WaypointSprite_Customize;
     wp.waypointsprite_visible_for_player = WaypointSprite_visible_for_player;
     wp.reset2 = WaypointSprite_Reset;
-    wp.cnt = icon;
+    wp.cnt = icon.m_id;
     wp.colormod = spr.m_color;
     Net_LinkEntity(wp, false, 0, WaypointSprite_SendEntity);
     return wp;
@@ -1044,7 +1045,7 @@ entity WaypointSprite_SpawnFixed(
     vector ofs,
     entity own,
     .entity ownfield,
-    float icon // initial icon
+    entity icon // initial icon
 )
 {
     return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, own, ownfield, true, icon);
@@ -1054,7 +1055,7 @@ entity WaypointSprite_DeployFixed(
     entity spr,
     float limited_range,
     vector ofs,
-    float icon // initial icon
+    entity icon // initial icon
 )
 {SELFPARAM();
     float t;
@@ -1073,7 +1074,7 @@ entity WaypointSprite_DeployFixed(
 entity WaypointSprite_DeployPersonal(
     entity spr,
     vector ofs,
-    float icon // initial icon
+    entity icon // initial icon
 )
 {SELFPARAM();
     return WaypointSprite_Spawn(spr, 0, 0, world, ofs, world, 0, self, waypointsprite_deployed_personal, false, icon);
@@ -1082,7 +1083,7 @@ entity WaypointSprite_DeployPersonal(
 entity WaypointSprite_Attach(
     entity spr,
     float limited_range,
-    float icon // initial icon
+    entity icon // initial icon
 )
 {SELFPARAM();
     float t;
@@ -1103,7 +1104,7 @@ entity WaypointSprite_Attach(
 entity WaypointSprite_AttachCarrier(
     entity spr,
     entity carrier,
-    float icon // initial icon and color
+    entity icon // initial icon and color
 )
 {
     WaypointSprite_Kill(carrier.waypointsprite_attached); // FC overrides attached
diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh
index 2be4ff8fdd..c9a5534319 100644
--- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh
+++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh
@@ -98,7 +98,7 @@ vector drawspritearrow(vector o, float ang, vector rgb, float a, float t);
 vector drawspritetext(vector o, float ang, float minwidth, vector rgb, float a, vector fontsize, string s);
 
 float spritelookupblinkvalue(string s);
-vector spritelookupcolor(string s, vector def);
+vector spritelookupcolor(entity this, string s, vector def);
 string spritelookuptext(string s);
 
 vector fixrgbexcess_move(vector rgb, vector src, vector dst);
@@ -142,7 +142,7 @@ void WaypointSprite_UpdateOrigin(entity e, vector o);
 
 void WaypointSprite_UpdateRule(entity e, float t, float r);
 
-void WaypointSprite_UpdateTeamRadar(entity e, float icon, vector col);
+void WaypointSprite_UpdateTeamRadar(entity e, entity icon, vector col);
 
 .float waypointsprite_pingtime;
 .float waypointsprite_helpmetime;
@@ -182,7 +182,7 @@ entity WaypointSprite_Spawn(
     entity showto, float t, // show to whom? Use a flag to indicate a team
     entity own, .entity ownfield, // remove when own gets killed
     float hideable, // true when it should be controlled by cl_hidewaypoints
-    float icon // initial icon
+    entity icon // initial icon
 );
 
 entity WaypointSprite_SpawnFixed(
@@ -190,7 +190,7 @@ entity WaypointSprite_SpawnFixed(
     vector ofs,
     entity own,
     .entity ownfield,
-    float icon // initial icon
+    entity icon // initial icon
 );
 
 .entity waypointsprite_deployed_fixed;
@@ -198,14 +198,14 @@ entity WaypointSprite_DeployFixed(
     entity spr,
     float limited_range,
     vector ofs,
-    float icon // initial icon
+    entity icon // initial icon
 );
 
 .entity waypointsprite_deployed_personal;
 entity WaypointSprite_DeployPersonal(
     entity spr,
     vector ofs,
-    float icon // initial icon
+    entity icon // initial icon
 );
 
 .entity waypointsprite_attached;
@@ -213,13 +213,13 @@ entity WaypointSprite_DeployPersonal(
 entity WaypointSprite_Attach(
     entity spr,
     float limited_range,
-    float icon // initial icon
+    entity icon // initial icon
 );
 
 entity WaypointSprite_AttachCarrier(
     entity spr,
     entity carrier,
-    float icon // initial icon
+    entity icon // initial icon
 );
 
 void WaypointSprite_DetachCarrier(entity carrier);
diff --git a/qcsrc/common/turrets/cl_turrets.qc b/qcsrc/common/turrets/cl_turrets.qc
index e62a4cc357..582113cf80 100644
--- a/qcsrc/common/turrets/cl_turrets.qc
+++ b/qcsrc/common/turrets/cl_turrets.qc
@@ -99,7 +99,7 @@ void turret_draw2d(entity this)
 
 	string spriteimage = self.netname;
 	float a = self.alpha * autocvar_hud_panel_fg_alpha;
-	vector rgb = spritelookupcolor(spriteimage, self.teamradar_color);
+	vector rgb = spritelookupcolor(self, spriteimage, self.teamradar_color);
 
 
 	if(self.maxdistance > waypointsprite_normdistance)
diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc
index c2e41dd941..7108e80770 100644
--- a/qcsrc/common/vehicles/sv_vehicles.qc
+++ b/qcsrc/common/vehicles/sv_vehicles.qc
@@ -529,7 +529,7 @@ void vehicles_showwp()
 		rgb = Team_ColorRGB(self.team);
 	else
 		rgb = '1 1 1';
-	entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_POWERUP);
+	entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Vehicle);
 	wp.colormod = rgb;
 	if(self.waypointsprite_attached)
 	{
diff --git a/qcsrc/server/mutators/mutator_buffs.qc b/qcsrc/server/mutators/mutator_buffs.qc
index da47be4159..7aeadce75e 100644
--- a/qcsrc/server/mutators/mutator_buffs.qc
+++ b/qcsrc/server/mutators/mutator_buffs.qc
@@ -92,9 +92,9 @@ float buff_Waypoint_visible_for_player(entity plr)
 void buff_Waypoint_Spawn(entity e)
 {
 	entity buff = buff_FirstFromFlags(e.buffs);
-	entity wp = WaypointSprite_Spawn(WP_Buff, 0, autocvar_g_buffs_waypoint_distance, e, '0 0 1' * e.maxs.z, world, e.team, e, buff_waypoint, true, RADARICON_POWERUP);
+	entity wp = WaypointSprite_Spawn(WP_Buff, 0, autocvar_g_buffs_waypoint_distance, e, '0 0 1' * e.maxs.z, world, e.team, e, buff_waypoint, true, RADARICON_Buff);
 	wp.wp_extra = buff.m_id;
-	WaypointSprite_UpdateTeamRadar(e.buff_waypoint, RADARICON_POWERUP, e.glowmod);
+	WaypointSprite_UpdateTeamRadar(e.buff_waypoint, RADARICON_Buff, e.glowmod);
 	e.buff_waypoint.waypointsprite_visible_for_player = buff_Waypoint_visible_for_player;
 }
 
diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc
index e93ee2d7e1..0a5785037f 100644
--- a/qcsrc/server/t_items.qc
+++ b/qcsrc/server/t_items.qc
@@ -476,7 +476,7 @@ void Item_RespawnCountdown (void)
 				{
 					entity wi = get_weaponinfo(self.weapon);
 					if (wi.m_id) {
-						entity wp = WaypointSprite_Spawn(WP_Weapon, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_POWERUP);
+						entity wp = WaypointSprite_Spawn(WP_Weapon, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Weapon);
 						wp.wp_extra = wi.m_id;
 						break;
 					}
@@ -484,7 +484,7 @@ void Item_RespawnCountdown (void)
 				{
 					entity ii = self.itemdef;
 					if (ii.m_id) {
-						entity wp = WaypointSprite_Spawn(WP_Item, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_POWERUP);
+						entity wp = WaypointSprite_Spawn(WP_Item, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Item);
 						wp.wp_extra = ii.m_id;
 						break;
 					}