]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/cl_turrets.qc
Show to spectators all the waypoints that are shown to spectated players. It fixes...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / cl_turrets.qc
index 79f1f216fff93bcf18ad7ded7fae17cb5c9ced43..48c6a8798981269b18d83e41c1351f0b23d41640 100644 (file)
@@ -1,3 +1,4 @@
+#include "cl_turrets.qh"
 void turret_remove(entity this)
 {
        delete(this.tur_head);
@@ -66,13 +67,12 @@ void turret_draw2d(entity this)
                return;
 
        float dist = vlen(this.origin - view_origin);
-       float t = (entcs_GetTeam(player_localnum) + 1);
 
        vector o;
        string txt;
 
        if(autocvar_cl_vehicles_hud_tactical)
-       if(dist < 10240 && t != this.team)
+       if(dist < 10240 && (myteam + 1 != this.team))
        {
                // TODO: Vehicle tactical hud
                o = project_3d_to_2d(this.origin + '0 0 32');
@@ -120,7 +120,7 @@ void turret_draw2d(entity this)
        else
                txt = spritelookuptext(this, spriteimage);
 
-       if(time - floor(time) > 0.5 && t == this.team)
+       if(time - floor(time) > 0.5 && (myteam + 1 == this.team))
        {
                if(this.helpme && time < this.helpme)
                {
@@ -155,17 +155,14 @@ void turret_draw2d(entity this)
 
        o_z = 0;
 
-       float edgedistance_min, crosshairdistance;
-               edgedistance_min = min((o_y - (vid_conheight * waypointsprite_edgeoffset_top)),
+       float edgedistance_min = min((o.y - (vid_conheight * waypointsprite_edgeoffset_top)),
        (o_x - (vid_conwidth * waypointsprite_edgeoffset_left)),
        (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o_x,
        (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o_y);
 
-       float vidscale = max(vid_conwidth / vid_width, vid_conheight / vid_height);
+       float crosshairdistance = sqrt( pow(o.x - vid_conwidth/2, 2) + pow(o.y - vid_conheight/2, 2) );
 
-       crosshairdistance = sqrt( pow(o_x - vid_conwidth/2, 2) + pow(o_y - vid_conheight/2, 2) );
-
-       t = waypointsprite_scale * vidscale;
+       float t = waypointsprite_scale;
        a *= waypointsprite_alpha;
 
        {
@@ -202,7 +199,7 @@ void turret_draw2d(entity this)
                        );
 }
 
-void turret_construct(entity this)
+void turret_construct(entity this, bool isnew)
 {
        entity tur = get_turretinfo(this.m_id);
 
@@ -238,11 +235,16 @@ void turret_construct(entity this)
        this.tur_head.drawmask                  = MASK_NORMAL;
        this.anim_start_time                    = 0;
        this.draw2d = turret_draw2d;
-       IL_PUSH(g_drawables_2d, this);
        this.maxdistance = autocvar_g_waypointsprite_turrets_maxdist;
        this.teamradar_color = '1 0 0';
        this.alpha = 1;
 
+       if(isnew)
+       {
+               IL_PUSH(g_drawables, this);
+               IL_PUSH(g_drawables_2d, this);
+       }
+
        tur.tr_setup(tur, this);
 }
 
@@ -370,7 +372,7 @@ NET_HANDLE(ENT_CLIENT_TURRET, bool isnew)
                this.angles_x = ReadAngle();
                this.angles_y = ReadAngle();
 
-               turret_construct(this);
+               turret_construct(this, isnew);
                this.colormap = 1024;
                this.glowmod = '0 1 1';
                this.tur_head.colormap = this.colormap;