]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/csqcprojectile.qc
Merge branch 'master' into terencehill/lms_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / csqcprojectile.qc
index bc7413033b0b4ed08cd78c1bd0700207bf7e3d8b..07f6f5c6651bd1615b35761921119294ee0d8bcd 100644 (file)
@@ -1,59 +1,52 @@
-#if defined(CSQC)
-#elif defined(MENUQC)
-#elif defined(SVQC)
-       #include "../../dpdefs/progsdefs.qh"
-    #include "../../common/constants.qh"
-    #include "../../common/weapons/weapons.qh"
-    #include "csqcprojectile.qh"
-    #include "../t_items.qh"
-    #include "../constants.qh"
-    #include "../defs.qh"
-    #include "../command/common.qh"
-#endif
+#include "csqcprojectile.qh"
+
+#include <common/constants.qh>
+#include <common/net_linked.qh>
+#include <common/stats.qh>
+#include <common/weapons/_all.qh>
+#include <common/weapons/_all.qh>
+#include <server/command/common.qh>
+#include <server/items/items.qh>
 
 .float csqcprojectile_type;
 
-float CSQCProjectile_SendEntity(entity to, float sf)
+bool CSQCProjectile_SendEntity(entity this, entity to, int sf)
 {
        float ft, fr;
 
        // note: flag 0x08 = no trail please (teleport bit)
        sf = sf & 0x0F;
 
-       if(self.csqcprojectile_clientanimate)
+       if(this.csqcprojectile_clientanimate)
                sf |= 0x80; // client animated, not interpolated
 
-       if(self.flags & FL_ONGROUND)
+       if(IS_ONGROUND(this))
                sf |= 0x40;
 
        ft = fr = 0;
-       if(self.fade_time != 0 || self.fade_rate != 0)
+       if(this.fade_time != 0 || this.fade_rate != 0)
        {
-               ft = (self.fade_time - time) / sys_frametime;
-               fr = (1 / self.fade_rate) / sys_frametime;
+               ft = (this.fade_time - time) / sys_frametime;
+               fr = (1 / this.fade_rate) / sys_frametime;
                if(ft <= 255 && fr <= 255 && fr >= 1)
                        sf |= 0x20;
        }
 
-       if(self.gravity != 0)
+       if(this.gravity != 0)
                sf |= 0x10;
 
-       WriteByte(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
+       WriteHeader(MSG_ENTITY, ENT_CLIENT_PROJECTILE);
        WriteByte(MSG_ENTITY, sf);
 
        if(sf & 1)
        {
-               WriteCoord(MSG_ENTITY, self.origin.x);
-               WriteCoord(MSG_ENTITY, self.origin.y);
-               WriteCoord(MSG_ENTITY, self.origin.z);
+               WriteVector(MSG_ENTITY, this.origin);
 
                if(sf & 0x80)
                {
-                       WriteCoord(MSG_ENTITY, self.velocity.x);
-                       WriteCoord(MSG_ENTITY, self.velocity.y);
-                       WriteCoord(MSG_ENTITY, self.velocity.z);
+                       WriteVector(MSG_ENTITY, this.velocity);
                        if(sf & 0x10)
-                               WriteCoord(MSG_ENTITY, self.gravity);
+                               WriteCoord(MSG_ENTITY, this.gravity);
                }
 
                if(sf & 0x20)
@@ -62,32 +55,35 @@ float CSQCProjectile_SendEntity(entity to, float sf)
                        WriteByte(MSG_ENTITY, fr);
                }
 
-               WriteByte(MSG_ENTITY, self.realowner.team);
+               if(teamplay)
+                       WriteByte(MSG_ENTITY, this.realowner.team);
+               else
+                       WriteByte(MSG_ENTITY, this.realowner.clientcolors); // NOTE: doesn't work on non-clients
        }
 
        if(sf & 2)
-               WriteByte(MSG_ENTITY, self.csqcprojectile_type); // TODO maybe put this into sf?
+               WriteByte(MSG_ENTITY, this.csqcprojectile_type); // TODO maybe put this into sf?
 
-       return 1;
+       return true;
 }
 
 .vector csqcprojectile_oldorigin;
 void CSQCProjectile_Check(entity e)
 {
        if(e.csqcprojectile_clientanimate)
-       if(e.flags & FL_ONGROUND)
+       if(IS_ONGROUND(e))
        if(e.origin != e.csqcprojectile_oldorigin)
                UpdateCSQCProjectile(e);
        e.csqcprojectile_oldorigin = e.origin;
 }
 
-void CSQCProjectile(entity e, float clientanimate, float type, float docull)
+void CSQCProjectile(entity e, float clientanimate, int type, float docull)
 {
        Net_LinkEntity(e, docull, 0, CSQCProjectile_SendEntity);
 
        e.csqcprojectile_clientanimate = clientanimate;
 
-       if(e.movetype == MOVETYPE_TOSS || e.movetype == MOVETYPE_BOUNCE)
+       if(e.move_movetype == MOVETYPE_TOSS || e.move_movetype == MOVETYPE_BOUNCE)
        {
                if(e.gravity == 0)
                        e.gravity = 1;
@@ -102,13 +98,13 @@ void CSQCProjectile(entity e, float clientanimate, float type, float docull)
 
 void UpdateCSQCProjectile(entity e)
 {
-       if(e.SendEntity == CSQCProjectile_SendEntity)
+       if(getSendEntity(e) == CSQCProjectile_SendEntity)
        {
                // send new origin data
                e.SendFlags |= 0x01;
        }
 // FIXME HACK
-       else if(e.SendEntity == ItemSend)
+       else if(getSendEntity(e) == ItemSend)
        {
                ItemUpdate(e);
        }
@@ -117,10 +113,14 @@ void UpdateCSQCProjectile(entity e)
 
 void UpdateCSQCProjectileAfterTeleport(entity e)
 {
-       if(e.SendEntity == CSQCProjectile_SendEntity)
+       if(getSendEntity(e) == CSQCProjectile_SendEntity)
        {
                // send new origin data
                e.SendFlags |= 0x01;
+               // send full data as the projectile may need resetting
+               // this is a workaround for client-side projectiles erroneously calling their SUB_Stop touch function occasionally
+               // when passing through a warpzone
+               e.SendFlags |= 2;
                // mark as teleported
                e.SendFlags |= 0x08;
        }