]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Don't depend on self for draw2d
authorMario <mario@smbclan.net>
Sun, 3 Jan 2016 14:57:57 +0000 (00:57 +1000)
committerMario <mario@smbclan.net>
Sun, 3 Jan 2016 14:57:57 +0000 (00:57 +1000)
qcsrc/client/view.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/turrets/cl_turrets.qc
qcsrc/common/vehicles/cl_vehicles.qc

index 1999bfb5acd34783d6309f538330aefa3e3e649b..8752f6dcf4039707b765d6f0e8bb6d120e54a42c 100644 (file)
@@ -2169,7 +2169,7 @@ void CSQC_UpdateView(float w, float h)
          } else */
 
        // draw 2D entities
-       FOREACH_ENTITY(it.draw2d, LAMBDA(WITH(entity, self, it, it.draw2d(it))));
+       FOREACH_ENTITY(it.draw2d, it.draw2d(it));
        Draw_ShowNames_All();
        Debug_Draw();
 
index 3c3cf7f562ca5cb499b4e6a7556e12d0e8cada98..88683b518fd0604618356abf158ce445f93c2555 100644 (file)
@@ -452,29 +452,29 @@ vector fixrgbexcess(vector rgb)
 
 void Draw_WaypointSprite(entity this)
 {
-    if (self.lifetime)
-        self.alpha = pow(bound(0, (self.fadetime - time) / self.lifetime, 1), waypointsprite_timealphaexponent);
+    if (this.lifetime)
+        this.alpha = pow(bound(0, (this.fadetime - time) / this.lifetime, 1), waypointsprite_timealphaexponent);
     else
-        self.alpha = 1;
+        this.alpha = 1;
 
-    if (self.hideflags & 2)
+    if (this.hideflags & 2)
         return; // radar only
 
     if (autocvar_cl_hidewaypoints >= 2)
         return;
 
-    if (self.hideflags & 1)
+    if (this.hideflags & 1)
         if (autocvar_cl_hidewaypoints)
             return; // fixed waypoint
 
-    InterpolateOrigin_Do(self);
+    InterpolateOrigin_Do(this);
 
     float t = entcs_GetTeam(player_localnum) + 1;
 
     string spriteimage = "";
 
     // choose the sprite
-    switch (self.rule)
+    switch (this.rule)
     {
         case SPRITERULE_SPECTATOR:
             if (!(
@@ -482,26 +482,26 @@ void Draw_WaypointSprite(entity this)
             || (autocvar_g_waypointsprite_itemstime == 2 && (t == NUM_SPECTATOR + 1 || warmup_stage))
                 ))
                 return;
-            spriteimage = self.netname;
+            spriteimage = this.netname;
             break;
         case SPRITERULE_DEFAULT:
-            if (self.team)
+            if (this.team)
             {
-                if (self.team == t)
-                    spriteimage = self.netname;
+                if (this.team == t)
+                    spriteimage = this.netname;
                 else
                     spriteimage = "";
             }
             else
-                spriteimage = self.netname;
+                spriteimage = this.netname;
             break;
         case SPRITERULE_TEAMPLAY:
             if (t == NUM_SPECTATOR + 1)
-                spriteimage = self.netname3;
-            else if (self.team == t)
-                spriteimage = self.netname2;
+                spriteimage = this.netname3;
+            else if (this.team == t)
+                spriteimage = this.netname2;
             else
-                spriteimage = self.netname;
+                spriteimage = this.netname;
             break;
         default:
             error("Invalid waypointsprite rule!");
@@ -514,28 +514,28 @@ void Draw_WaypointSprite(entity this)
     ++waypointsprite_newcount;
 
     float dist;
-    dist = vlen(self.origin - view_origin);
+    dist = vlen(this.origin - view_origin);
 
     float a;
-    a = self.alpha * autocvar_hud_panel_fg_alpha;
+    a = this.alpha * autocvar_hud_panel_fg_alpha;
 
-    if (self.maxdistance > waypointsprite_normdistance)
-        a *= pow(bound(0, (self.maxdistance - dist) / (self.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
-    else if (self.maxdistance > 0)
+    if (this.maxdistance > waypointsprite_normdistance)
+        a *= pow(bound(0, (this.maxdistance - dist) / (this.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
+    else if (this.maxdistance > 0)
         a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
 
-    vector rgb = spritelookupcolor(self, spriteimage, self.teamradar_color);
+    vector rgb = spritelookupcolor(this, spriteimage, this.teamradar_color);
     if (rgb == '0 0 0')
     {
-        self.teamradar_color = '1 0 1';
+        this.teamradar_color = '1 0 1';
         LOG_INFOF("WARNING: sprite of name %s has no color, using pink so you notice it\n", spriteimage);
     }
 
     if (time - floor(time) > 0.5)
     {
-        if (self.helpme && time < self.helpme)
+        if (this.helpme && time < this.helpme)
             a *= SPRITE_HELPME_BLINK;
-        else if (!self.lifetime) // fading out waypoints don't blink
+        else if (!this.lifetime) // fading out waypoints don't blink
             a *= spritelookupblinkvalue(spriteimage);
     }
 
@@ -553,7 +553,7 @@ void Draw_WaypointSprite(entity this)
     vector o;
     float ang;
 
-    o = project_3d_to_2d(self.origin);
+    o = project_3d_to_2d(this.origin);
     if (o.z < 0
     || o.x < (vid_conwidth * waypointsprite_edgeoffset_left)
     || o.y < (vid_conheight * waypointsprite_edgeoffset_top)
@@ -629,19 +629,19 @@ void Draw_WaypointSprite(entity this)
         t = t * (1 - (1 - waypointsprite_crosshairfadescale) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
     }
 
-    if (self.build_finished)
+    if (this.build_finished)
     {
-        if (time < self.build_finished + 0.25)
+        if (time < this.build_finished + 0.25)
         {
-            if (time < self.build_started)
-                self.health = self.build_starthealth;
-            else if (time < self.build_finished)
-                self.health = (time - self.build_started) / (self.build_finished - self.build_started) * (1 - self.build_starthealth) + self.build_starthealth;
+            if (time < this.build_started)
+                this.health = this.build_starthealth;
+            else if (time < this.build_finished)
+                this.health = (time - this.build_started) / (this.build_finished - this.build_started) * (1 - this.build_starthealth) + this.build_starthealth;
             else
-                self.health = 1;
+                this.health = 1;
         }
         else
-            self.health = -1;
+            this.health = -1;
     }
 
     o = drawspritearrow(o, ang, rgb, a, SPRITE_ARROW_SCALE * t);
@@ -651,18 +651,18 @@ void Draw_WaypointSprite(entity this)
         txt = _("Spam");
     else
         txt = spritelookuptext(spriteimage);
-    if (self.helpme && time < self.helpme)
+    if (this.helpme && time < this.helpme)
         txt = sprintf(_("%s needing help!"), txt);
     if (autocvar_g_waypointsprite_uppercase)
         txt = strtoupper(txt);
 
     draw_beginBoldFont();
-    if (self.health >= 0)
+    if (this.health >= 0)
     {
         o = drawspritetext(o, ang, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
 
         float align, marg;
-        if (self.build_finished)
+        if (this.build_finished)
             align = 0.5;
         else
             align = 0;
@@ -673,7 +673,7 @@ void Draw_WaypointSprite(entity this)
         drawhealthbar(
                 o,
                 0,
-                self.health,
+                this.health,
                 '0 0 0',
                 '0 0 0',
                 SPRITE_HEALTHBAR_WIDTH * t,
index 31c22480fc676fe5e8f078824a4f9b239e22f633..99f0139bff627929a68a5643be6429552c2ed2a5 100644 (file)
@@ -55,7 +55,7 @@ void turret_draw(entity this)
 
 void turret_draw2d(entity this)
 {
-       if(self.netname == "")
+       if(this.netname == "")
                return;
 
        if(!autocvar_g_waypointsprite_turrets)
@@ -64,17 +64,17 @@ void turret_draw2d(entity this)
        if(autocvar_cl_hidewaypoints)
                return;
 
-       float dist = vlen(self.origin - view_origin);
+       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 != self.team)
+       if(dist < 10240 && t != this.team)
        {
                // TODO: Vehicle tactical hud
-               o = project_3d_to_2d(self.origin + '0 0 32');
+               o = project_3d_to_2d(this.origin + '0 0 32');
                if(o_z < 0
                || o_x < (vid_conwidth * waypointsprite_edgeoffset_left)
                || o_y < (vid_conheight * waypointsprite_edgeoffset_top)
@@ -84,7 +84,7 @@ void turret_draw2d(entity this)
                o_z = 0;
                if(hud != HUD_NORMAL)
                {
-                       if((get_turretinfo(self.m_id)).spawnflags & TUR_FLAG_MOVE)
+                       if((get_turretinfo(this.m_id)).spawnflags & TUR_FLAG_MOVE)
                                txt = "gfx/vehicles/turret_moving.tga";
                        else
                                txt = "gfx/vehicles/turret_stationary.tga";
@@ -94,34 +94,34 @@ void turret_draw2d(entity this)
                }
        }
 
-       if(dist > self.maxdistance)
+       if(dist > this.maxdistance)
                return;
 
-       string spriteimage = self.netname;
-       float a = self.alpha * autocvar_hud_panel_fg_alpha;
-       vector rgb = spritelookupcolor(self, spriteimage, self.teamradar_color);
+       string spriteimage = this.netname;
+       float a = this.alpha * autocvar_hud_panel_fg_alpha;
+       vector rgb = spritelookupcolor(this, spriteimage, this.teamradar_color);
 
 
-       if(self.maxdistance > waypointsprite_normdistance)
-               a *= pow(bound(0, (self.maxdistance - dist) / (self.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
-       else if(self.maxdistance > 0)
+       if(this.maxdistance > waypointsprite_normdistance)
+               a *= pow(bound(0, (this.maxdistance - dist) / (this.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
+       else if(this.maxdistance > 0)
                a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
 
        if(rgb == '0 0 0')
        {
-               self.teamradar_color = '1 0 1';
+               this.teamradar_color = '1 0 1';
                LOG_INFOF("WARNING: sprite of name %s has no color, using pink so you notice it\n", spriteimage);
        }
 
-       txt = self.netname;
+       txt = this.netname;
        if(autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
                txt = _("Spam");
        else
                txt = spritelookuptext(spriteimage);
 
-       if(time - floor(time) > 0.5 && t == self.team)
+       if(time - floor(time) > 0.5 && t == this.team)
        {
-               if(self.helpme && time < self.helpme)
+               if(this.helpme && time < this.helpme)
                {
                        a *= SPRITE_HELPME_BLINK;
                        txt = sprintf(_("%s under attack!"), txt);
@@ -144,7 +144,7 @@ void turret_draw2d(entity this)
 
        rgb = fixrgbexcess(rgb);
 
-       o = project_3d_to_2d(self.origin + '0 0 64');
+       o = project_3d_to_2d(this.origin + '0 0 64');
        if(o_z < 0
        || o_x < (vid_conwidth * waypointsprite_edgeoffset_left)
        || o_y < (vid_conheight * waypointsprite_edgeoffset_top)
@@ -185,7 +185,7 @@ void turret_draw2d(entity this)
        drawhealthbar(
                        o,
                        0,
-                       self.health / 255,
+                       this.health / 255,
                        '0 0 0',
                        '0 0 0',
                        0.5 * SPRITE_HEALTHBAR_WIDTH * t,
index 1733a63cc39c8bfcad8cf52e6fa3180c6c76a570..a3c07a03ddbcb61f0c283f5c702d660852a3a508 100644 (file)
@@ -31,18 +31,18 @@ void AuxiliaryXhair_Draw2D(entity this)
        if (scoreboard_active)
                return;
 
-       vector size = draw_getimagesize(self.axh_image) * autocvar_cl_vehicles_crosshair_size;
-       vector pos = project_3d_to_2d(self.move_origin) - 0.5 * size;
+       vector size = draw_getimagesize(this.axh_image) * autocvar_cl_vehicles_crosshair_size;
+       vector pos = project_3d_to_2d(this.move_origin) - 0.5 * size;
 
        if (!(pos.z < 0 || pos.x < 0 || pos.y < 0 || pos.x > vid_conwidth || pos.y > vid_conheight))
        {
                pos.z = 0;
                size.z = 0;
-               drawpic(pos, self.axh_image, size, self.colormod, autocvar_crosshair_alpha * self.alpha, self.axh_drawflag);
+               drawpic(pos, this.axh_image, size, this.colormod, autocvar_crosshair_alpha * this.alpha, this.axh_drawflag);
        }
 
-       if(time - self.cnt > self.axh_fadetime)
-               self.draw2d = func_null;
+       if(time - this.cnt > this.axh_fadetime)
+               this.draw2d = func_null;
 }
 
 NET_HANDLE(ENT_CLIENT_AUXILIARYXHAIR, bool isnew)