]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Potential fix for arc's buffer overflow issue (hacky method)
authorMario <mario@smbclan.net>
Mon, 11 Jun 2018 13:46:52 +0000 (23:46 +1000)
committerMario <mario@smbclan.net>
Mon, 11 Jun 2018 13:46:52 +0000 (23:46 +1000)
qcsrc/common/weapons/weapon/arc.qc

index e5d4f2eb23253dccbe414e522d0bc5ec84e8c1f0..3fe93fe4cd3d189416b938a52a6e4d862cc495d8 100644 (file)
@@ -863,6 +863,8 @@ void Reset_ArcBeam()
        }
 }
 
+.float beam_tag_index;
+.int beam_prevusevieworigin;
 void Draw_ArcBeam(entity this)
 {
        float dt = time - this.move_time;
@@ -911,10 +913,16 @@ void Draw_ArcBeam(entity this)
                else
                        { start_pos = this.origin; }
 
-               int v_shot_idx;  // used later
-               (v_shot_idx = gettagindex(wepent, "shot")) || (v_shot_idx = gettagindex(wepent, "tag_shot"));
-               if(v_shot_idx && this.beam_usevieworigin == 2)
-                       start_pos = gettaginfo(wepent, v_shot_idx) - '0 0 2';
+               if(this.beam_prevusevieworigin != this.beam_usevieworigin)
+               {
+                       this.beam_prevusevieworigin = this.beam_usevieworigin;
+                       int v_shot_idx;  // used later
+                       (v_shot_idx = gettagindex(wepent, "shot")) || (v_shot_idx = gettagindex(wepent, "tag_shot"));
+                       this.beam_tag_index = v_shot_idx;
+               }
+
+               if(this.beam_tag_index && this.beam_usevieworigin == 2)
+                       start_pos = gettaginfo(wepent, this.beam_tag_index) - '0 0 2';
 
                // trace forward with an estimation
                WarpZone_TraceLine(
@@ -933,7 +941,7 @@ void Draw_ArcBeam(entity this)
 
                // move shot origin to the actual gun muzzle origin
                vector origin_offset = '0 0 0';
-               if(!v_shot_idx || this.beam_usevieworigin != 2)
+               if(!this.beam_tag_index || this.beam_usevieworigin != 2)
                {
                        this.beam_shotorigin = wepent.movedir;
                        origin_offset =