From: Samual Lenks Date: Mon, 10 Jun 2013 18:35:28 +0000 (-0400) Subject: Move projectile handling to new folder as well X-Git-Tag: xonotic-v0.8.0~152^2~403 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=833f122e978aab322b6594a2f56234598c6494c6;p=xonotic%2Fxonotic-data.pk3dir.git Move projectile handling to new folder as well --- diff --git a/qcsrc/server/csqcprojectile.qc b/qcsrc/server/csqcprojectile.qc deleted file mode 100644 index 3554f1ff6..000000000 --- a/qcsrc/server/csqcprojectile.qc +++ /dev/null @@ -1,106 +0,0 @@ -.float csqcprojectile_type; - -float CSQCProjectile_SendEntity(entity to, float sf) -{ - float ft, fr; - - // note: flag 0x08 = no trail please (teleport bit) - sf = sf & 0x0F; - - if(self.csqcprojectile_clientanimate) - sf |= 0x80; // client animated, not interpolated - - if(self.flags & FL_ONGROUND) - sf |= 0x40; - - ft = fr = 0; - if(self.fade_time != 0 || self.fade_rate != 0) - { - ft = (self.fade_time - time) / sys_frametime; - fr = (1 / self.fade_rate) / sys_frametime; - if(ft <= 255 && fr <= 255 && fr >= 1) - sf |= 0x20; - } - - if(self.gravity != 0) - sf |= 0x10; - - WriteByte(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); - - if(sf & 0x80) - { - WriteCoord(MSG_ENTITY, self.velocity_x); - WriteCoord(MSG_ENTITY, self.velocity_y); - WriteCoord(MSG_ENTITY, self.velocity_z); - if(sf & 0x10) - WriteCoord(MSG_ENTITY, self.gravity); - } - - if(sf & 0x20) - { - WriteByte(MSG_ENTITY, ft); - WriteByte(MSG_ENTITY, fr); - } - } - - if(sf & 2) - WriteByte(MSG_ENTITY, self.csqcprojectile_type); // TODO maybe put this into sf? - - return 1; -} - -.vector csqcprojectile_oldorigin; -void CSQCProjectile_Check(entity e) -{ - if(e.csqcprojectile_clientanimate) - if(e.flags & FL_ONGROUND) - if(e.origin != e.csqcprojectile_oldorigin) - UpdateCSQCProjectile(e); - e.csqcprojectile_oldorigin = e.origin; -} - -void CSQCProjectile(entity e, float clientanimate, float 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.gravity == 0) - e.gravity = 1; - } - else - e.gravity = 0; - - if(!sound_allowed(MSG_BROADCAST, e)) - type |= 0x80; - e.csqcprojectile_type = type; -} - -void UpdateCSQCProjectile(entity e) -{ - if(e.SendEntity == CSQCProjectile_SendEntity) - { - // send new origin data - e.SendFlags |= 0x01; - } -} - -void UpdateCSQCProjectileAfterTeleport(entity e) -{ - if(e.SendEntity == CSQCProjectile_SendEntity) - { - // send new origin data - e.SendFlags |= 0x01; - // mark as teleported - e.SendFlags |= 0x08; - } -} diff --git a/qcsrc/server/csqcprojectile.qh b/qcsrc/server/csqcprojectile.qh deleted file mode 100644 index e00c0988b..000000000 --- a/qcsrc/server/csqcprojectile.qh +++ /dev/null @@ -1,6 +0,0 @@ -.float csqcprojectile_clientanimate; - -void CSQCProjectile(entity e, float clientanimate, float type, float docull); -void UpdateCSQCProjectile(entity e); -void UpdateCSQCProjectileAfterTeleport(entity e); -void CSQCProjectile_Check(entity e); diff --git a/qcsrc/server/weapons/csqcprojectile.qc b/qcsrc/server/weapons/csqcprojectile.qc new file mode 100644 index 000000000..3554f1ff6 --- /dev/null +++ b/qcsrc/server/weapons/csqcprojectile.qc @@ -0,0 +1,106 @@ +.float csqcprojectile_type; + +float CSQCProjectile_SendEntity(entity to, float sf) +{ + float ft, fr; + + // note: flag 0x08 = no trail please (teleport bit) + sf = sf & 0x0F; + + if(self.csqcprojectile_clientanimate) + sf |= 0x80; // client animated, not interpolated + + if(self.flags & FL_ONGROUND) + sf |= 0x40; + + ft = fr = 0; + if(self.fade_time != 0 || self.fade_rate != 0) + { + ft = (self.fade_time - time) / sys_frametime; + fr = (1 / self.fade_rate) / sys_frametime; + if(ft <= 255 && fr <= 255 && fr >= 1) + sf |= 0x20; + } + + if(self.gravity != 0) + sf |= 0x10; + + WriteByte(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); + + if(sf & 0x80) + { + WriteCoord(MSG_ENTITY, self.velocity_x); + WriteCoord(MSG_ENTITY, self.velocity_y); + WriteCoord(MSG_ENTITY, self.velocity_z); + if(sf & 0x10) + WriteCoord(MSG_ENTITY, self.gravity); + } + + if(sf & 0x20) + { + WriteByte(MSG_ENTITY, ft); + WriteByte(MSG_ENTITY, fr); + } + } + + if(sf & 2) + WriteByte(MSG_ENTITY, self.csqcprojectile_type); // TODO maybe put this into sf? + + return 1; +} + +.vector csqcprojectile_oldorigin; +void CSQCProjectile_Check(entity e) +{ + if(e.csqcprojectile_clientanimate) + if(e.flags & FL_ONGROUND) + if(e.origin != e.csqcprojectile_oldorigin) + UpdateCSQCProjectile(e); + e.csqcprojectile_oldorigin = e.origin; +} + +void CSQCProjectile(entity e, float clientanimate, float 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.gravity == 0) + e.gravity = 1; + } + else + e.gravity = 0; + + if(!sound_allowed(MSG_BROADCAST, e)) + type |= 0x80; + e.csqcprojectile_type = type; +} + +void UpdateCSQCProjectile(entity e) +{ + if(e.SendEntity == CSQCProjectile_SendEntity) + { + // send new origin data + e.SendFlags |= 0x01; + } +} + +void UpdateCSQCProjectileAfterTeleport(entity e) +{ + if(e.SendEntity == CSQCProjectile_SendEntity) + { + // send new origin data + e.SendFlags |= 0x01; + // mark as teleported + e.SendFlags |= 0x08; + } +} diff --git a/qcsrc/server/weapons/csqcprojectile.qh b/qcsrc/server/weapons/csqcprojectile.qh new file mode 100644 index 000000000..e00c0988b --- /dev/null +++ b/qcsrc/server/weapons/csqcprojectile.qh @@ -0,0 +1,6 @@ +.float csqcprojectile_clientanimate; + +void CSQCProjectile(entity e, float clientanimate, float type, float docull); +void UpdateCSQCProjectile(entity e); +void UpdateCSQCProjectileAfterTeleport(entity e); +void CSQCProjectile_Check(entity e);