]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/effects/all.qc
Merge branch 'master' into TimePath/debug_draw
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / effects / all.qc
index a18d741f61a0c8571905ab435c13d11a885e8cab..bc739192245ce8beadc88a30fec8a04d3811bc19 100644 (file)
@@ -1,15 +1,16 @@
 #include "all.qh"
 
+REGISTER_NET_TEMP(net_effect, bool isNew)
 #ifdef CSQC
-void Read_Effect(bool is_new)
 {
        int net_name = (Effects_COUNT >= 255) ? ReadShort() : ReadByte();
 
        entity eff = Effects_from(net_name);
 
-       vector v, vel = '0 0 0';
+       vector vel = '0 0 0';
        int eff_cnt = 1;
        bool eff_trail = eff.eent_eff_trail;
+       vector v;
        v_x = ReadCoord();
        v_y = ReadCoord();
        v_z = ReadCoord();
@@ -25,38 +26,37 @@ void Read_Effect(bool is_new)
        if(!eff_trail)
                eff_cnt = ReadByte();
 
-       if(is_new)
-       {
-               if(eff_trail)
-                       WarpZone_TrailParticles(world, particleeffectnum(eff), v, vel);
-               else
-                       pointparticles(eff, v, vel, eff_cnt);
-       }
+       if(eff_trail)
+               WarpZone_TrailParticles(world, particleeffectnum(eff), v, vel);
+       else
+               pointparticles(eff, v, vel, eff_cnt);
 }
 #endif
 
 #ifdef SVQC
 bool Net_Write_Effect(entity this, entity client, int sf)
 {
-       WriteByte(MSG_ENTITY, ENT_CLIENT_EFFECT);
+       int channel = MSG_ONE;
+       msg_entity = client;
+       WriteHeader(channel, net_effect);
        (Effects_COUNT >= 255)
-       ? WriteShort(MSG_ENTITY, self.m_id)
-       : WriteByte(MSG_ENTITY, self.m_id);
-       WriteCoord(MSG_ENTITY, self.eent_net_location_x);
-       WriteCoord(MSG_ENTITY, self.eent_net_location_y);
-       WriteCoord(MSG_ENTITY, self.eent_net_location_z);
+       ? WriteShort(channel, this.m_id)
+       : WriteByte(channel, this.m_id);
+       WriteCoord(channel, this.eent_net_location_x);
+       WriteCoord(channel, this.eent_net_location_y);
+       WriteCoord(channel, this.eent_net_location_z);
 
        // attempt to save a tiny bit more bandwidth by not sending velocity if it isn't set
-       if(self.eent_net_velocity)
+       if(this.eent_net_velocity)
        {
-               WriteByte(MSG_ENTITY, true);
-               WriteCoord(MSG_ENTITY, self.eent_net_velocity_x);
-               WriteCoord(MSG_ENTITY, self.eent_net_velocity_y);
-               WriteCoord(MSG_ENTITY, self.eent_net_velocity_z);
+               WriteByte(channel, true);
+               WriteCoord(channel, this.eent_net_velocity_x);
+               WriteCoord(channel, this.eent_net_velocity_y);
+               WriteCoord(channel, this.eent_net_velocity_z);
        }
-       else { WriteByte(MSG_ENTITY, false); }
+       else { WriteByte(channel, false); }
 
-       if(!self.eent_eff_trail) { WriteByte(MSG_ENTITY, self.eent_net_count); }
+       if(!this.eent_eff_trail) { WriteByte(channel, this.eent_net_count); }
        return true;
 }
 
@@ -64,9 +64,9 @@ void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
 {
        if(!eff) { return; }
        if(!eff.eent_eff_trail && !eff_cnt) { return; } // effect has no count!
-       entity net_eff = spawn();
+       entity net_eff = new(net_effect);
+       make_pure(net_eff);
        net_eff.owner = eff;
-       net_eff.classname = "net_effect";
        //net_eff.eent_broadcast = broadcast;
        net_eff.m_id = eff.m_id;
        net_eff.eent_net_velocity = eff_vel;
@@ -74,10 +74,8 @@ void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
        net_eff.eent_net_count = eff_cnt;
        net_eff.eent_eff_trail = eff.eent_eff_trail;
 
-       net_eff.think = SUB_Remove;
-       net_eff.nextthink = time + 0.2; // don't need to keep this long
-
-       Net_LinkEntity(net_eff, false, 0, Net_Write_Effect);
+       entity e; FOR_EACH_REALCLIENT(e) Net_Write_Effect(net_eff, e, 0);
+       remove(net_eff);
 }
 
 void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt)