From: Mario Date: Sun, 3 Jan 2016 15:50:00 +0000 (+1000) Subject: Hopefully fix a potential crash X-Git-Tag: xonotic-v0.8.2~1299 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ccd94d872047615c91161d0d40c4f97736898b0c;p=xonotic%2Fxonotic-data.pk3dir.git Hopefully fix a potential crash --- diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index 88683b518..1cb2766ab 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -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) diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh index c3f8378b1..843a88d45 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh @@ -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); diff --git a/qcsrc/common/turrets/cl_turrets.qc b/qcsrc/common/turrets/cl_turrets.qc index 2f9107d06..079d6b3f0 100644 --- a/qcsrc/common/turrets/cl_turrets.qc +++ b/qcsrc/common/turrets/cl_turrets.qc @@ -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)