]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Avoid sending beam settings every time a player starts firing with the Arc. Also...
authorterencehill <piuntn@gmail.com>
Tue, 16 Jul 2024 14:53:02 +0000 (16:53 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 16 Jul 2024 14:58:17 +0000 (16:58 +0200)
It turns out the Arc beam settings were already networked along with all the Arc cvars by the weapon system so there was no need to explicitly send them

qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/arc.qh
qcsrc/server/client.qc

index 3bb17da8ed7b0c65ea3192288bd8fb770d17e38f..8f710b242b44e98b840d41e7604359c365ee024a 100644 (file)
@@ -18,15 +18,8 @@ bool W_Arc_Beam_Send(entity this, entity to, int sf)
        WriteByte(MSG_ENTITY, sf);
        WriteByte(MSG_ENTITY, weaponslot(this.weaponentity_fld));
 
-       if(sf & ARC_SF_SETTINGS) // settings information
+       if(sf & ARC_SF_UPDATE)
        {
-               WriteShort(MSG_ENTITY, WEP_CVAR(arc, beam_degreespersegment));
-               WriteShort(MSG_ENTITY, WEP_CVAR(arc, beam_distancepersegment));
-               WriteShort(MSG_ENTITY, WEP_CVAR(arc, beam_maxangle));
-               WriteCoord(MSG_ENTITY, WEP_CVAR(arc, beam_range));
-               WriteShort(MSG_ENTITY, WEP_CVAR(arc, beam_returnspeed));
-               WriteByte(MSG_ENTITY, WEP_CVAR(arc, beam_tightness) * 10);
-
                WriteByte(MSG_ENTITY, drawlocal);
                WriteByte(MSG_ENTITY, etof(this.owner));
        }
@@ -358,7 +351,8 @@ void W_Arc_Beam_Think(entity this)
        }
 
        vector beam_endpos = (w_shotorg + (this.beam_dir * WEP_CVAR(arc, beam_range)));
-       vector beam_controlpoint = w_shotorg + w_shotdir * (WEP_CVAR(arc, beam_range) * (1 - WEP_CVAR(arc, beam_tightness)));
+       float beam_controlpoint_dist = WEP_CVAR(arc, beam_range) * bound(0.001, 1 - WEP_CVAR(arc, beam_tightness), 1);
+       vector beam_controlpoint = w_shotorg + w_shotdir * beam_controlpoint_dist;
 
        int new_beam_type = 0;
        vector last_origin = w_shotorg;
@@ -935,7 +929,7 @@ void Draw_ArcBeam(entity this)
                // trace forward with an estimation
                WarpZone_TraceLine(
                        start_pos_saved,
-                       start_pos_saved + forward * this.beam_range,
+                       start_pos_saved + forward * WEP_CVAR(arc, beam_range),
                        MOVE_NOMONSTERS,
                        this
                );
@@ -987,22 +981,22 @@ void Draw_ArcBeam(entity this)
                        else
                        {
                                float max_blendfactor = 1;
-                               if(angle && (angle > this.beam_maxangle))
-                                       max_blendfactor = this.beam_maxangle / angle;
-                               float blendfactor = bound(0, (1 - (this.beam_returnspeed * dt)), max_blendfactor);
+                               if(angle && (angle > WEP_CVAR(arc, beam_maxangle)))
+                                       max_blendfactor = WEP_CVAR(arc, beam_maxangle) / angle;
+                               float blendfactor = bound(0, (1 - (WEP_CVAR(arc, beam_returnspeed) * dt)), max_blendfactor);
                                this.beam_dir = normalize((wantdir * (1 - blendfactor)) + (this.beam_dir * blendfactor));
 
                                // calculate how many segments are needed
                                float max_allowed_segments = ARC_MAX_SEGMENTS;
-                               if(this.beam_distancepersegment)
+                               if(WEP_CVAR(arc, beam_distancepersegment))
                                {
-                                       max_allowed_segments = 1 + (vlen(wantdir / this.beam_distancepersegment));
+                                       max_allowed_segments = 1 + (vlen(wantdir / WEP_CVAR(arc, beam_distancepersegment)));
                                        max_allowed_segments = bound(1, max_allowed_segments, ARC_MAX_SEGMENTS);
                                }
 
-                               if(this.beam_degreespersegment)
+                               if(WEP_CVAR(arc, beam_degreespersegment))
                                {
-                                       segments = min(angle, this.beam_maxangle) / this.beam_degreespersegment;
+                                       segments = min(angle, WEP_CVAR(arc, beam_maxangle)) / WEP_CVAR(arc, beam_degreespersegment);
                                        segments = bound(1, segments, max_allowed_segments);
                                }
                        }
@@ -1030,15 +1024,15 @@ void Draw_ArcBeam(entity this)
 
                        // calculate how many segments are needed
                        float max_allowed_segments = ARC_MAX_SEGMENTS;
-                       if(this.beam_distancepersegment)
+                       if(WEP_CVAR(arc, beam_distancepersegment))
                        {
-                               max_allowed_segments = 1 + (vlen(wantdir / this.beam_distancepersegment));
+                               max_allowed_segments = 1 + (vlen(wantdir / WEP_CVAR(arc, beam_distancepersegment)));
                                max_allowed_segments = bound(1, max_allowed_segments, ARC_MAX_SEGMENTS);
                        }
 
-                       if(this.beam_degreespersegment)
+                       if(WEP_CVAR(arc, beam_degreespersegment))
                        {
-                               segments = min(angle, this.beam_maxangle) / this.beam_degreespersegment;
+                               segments = min(angle, WEP_CVAR(arc, beam_maxangle)) / WEP_CVAR(arc, beam_degreespersegment);
                                segments = bound(1, segments, max_allowed_segments);
                        }
                }
@@ -1047,8 +1041,9 @@ void Draw_ArcBeam(entity this)
        setorigin(this, start_pos);
        this.beam_muzzleentity.angles_z = random() * 360; // WEAPONTODO: use avelocity instead?
 
-       vector beam_endpos = (start_pos + (beamdir * this.beam_range));
-       vector beam_controlpoint = start_pos + wantdir * (this.beam_range * (1 - this.beam_tightness));
+       vector beam_endpos = (start_pos + (beamdir * WEP_CVAR(arc, beam_range)));
+       float beam_controlpoint_dist = WEP_CVAR(arc, beam_range) * bound(0.001, 1 - WEP_CVAR(arc, beam_tightness), 1);
+       vector beam_controlpoint = start_pos + wantdir * beam_controlpoint_dist;
 
        Draw_ArcBeam_callback_entity = this;
        if(!autocvar_cl_arcbeam_simple)
@@ -1201,16 +1196,9 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
                flash = this.beam_muzzleentity;
        }
 
-       if(sf & ARC_SF_SETTINGS) // settings information
+       if(sf & ARC_SF_UPDATE)
        {
-               this.beam_degreespersegment = ReadShort();
-               this.beam_distancepersegment = ReadShort();
-               this.beam_maxangle = ReadShort();
-               this.beam_range = ReadCoord();
-               this.beam_returnspeed = ReadShort();
-               this.beam_tightness = (ReadByte() / 10);
-
-               if(ReadByte())
+               if(ReadByte()) // drawlocal?
                {
                        this.beam_usevieworigin = (autocvar_chase_active) ? 1 : 2;
                }
index 1aa5cd8dba0786b5dfb80d60e074129145fdb379..971ad8001000959935061247a4c5ac18d6c623a9 100644 (file)
@@ -102,7 +102,7 @@ const int ARC_BT_BURST_HEAL =  0x12;
 const int ARC_BT_BURST_HIT =   0x13;
 const int ARC_BT_BURSTMASK =   0x10;
 
-const int ARC_SF_SETTINGS =    BIT(0);
+const int ARC_SF_UPDATE =      BIT(0);
 const int ARC_SF_START =       BIT(1);
 const int ARC_SF_WANTDIR =     BIT(2);
 const int ARC_SF_BEAMDIR =     BIT(3);
@@ -136,14 +136,8 @@ const int ARC_SF_LOCALMASK =   ARC_SF_START | ARC_SF_WANTDIR | ARC_SF_BEAMDIR;
 
 .entity beam_muzzleentity;
 
-.float beam_degreespersegment;
-.float beam_distancepersegment;
 .float beam_usevieworigin;
 .bool beam_initialized;
-.float beam_maxangle;
-.float beam_range;
-.float beam_returnspeed;
-.float beam_tightness;
 .vector beam_shotorigin;
 
 entity Draw_ArcBeam_callback_entity;
index c97f09c777424fb198c2c6b4b0501de71e50d672..769ce238d14036c254dce963826647fc212d57de 100644 (file)
@@ -1919,7 +1919,7 @@ void SetSpectatee(entity this, entity spectatee)
                {
                        .entity weaponentity = weaponentities[slot];
                        if(old_spectatee.(weaponentity).arc_beam)
-                               old_spectatee.(weaponentity).arc_beam.SendFlags |= ARC_SF_SETTINGS;
+                               old_spectatee.(weaponentity).arc_beam.SendFlags |= ARC_SF_UPDATE;
                }
        }
        if(spectatee)
@@ -1928,7 +1928,7 @@ void SetSpectatee(entity this, entity spectatee)
                {
                        .entity weaponentity = weaponentities[slot];
                        if(spectatee.(weaponentity).arc_beam)
-                               spectatee.(weaponentity).arc_beam.SendFlags |= ARC_SF_SETTINGS;
+                               spectatee.(weaponentity).arc_beam.SendFlags |= ARC_SF_UPDATE;
                }
        }