]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Hopefully fix a potential crash
authorMario <mario@smbclan.net>
Sun, 3 Jan 2016 15:50:00 +0000 (01:50 +1000)
committerMario <mario@smbclan.net>
Sun, 3 Jan 2016 15:50:00 +0000 (01:50 +1000)
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh
qcsrc/common/turrets/cl_turrets.qc

index 88683b518fd0604618356abf158ce445f93c2555..1cb2766ab93574b5669d987874f2cf8018c98f2e 100644 (file)
@@ -98,9 +98,9 @@ bool WaypointSprite_SendEntity(entity this, entity to, float sendflags)
 #endif
 
 #ifdef CSQC
-void Ent_WaypointSprite();
+void Ent_WaypointSprite(entity this);
 NET_HANDLE(waypointsprites, bool isnew) {
-    Ent_WaypointSprite();
+    Ent_WaypointSprite(this);
     return true;
 }
 
@@ -112,119 +112,119 @@ void Ent_RemoveWaypointSprite(entity this)
 }
 
 /** flags origin [team displayrule] [spritename] [spritename2] [spritename3] [lifetime maxdistance hideable] */
-void Ent_WaypointSprite()
-{SELFPARAM();
+void Ent_WaypointSprite(entity this)
+{
     int sendflags = ReadByte();
-    self.wp_extra = ReadByte();
+    this.wp_extra = ReadByte();
 
-    if (!self.spawntime)
-        self.spawntime = time;
+    if (!this.spawntime)
+        this.spawntime = time;
 
-    self.draw2d = Draw_WaypointSprite;
+    this.draw2d = Draw_WaypointSprite;
 
-    InterpolateOrigin_Undo(self);
-    self.iflags |= IFLAG_ORIGIN;
+    InterpolateOrigin_Undo(this);
+    this.iflags |= IFLAG_ORIGIN;
 
     if (sendflags & 0x80)
     {
         int t = ReadByte();
         if (t < 192)
         {
-            self.health = t / 191.0;
-            self.build_finished = 0;
+            this.health = t / 191.0;
+            this.build_finished = 0;
         }
         else
         {
             t = (t - 192) * 256 + ReadByte();
-            self.build_started = servertime;
-            if (self.build_finished)
-                self.build_starthealth = bound(0, self.health, 1);
+            this.build_started = servertime;
+            if (this.build_finished)
+                this.build_starthealth = bound(0, this.health, 1);
             else
-                self.build_starthealth = 0;
-            self.build_finished = servertime + t / 32;
+                this.build_starthealth = 0;
+            this.build_finished = servertime + t / 32;
         }
     }
     else
     {
-        self.health = -1;
-        self.build_finished = 0;
+        this.health = -1;
+        this.build_finished = 0;
     }
 
     if (sendflags & 64)
     {
         // unfortunately, this needs to be exact (for the 3D display)
-        self.origin_x = ReadCoord();
-        self.origin_y = ReadCoord();
-        self.origin_z = ReadCoord();
-        setorigin(self, self.origin);
+        this.origin_x = ReadCoord();
+        this.origin_y = ReadCoord();
+        this.origin_z = ReadCoord();
+        setorigin(this, this.origin);
     }
 
     if (sendflags & 1)
     {
-        self.team = ReadByte();
-        self.rule = ReadByte();
+        this.team = ReadByte();
+        this.rule = ReadByte();
     }
 
     if (sendflags & 2)
     {
-        if (self.netname)
-            strunzone(self.netname);
-        self.netname = strzone(ReadString());
+        if (this.netname)
+            strunzone(this.netname);
+        this.netname = strzone(ReadString());
     }
 
     if (sendflags & 4)
     {
-        if (self.netname2)
-            strunzone(self.netname2);
-        self.netname2 = strzone(ReadString());
+        if (this.netname2)
+            strunzone(this.netname2);
+        this.netname2 = strzone(ReadString());
     }
 
     if (sendflags & 8)
     {
-        if (self.netname3)
-            strunzone(self.netname3);
-        self.netname3 = strzone(ReadString());
+        if (this.netname3)
+            strunzone(this.netname3);
+        this.netname3 = strzone(ReadString());
     }
 
     if (sendflags & 16)
     {
-        self.lifetime = ReadCoord();
-        self.fadetime = ReadCoord();
-        self.maxdistance = ReadShort();
-        self.hideflags = ReadByte();
+        this.lifetime = ReadCoord();
+        this.fadetime = ReadCoord();
+        this.maxdistance = ReadShort();
+        this.hideflags = ReadByte();
     }
 
     if (sendflags & 32)
     {
         int f = ReadByte();
-        self.teamradar_icon = f & BITS(7);
+        this.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;
+            this.(teamradar_times[this.teamradar_time_index]) = time;
+            this.teamradar_time_index = (this.teamradar_time_index + 1) % MAX_TEAMRADAR_TIMES;
         }
-        self.teamradar_color_x = ReadByte() / 255.0;
-        self.teamradar_color_y = ReadByte() / 255.0;
-        self.teamradar_color_z = ReadByte() / 255.0;
-        self.helpme = ReadByte() * 0.1;
-        if (self.helpme > 0)
-            self.helpme += servertime;
+        this.teamradar_color_x = ReadByte() / 255.0;
+        this.teamradar_color_y = ReadByte() / 255.0;
+        this.teamradar_color_z = ReadByte() / 255.0;
+        this.helpme = ReadByte() * 0.1;
+        if (this.helpme > 0)
+            this.helpme += servertime;
     }
 
     InterpolateOrigin_Note(this);
 
-    self.entremove = Ent_RemoveWaypointSprite;
+    this.entremove = Ent_RemoveWaypointSprite;
 }
 #endif
 
 #ifdef CSQC
-float spritelookupblinkvalue(string s)
-{SELFPARAM();
+float spritelookupblinkvalue(entity this, string s)
+{
     if (s == WP_Weapon.netname) {
-        if (Weapons_from(self.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
+        if (Weapons_from(this.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
             return 2;
     }
-    if (s == WP_Item.netname) return Items_from(self.wp_extra).m_waypointblink;
+    if (s == WP_Item.netname) return Items_from(this.wp_extra).m_waypointblink;
 
     return 1;
 }
@@ -240,12 +240,12 @@ vector spritelookupcolor(entity this, string s, vector def)
     return def;
 }
 
-string spritelookuptext(string s)
-{SELFPARAM();
+string spritelookuptext(entity this, string s)
+{
     if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
-    if (s == WP_Weapon.netname) return Weapons_from(self.wp_extra).m_name;
-    if (s == WP_Item.netname) return Items_from(self.wp_extra).m_waypoint;
-    if (s == WP_Monster.netname) return get_monsterinfo(self.wp_extra).monster_name;
+    if (s == WP_Weapon.netname) return Weapons_from(this.wp_extra).m_name;
+    if (s == WP_Item.netname) return Items_from(this.wp_extra).m_waypoint;
+    if (s == WP_Monster.netname) return get_monsterinfo(this.wp_extra).monster_name;
     if (MUTATOR_CALLHOOK(WP_Format, this, s))
     {
         return MUTATOR_ARGV(0, string);
@@ -536,7 +536,7 @@ void Draw_WaypointSprite(entity this)
         if (this.helpme && time < this.helpme)
             a *= SPRITE_HELPME_BLINK;
         else if (!this.lifetime) // fading out waypoints don't blink
-            a *= spritelookupblinkvalue(spriteimage);
+            a *= spritelookupblinkvalue(this, spriteimage);
     }
 
     if (a > 1)
@@ -650,7 +650,7 @@ void Draw_WaypointSprite(entity this)
     if (autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
         txt = _("Spam");
     else
-        txt = spritelookuptext(spriteimage);
+        txt = spritelookuptext(this, spriteimage);
     if (this.helpme && time < this.helpme)
         txt = sprintf(_("%s needing help!"), txt);
     if (autocvar_g_waypointsprite_uppercase)
index c3f8378b16af8de9e2a97dd72dc8164460b6cad5..843a88d4502430dac3e536e9d5ee4b2839ea4b39 100644 (file)
@@ -97,9 +97,9 @@ vector drawspritearrow(vector o, float ang, vector rgb, float a, float t);
 // returns location of sprite healthbar
 vector drawspritetext(vector o, float ang, float minwidth, vector rgb, float a, vector fontsize, string s);
 
-float spritelookupblinkvalue(string s);
+float spritelookupblinkvalue(entity this, string s);
 vector spritelookupcolor(entity this, string s, vector def);
-string spritelookuptext(string s);
+string spritelookuptext(entity this, string s);
 
 vector fixrgbexcess_move(vector rgb, vector src, vector dst);
 vector fixrgbexcess(vector rgb);
@@ -108,7 +108,7 @@ vector fixrgbexcess(vector rgb);
 
 void Ent_RemoveWaypointSprite(entity this);
 
-void Ent_WaypointSprite();
+void Ent_WaypointSprite(entity this);
 
 void WaypointSprite_Load_Frames(string ext);
 
index 2f9107d066366ddb0854800f897a632b959326ec..079d6b3f0dbc445577c8b95b1834f81d0e0d353e 100644 (file)
@@ -117,7 +117,7 @@ void turret_draw2d(entity this)
        if(autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
                txt = _("Spam");
        else
-               txt = spritelookuptext(spriteimage);
+               txt = spritelookuptext(this, spriteimage);
 
        if(time - floor(time) > 0.5 && t == this.team)
        {
@@ -127,7 +127,7 @@ void turret_draw2d(entity this)
                        txt = sprintf(_("%s under attack!"), txt);
                }
                else
-                       a *= spritelookupblinkvalue(spriteimage);
+                       a *= spritelookupblinkvalue(this, spriteimage);
        }
 
        if(autocvar_g_waypointsprite_uppercase)