#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"
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")); )
{
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)
{
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);
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;
/** 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);
#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
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;
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;
}
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';
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;
}
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;
}
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);
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;
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);
entity spr,
float limited_range,
vector ofs,
- float icon // initial icon
+ entity icon // initial icon
)
{SELFPARAM();
float t;
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);
entity WaypointSprite_Attach(
entity spr,
float limited_range,
- float icon // initial icon
+ entity icon // initial icon
)
{SELFPARAM();
float t;
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
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);
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;
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(
vector ofs,
entity own,
.entity ownfield,
- float icon // initial icon
+ entity icon // initial icon
);
.entity waypointsprite_deployed_fixed;
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;
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);
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)
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)
{
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;
}
{
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;
}
{
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;
}