Modeleffects: move to qc effects
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 5 Nov 2015 21:37:17 +0000 (08:37 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 5 Nov 2015 21:37:17 +0000 (08:37 +1100)
qcsrc/client/main.qc
qcsrc/client/modeleffects.qc [deleted file]
qcsrc/client/modeleffects.qh [deleted file]
qcsrc/client/progs.inc
qcsrc/common/constants.qh
qcsrc/common/effects/qc/all.inc
qcsrc/common/effects/qc/modeleffects.qc [new file with mode: 0644]
qcsrc/server/miscfunctions.qc
qcsrc/server/miscfunctions.qh
qcsrc/server/mutators/mutator/gamemode_ctf.qc

index 16b6d95..523786e 100644 (file)
@@ -4,7 +4,6 @@
 #include "hook.qh"
 #include "hud/all.qh"
 #include "mapvoting.qh"
-#include "modeleffects.qh"
 #include "mutators/events.qh"
 #include "quickmenu.qh"
 #include "scoreboard.qh"
diff --git a/qcsrc/client/modeleffects.qc b/qcsrc/client/modeleffects.qc
deleted file mode 100644 (file)
index 3a848e4..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#include "modeleffects.qh"
-
-.float cnt;
-.float scale;
-.float alpha;
-
-void ModelEffect_Draw(entity this)
-{
-       self.angles = self.angles + frametime * self.avelocity;
-       setorigin(self, self.origin + frametime * self.velocity);
-       self.scale = self.scale1 + (self.scale2 - self.scale1) * (time - self.teleport_time) / (self.lifetime + self.fadetime - self.teleport_time);
-       self.alpha = self.cnt * bound(0, 1 - (time - self.lifetime) / self.fadetime, 1);
-       if(self.alpha < ALPHA_MIN_VISIBLE)
-       {
-               remove(self);
-               return;
-       }
-       self.drawmask = MASK_NORMAL;
-       if(self.scale <= 0)
-       {
-               self.drawmask = 0;
-               return;
-       }
-}
-
-NET_HANDLE(ENT_CLIENT_MODELEFFECT, bool isnew)
-{
-       make_pure(self);
-
-       int f = ReadByte();
-
-       entity e = new(modeleffect);
-       e.model = "from network";
-       e.modelindex = ReadShort();
-       e.skin = ReadByte();
-       e.frame = ReadByte();
-       e.frame1time = time;
-       e.origin_x = ReadCoord();
-       e.origin_y = ReadCoord();
-       e.origin_z = ReadCoord();
-       setorigin(e, e.origin);
-       if(f & 1)
-       {
-               e.velocity_x = ReadCoord();
-               e.velocity_y = ReadCoord();
-               e.velocity_z = ReadCoord();
-       }
-       if(f & 2)
-       {
-               e.angles_x = ReadAngle();
-               e.angles_y = ReadAngle();
-               e.angles_z = ReadAngle();
-       }
-       if(f & 4)
-       {
-               e.avelocity_x = ReadAngle();
-               e.avelocity_y = ReadAngle();
-               e.avelocity_z = ReadAngle();
-       }
-       e.scale1 = ReadShort() / 256.0;
-       e.scale2 = ReadShort() / 256.0;
-       e.lifetime = time + ReadByte() * 0.01;
-       e.fadetime = ReadByte() * 0.01;
-       e.teleport_time = time;
-       e.cnt = ReadByte() / 255.0; // actually alpha
-
-       e.draw = ModelEffect_Draw;
-
-       if (!isnew) remove(e); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then
-       return true;
-}
diff --git a/qcsrc/client/modeleffects.qh b/qcsrc/client/modeleffects.qh
deleted file mode 100644 (file)
index 9c8c77f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef CLIENT_MODELEFFECTS_H
-#define CLIENT_MODELEFFECTS_H
-
-entityclass(ModelEffect);
-class(ModelEffect) .float frame1time;
-class(ModelEffect) .float lifetime, fadetime;
-class(ModelEffect) .float teleport_time;
-class(ModelEffect) .float scale1, scale2;
-
-void ModelEffect_Draw(entity this);
-
-#endif
index 83f387b..e2cd0d6 100644 (file)
@@ -11,7 +11,6 @@
 #include "main.qc"
 #include "mapvoting.qc"
 #include "miscfunctions.qc"
-#include "modeleffects.qc"
 #include "movelib.qc"
 #include "player_skeleton.qc"
 #include "rubble.qc"
index 58f41bc..2b40b2e 100644 (file)
@@ -72,7 +72,6 @@ REGISTER_NET_LINKED(ENT_CLIENT_MAPVOTE)
 REGISTER_NET_LINKED(ENT_CLIENT_CLIENTDATA)
 REGISTER_NET_LINKED(ENT_CLIENT_RANDOMSEED)
 REGISTER_NET_LINKED(ENT_CLIENT_WALL)
-REGISTER_NET_LINKED(ENT_CLIENT_MODELEFFECT)
 REGISTER_NET_LINKED(ENT_CLIENT_TUBANOTE)
 REGISTER_NET_LINKED(ENT_CLIENT_WARPZONE)
 REGISTER_NET_LINKED(ENT_CLIENT_WARPZONE_CAMERA)
index 16fc201..cda1a63 100644 (file)
@@ -2,3 +2,4 @@
 #include "damageeffects.qc"
 #include "gibs.qc"
 #include "lightningarc.qc"
+#include "modeleffects.qc"
diff --git a/qcsrc/common/effects/qc/modeleffects.qc b/qcsrc/common/effects/qc/modeleffects.qc
new file mode 100644 (file)
index 0000000..41c5ba0
--- /dev/null
@@ -0,0 +1,163 @@
+#ifdef IMPLEMENTATION
+
+REGISTER_NET_LINKED(ENT_CLIENT_MODELEFFECT)
+
+#ifdef SVQC
+
+.float scale2;
+
+bool modeleffect_SendEntity(entity this, entity to, int sf)
+{
+       float f;
+       WriteHeader(MSG_ENTITY, ENT_CLIENT_MODELEFFECT);
+
+       f = 0;
+       if(self.velocity != '0 0 0')
+               f |= 1;
+       if(self.angles != '0 0 0')
+               f |= 2;
+       if(self.avelocity != '0 0 0')
+               f |= 4;
+
+       WriteByte(MSG_ENTITY, f);
+       WriteShort(MSG_ENTITY, self.modelindex);
+       WriteByte(MSG_ENTITY, self.skin);
+       WriteByte(MSG_ENTITY, self.frame);
+       WriteCoord(MSG_ENTITY, self.origin.x);
+       WriteCoord(MSG_ENTITY, self.origin.y);
+       WriteCoord(MSG_ENTITY, self.origin.z);
+       if(f & 1)
+       {
+               WriteCoord(MSG_ENTITY, self.velocity.x);
+               WriteCoord(MSG_ENTITY, self.velocity.y);
+               WriteCoord(MSG_ENTITY, self.velocity.z);
+       }
+       if(f & 2)
+       {
+               WriteCoord(MSG_ENTITY, self.angles.x);
+               WriteCoord(MSG_ENTITY, self.angles.y);
+               WriteCoord(MSG_ENTITY, self.angles.z);
+       }
+       if(f & 4)
+       {
+               WriteCoord(MSG_ENTITY, self.avelocity.x);
+               WriteCoord(MSG_ENTITY, self.avelocity.y);
+               WriteCoord(MSG_ENTITY, self.avelocity.z);
+       }
+       WriteShort(MSG_ENTITY, self.scale * 256.0);
+       WriteShort(MSG_ENTITY, self.scale2 * 256.0);
+       WriteByte(MSG_ENTITY, self.teleport_time * 100.0);
+       WriteByte(MSG_ENTITY, self.fade_time * 100.0);
+       WriteByte(MSG_ENTITY, self.alpha * 255.0);
+
+       return true;
+}
+
+void modeleffect_spawn(string m, float s, float f, vector o, vector v, vector ang, vector angv, float s0, float s2, float a, float t1, float t2)
+{
+       entity e = new(modeleffect);
+       _setmodel(e, m);
+       e.frame = f;
+       setorigin(e, o);
+       e.velocity = v;
+       e.angles = ang;
+       e.avelocity = angv;
+       e.alpha = a;
+       e.teleport_time = t1;
+       e.fade_time = t2;
+       e.skin = s;
+       if(s0 >= 0)
+               e.scale = s0 / max6(-e.mins.x, -e.mins.y, -e.mins.z, e.maxs.x, e.maxs.y, e.maxs.z);
+       else
+               e.scale = -s0;
+       if(s2 >= 0)
+               e.scale2 = s2 / max6(-e.mins.x, -e.mins.y, -e.mins.z, e.maxs.x, e.maxs.y, e.maxs.z);
+       else
+               e.scale2 = -s2;
+       float sz = max(e.scale, e.scale2);
+       setsize(e, e.mins * sz, e.maxs * sz);
+       Net_LinkEntity(e, false, 0.1, modeleffect_SendEntity);
+}
+
+#endif
+
+#ifdef CSQC
+
+entityclass(ModelEffect);
+class(ModelEffect) .float frame1time;
+class(ModelEffect) .float lifetime, fadetime;
+class(ModelEffect) .float teleport_time;
+class(ModelEffect) .float scale1, scale2;
+
+.float cnt;
+.float scale;
+.float alpha;
+
+void ModelEffect_Draw(entity this)
+{
+       self.angles = self.angles + frametime * self.avelocity;
+       setorigin(self, self.origin + frametime * self.velocity);
+       self.scale = self.scale1 + (self.scale2 - self.scale1) * (time - self.teleport_time) / (self.lifetime + self.fadetime - self.teleport_time);
+       self.alpha = self.cnt * bound(0, 1 - (time - self.lifetime) / self.fadetime, 1);
+       if(self.alpha < ALPHA_MIN_VISIBLE)
+       {
+               remove(self);
+               return;
+       }
+       self.drawmask = MASK_NORMAL;
+       if(self.scale <= 0)
+       {
+               self.drawmask = 0;
+               return;
+       }
+}
+
+NET_HANDLE(ENT_CLIENT_MODELEFFECT, bool isnew)
+{
+       make_pure(self);
+
+       int f = ReadByte();
+
+       entity e = new(modeleffect);
+       e.model = "from network";
+       e.modelindex = ReadShort();
+       e.skin = ReadByte();
+       e.frame = ReadByte();
+       e.frame1time = time;
+       e.origin_x = ReadCoord();
+       e.origin_y = ReadCoord();
+       e.origin_z = ReadCoord();
+       setorigin(e, e.origin);
+       if(f & 1)
+       {
+               e.velocity_x = ReadCoord();
+               e.velocity_y = ReadCoord();
+               e.velocity_z = ReadCoord();
+       }
+       if(f & 2)
+       {
+               e.angles_x = ReadAngle();
+               e.angles_y = ReadAngle();
+               e.angles_z = ReadAngle();
+       }
+       if(f & 4)
+       {
+               e.avelocity_x = ReadAngle();
+               e.avelocity_y = ReadAngle();
+               e.avelocity_z = ReadAngle();
+       }
+       e.scale1 = ReadShort() / 256.0;
+       e.scale2 = ReadShort() / 256.0;
+       e.lifetime = time + ReadByte() * 0.01;
+       e.fadetime = ReadByte() * 0.01;
+       e.teleport_time = time;
+       e.cnt = ReadByte() / 255.0; // actually alpha
+
+       e.draw = ModelEffect_Draw;
+
+       if (!isnew) remove(e); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then
+       return true;
+}
+#endif
+
+#endif
index 4df487c..2f459c3 100644 (file)
@@ -1564,86 +1564,6 @@ vector gettaginfo_relative(entity e, float tag)
     return gettaginfo(gettaginfo_relative_ent, tag);
 }
 
-.float scale2;
-
-bool modeleffect_SendEntity(entity this, entity to, int sf)
-{
-       float f;
-       WriteHeader(MSG_ENTITY, ENT_CLIENT_MODELEFFECT);
-
-       f = 0;
-       if(self.velocity != '0 0 0')
-               f |= 1;
-       if(self.angles != '0 0 0')
-               f |= 2;
-       if(self.avelocity != '0 0 0')
-               f |= 4;
-
-       WriteByte(MSG_ENTITY, f);
-       WriteShort(MSG_ENTITY, self.modelindex);
-       WriteByte(MSG_ENTITY, self.skin);
-       WriteByte(MSG_ENTITY, self.frame);
-       WriteCoord(MSG_ENTITY, self.origin.x);
-       WriteCoord(MSG_ENTITY, self.origin.y);
-       WriteCoord(MSG_ENTITY, self.origin.z);
-       if(f & 1)
-       {
-               WriteCoord(MSG_ENTITY, self.velocity.x);
-               WriteCoord(MSG_ENTITY, self.velocity.y);
-               WriteCoord(MSG_ENTITY, self.velocity.z);
-       }
-       if(f & 2)
-       {
-               WriteCoord(MSG_ENTITY, self.angles.x);
-               WriteCoord(MSG_ENTITY, self.angles.y);
-               WriteCoord(MSG_ENTITY, self.angles.z);
-       }
-       if(f & 4)
-       {
-               WriteCoord(MSG_ENTITY, self.avelocity.x);
-               WriteCoord(MSG_ENTITY, self.avelocity.y);
-               WriteCoord(MSG_ENTITY, self.avelocity.z);
-       }
-       WriteShort(MSG_ENTITY, self.scale * 256.0);
-       WriteShort(MSG_ENTITY, self.scale2 * 256.0);
-       WriteByte(MSG_ENTITY, self.teleport_time * 100.0);
-       WriteByte(MSG_ENTITY, self.fade_time * 100.0);
-       WriteByte(MSG_ENTITY, self.alpha * 255.0);
-
-       return true;
-}
-
-void modeleffect_spawn(string m, float s, float f, vector o, vector v, vector ang, vector angv, float s0, float s2, float a, float t1, float t2)
-{
-       entity e = new(modeleffect);
-       _setmodel(e, m);
-       e.frame = f;
-       setorigin(e, o);
-       e.velocity = v;
-       e.angles = ang;
-       e.avelocity = angv;
-       e.alpha = a;
-       e.teleport_time = t1;
-       e.fade_time = t2;
-       e.skin = s;
-       if(s0 >= 0)
-               e.scale = s0 / max6(-e.mins.x, -e.mins.y, -e.mins.z, e.maxs.x, e.maxs.y, e.maxs.z);
-       else
-               e.scale = -s0;
-       if(s2 >= 0)
-               e.scale2 = s2 / max6(-e.mins.x, -e.mins.y, -e.mins.z, e.maxs.x, e.maxs.y, e.maxs.z);
-       else
-               e.scale2 = -s2;
-       float sz = max(e.scale, e.scale2);
-       setsize(e, e.mins * sz, e.maxs * sz);
-       Net_LinkEntity(e, false, 0.1, modeleffect_SendEntity);
-}
-
-void shockwave_spawn(string m, vector org, float sz, float t1, float t2)
-{
-       return modeleffect_spawn(m, 0, 0, org, '0 0 0', '0 0 0', '0 0 0', 0, sz, 1, t1, t2);
-}
-
 .string aiment_classname;
 .float aiment_deadflag;
 void SetMovetypeFollow(entity ent, entity e)
index bb19caf..ae0aa0e 100644 (file)
@@ -39,10 +39,6 @@ void write_recordmarker(entity pl, float tstart, float dt);
 
 void play2all(string samp);
 
-void modeleffect_spawn(string m, float s, float f, vector o, vector v, vector ang, vector angv, float s0, float s2, float a, float t1, float t2);
-
-void shockwave_spawn(string m, vector org, float sz, float t1, float t2);
-
 void play2team(float t, string filename);
 
 void GetCvars_handleFloat(string thisname, float f, .float field, string name);
index eda9f16..d16b168 100644 (file)
@@ -678,6 +678,10 @@ void ctf_Handle_Throw(entity player, entity receiver, int droptype)
        ctf_CaptureShield_Update(player, 0); // shield player from picking up flag
 }
 
+void shockwave_spawn(string m, vector org, float sz, float t1, float t2)
+{
+       return modeleffect_spawn(m, 0, 0, org, '0 0 0', '0 0 0', '0 0 0', 0, sz, 1, t1, t2);
+}
 
 // ==============
 // Event Handlers