]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/t_plats.qc
Merge branch 'TimePath/experiments/csqc_prediction' into Mario/qc_physics
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_plats.qc
index c714c69eca4a1173a719aa5d90cb8992f1446943..7b2bc9973eacc411b47d6b7c015163fd717b13a5 100644 (file)
@@ -1,9 +1,8 @@
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
-       #include "../dpdefs/progsdefs.qc"
-    #include "../dpdefs/dpextensions.qc"
-    #include "sys-post.qh"
+       #include "../dpdefs/progsdefs.qh"
+    #include "../dpdefs/dpextensions.qh"
     #include "../warpzonelib/mathlib.qh"
     #include "../warpzonelib/common.qh"
     #include "../warpzonelib/util_server.qh"
@@ -18,6 +17,8 @@
     #include "../csqcmodellib/sv_model.qh"
 #endif
 
+#ifdef SVQC
+
 .float dmgtime2;
 void generic_plat_blocked()
 {
@@ -57,19 +58,19 @@ void plat_spawn_inside_trigger()
 
        tmin = self.absmin + '25 25 0';
        tmax = self.absmax - '25 25 -8';
-       tmin_z = tmax.z - (self.pos1_z - self.pos2_z + 8);
+       tmin.z = tmax.z - (self.pos1_z - self.pos2_z + 8);
        if (self.spawnflags & PLAT_LOW_TRIGGER)
-               tmax_z = tmin.z + 8;
+               tmax.z = tmin.z + 8;
 
        if (self.size.x <= 50)
        {
-               tmin_x = (self.mins.x + self.maxs.x) / 2;
-               tmax_x = tmin.x + 1;
+               tmin.x = (self.mins.x + self.maxs.x) / 2;
+               tmax.x = tmin.x + 1;
        }
        if (self.size.y <= 50)
        {
-               tmin_y = (self.mins.y + self.maxs.y) / 2;
-               tmax_y = tmin.y + 1;
+               tmin.y = (self.mins.y + self.maxs.y) / 2;
+               tmax.y = tmin.y + 1;
        }
 
        if(tmin.x < tmax.x)
@@ -329,7 +330,7 @@ void train_wait()
                else // linear movement
                        ang = targ.origin - (self.origin - self.view_ofs); // use the origin of the next path_corner
                ang = vectoangles(ang);
-               ang_x = -ang.x; // flip up / down orientation
+               ang.x = -ang.x; // flip up / down orientation
 
                if(self.wait > 0) // slow turning
                        SUB_CalcAngleMove(ang, TSPEED_TIME, self.ltime - time + self.wait, train_wait);
@@ -437,7 +438,7 @@ void spawnfunc_func_train()
        if (!InitMovingBrushTrigger())
                return;
        self.effects |= EF_LOWPRECISION;
-       
+
        if (self.spawnflags & 2)
        {
                self.platmovetype_turn = true;
@@ -1409,17 +1410,17 @@ void LinkDoors()
                if((t.message != "") && (self.message == ""))
                        self.message = t.message;
                if (t.absmin.x < cmins.x)
-                       cmins_x = t.absmin.x;
+                       cmins.x = t.absmin.x;
                if (t.absmin.y < cmins.y)
-                       cmins_y = t.absmin.y;
+                       cmins.y = t.absmin.y;
                if (t.absmin.z < cmins.z)
-                       cmins_z = t.absmin.z;
+                       cmins.z = t.absmin.z;
                if (t.absmax.x > cmaxs.x)
-                       cmaxs_x = t.absmax.x;
+                       cmaxs.x = t.absmax.x;
                if (t.absmax.y > cmaxs.y)
-                       cmaxs_y = t.absmax.y;
+                       cmaxs.y = t.absmax.y;
                if (t.absmax.z > cmaxs.z)
-                       cmaxs_z = t.absmax.z;
+                       cmaxs.z = t.absmax.z;
                if(t.enemy == self)
                        break;
        }
@@ -1628,7 +1629,7 @@ void spawnfunc_func_door_rotating()
        else // Z
                self.movedir = '0 1 0';
 
-       if (self.angles_y ==0) self.angles_y = 90;
+       if (self.angles.y ==0) self.angles_y = 90;
 
        self.movedir = self.movedir * self.angles.y;
        self.angles = '0 0 0';
@@ -2183,8 +2184,15 @@ void spawnfunc_func_vectormamamam()
        InitializeEntity(self, func_vectormamamam_findtarget, INITPRIO_FINDTARGET);
 }
 
+#endif
+
 void conveyor_think()
 {
+#ifdef CSQC
+       float dt = time - self.move_time;
+       self.move_time = time;
+       if(dt <= 0) { return; }
+#endif
        entity e;
 
        // set myself as current conveyor where possible
@@ -2195,7 +2203,11 @@ void conveyor_think()
        {
                for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
                        if(!e.conveyor.state)
+#ifdef SVQC
                                if(isPushable(e))
+#elif defined(CSQC)
+                               if(e.isplayermodel)
+#endif
                                {
                                        vector emin = e.absmin;
                                        vector emax = e.absmax;
@@ -2211,12 +2223,19 @@ void conveyor_think()
 
                for(e = world; (e = findentity(e, conveyor, self)); )
                {
+#ifdef SVQC
                        if(IS_CLIENT(e)) // doing it via velocity has quite some advantages
                                continue; // done in SV_PlayerPhysics
+#elif defined(CSQC)
+                       if(e.isplayermodel)
+                               continue;
+#endif
 
-                       setorigin(e, e.origin + self.movedir * sys_frametime);
+                       setorigin(e, e.origin + self.movedir * PHYS_INPUT_FRAMETIME);
                        move_out_of_solid(e);
+#ifdef SVQC
                        UpdateCSQCProjectile(e);
+#endif
                        /*
                        // stupid conveyor code
                        tracebox(e.origin, e.mins, e.maxs, e.origin + self.movedir * sys_frametime, MOVE_NORMAL, e);
@@ -2226,17 +2245,61 @@ void conveyor_think()
                }
        }
 
+#ifdef SVQC
        self.nextthink = time;
+#endif
 }
 
+#ifdef SVQC
+
 void conveyor_use()
 {
        self.state = !self.state;
+
+       self.SendFlags |= 2;
 }
 
 void conveyor_reset()
 {
        self.state = (self.spawnflags & 1);
+
+       self.SendFlags |= 2;
+}
+
+float conveyor_send(entity to, float sf)
+{
+       WriteByte(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
+       WriteByte(MSG_ENTITY, sf);
+
+       if(sf & 1)
+       {
+               WriteByte(MSG_ENTITY, self.warpzone_isboxy);
+               WriteCoord(MSG_ENTITY, self.origin_x);
+               WriteCoord(MSG_ENTITY, self.origin_y);
+               WriteCoord(MSG_ENTITY, self.origin_z);
+
+               WriteCoord(MSG_ENTITY, self.mins_x);
+               WriteCoord(MSG_ENTITY, self.mins_y);
+               WriteCoord(MSG_ENTITY, self.mins_z);
+               WriteCoord(MSG_ENTITY, self.maxs_x);
+               WriteCoord(MSG_ENTITY, self.maxs_y);
+               WriteCoord(MSG_ENTITY, self.maxs_z);
+
+               WriteCoord(MSG_ENTITY, self.movedir_x);
+               WriteCoord(MSG_ENTITY, self.movedir_y);
+               WriteCoord(MSG_ENTITY, self.movedir_z);
+
+               WriteByte(MSG_ENTITY, self.speed);
+               WriteByte(MSG_ENTITY, self.state);
+
+               WriteString(MSG_ENTITY, self.targetname);
+               WriteString(MSG_ENTITY, self.target);
+       }
+
+       if(sf & 2)
+               WriteByte(MSG_ENTITY, self.state);
+
+       return true;
 }
 
 void conveyor_init()
@@ -2254,6 +2317,10 @@ void conveyor_init()
        }
        else
                self.state = 1;
+
+       Net_LinkEntity(self, 0, false, conveyor_send);
+
+       self.SendFlags |= 1;
 }
 
 void spawnfunc_trigger_conveyor()
@@ -2270,3 +2337,56 @@ void spawnfunc_func_conveyor()
        self.movetype = MOVETYPE_NONE;
        conveyor_init();
 }
+
+#elif defined(CSQC)
+
+void conveyor_init()
+{
+       self.draw = conveyor_think;
+       self.drawmask = MASK_NORMAL;
+
+       self.movetype = MOVETYPE_NONE;
+       self.model = "";
+       self.solid = SOLID_TRIGGER;
+       self.move_origin = self.origin;
+       self.move_time = time;
+}
+
+void ent_conveyor()
+{
+       float sf = ReadByte();
+
+       if(sf & 1)
+       {
+               self.warpzone_isboxy = ReadByte();
+               self.origin_x = ReadCoord();
+               self.origin_y = ReadCoord();
+               self.origin_z = ReadCoord();
+               setorigin(self, self.origin);
+
+               self.mins_x = ReadCoord();
+               self.mins_y = ReadCoord();
+               self.mins_z = ReadCoord();
+               self.maxs_x = ReadCoord();
+               self.maxs_y = ReadCoord();
+               self.maxs_z = ReadCoord();
+               setsize(self, self.mins, self.maxs);
+
+               self.movedir_x = ReadCoord();
+               self.movedir_y = ReadCoord();
+               self.movedir_z = ReadCoord();
+
+               self.speed = ReadByte();
+               self.state = ReadByte();
+
+               self.targetname = strzone(ReadString());
+               self.target = strzone(ReadString());
+
+               conveyor_init();
+       }
+
+       if(sf & 2)
+               self.state = ReadByte();
+}
+
+#endif