]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Kill the use of self in movetype code, to make it usable from the player physics...
authorMario <mario@smbclan.net>
Thu, 26 Nov 2015 09:19:49 +0000 (19:19 +1000)
committerMario <mario@smbclan.net>
Thu, 26 Nov 2015 09:19:49 +0000 (19:19 +1000)
25 files changed:
qcsrc/client/weapons/projectile.qc
qcsrc/common/effects/qc/casings.qc
qcsrc/common/effects/qc/gibs.qc
qcsrc/common/movetypes/follow.qc
qcsrc/common/movetypes/movetypes.qc
qcsrc/common/movetypes/movetypes.qh
qcsrc/common/movetypes/push.qc
qcsrc/common/movetypes/push.qh
qcsrc/common/movetypes/step.qc
qcsrc/common/movetypes/toss.qc
qcsrc/common/movetypes/toss.qh
qcsrc/common/movetypes/walk.qc
qcsrc/common/movetypes/walk.qh
qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc
qcsrc/common/physics.qc
qcsrc/common/triggers/func/door.qc
qcsrc/common/triggers/func/plat.qc
qcsrc/common/triggers/func/train.qc
qcsrc/common/triggers/subs.qh
qcsrc/common/turrets/cl_turrets.qc
qcsrc/common/vehicles/vehicle/raptor_weapons.qc
qcsrc/lib/csqcmodel/cl_player.qc
qcsrc/lib/csqcmodel/cl_player.qh
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/t_items.qc

index e0244d4bf982d4b927b5a4386a8d6d65f0081745..1591bad96b5ccba33b54f72a29acbb93cf1bad3f 100644 (file)
@@ -65,14 +65,14 @@ void Projectile_Draw(entity this)
        {
                // self.move_flags &= ~FL_ONGROUND;
                if (self.move_movetype == MOVETYPE_NONE || self.move_movetype == MOVETYPE_FLY)
-                       Movetype_Physics_NoMatchServer();
+                       Movetype_Physics_NoMatchServer(self);
                // the trivial movetypes do not have to match the
                // server's ticrate as they are ticrate independent
                // NOTE: this assumption is only true if MOVETYPE_FLY
                // projectiles detonate on impact. If they continue
                // moving, we might still be ticrate dependent.
                else
-                       Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
+                       Movetype_Physics_MatchServer(self, autocvar_cl_projectiles_sloppy);
                if (!(self.move_flags & FL_ONGROUND))
                        if (self.velocity != '0 0 0')
                                self.move_angles = self.angles = vectoangles(self.velocity);
index 815555df6a500977ec362fee09255f302974dec4..7393217891139454e6848872f4f54937bac3cc1d 100644 (file)
@@ -52,7 +52,7 @@ void Casing_Draw(entity this)
         self.flags &= ~FL_ONGROUND;
     }
 
-    Movetype_Physics_MatchTicrate(autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
+    Movetype_Physics_MatchTicrate(self, autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
     if (wasfreed(self))
         return; // deleted by touch function
 
index ab8dbb8ccf23c85002afaae76f13aad9bcb43fd2..3c778b52ba363feab38f4edfdcdf8e2dfacc181a 100644 (file)
@@ -137,7 +137,7 @@ void Gib_Draw(entity this)
        vector oldorg;
        oldorg = self.origin;
 
-       Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
+       Movetype_Physics_MatchTicrate(self, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
        if(wasfreed(self))
                return;
 
index b636772687ebdc66113ffec3ad69fdabe7995082..2d3e24f44c93ec5e8d4f34b0800d806336f2039d 100644 (file)
@@ -1,31 +1,31 @@
-void _Movetype_Physics_Follow() // SV_Physics_Follow
-{SELFPARAM();
-       entity e = self.move_aiment; // TODO: networking?
+void _Movetype_Physics_Follow(entity this) // SV_Physics_Follow
+{
+       entity e = this.move_aiment; // TODO: networking?
 
        // LordHavoc: implemented rotation on MOVETYPE_FOLLOW objects
-       if(self.move_angles == self.move_punchangle)
+       if(this.move_angles == this.move_punchangle)
        {
-               self.move_origin = e.move_origin + self.view_ofs;
+               this.move_origin = e.move_origin + this.view_ofs;
        }
        else
        {
                vector ang, v;
-               ang_x = -self.move_punchangle_x;
-               ang_y = self.move_punchangle_y;
-               ang_z = self.move_punchangle_z;
+               ang_x = -this.move_punchangle_x;
+               ang_y = this.move_punchangle_y;
+               ang_z = this.move_punchangle_z;
                makevectors(ang);
-               v_x = self.view_ofs_x * v_forward_x + self.view_ofs_y * v_right_x + self.view_ofs_z * v_up_x;
-               v_y = self.view_ofs_x * v_forward_y + self.view_ofs_y * v_right_y + self.view_ofs_z * v_up_y;
-               v_z = self.view_ofs_x * v_forward_z + self.view_ofs_y * v_right_z + self.view_ofs_z * v_up_z;
+               v_x = this.view_ofs_x * v_forward_x + this.view_ofs_y * v_right_x + this.view_ofs_z * v_up_x;
+               v_y = this.view_ofs_x * v_forward_y + this.view_ofs_y * v_right_y + this.view_ofs_z * v_up_y;
+               v_z = this.view_ofs_x * v_forward_z + this.view_ofs_y * v_right_z + this.view_ofs_z * v_up_z;
                ang_x = -e.move_angles_x;
                ang_y = e.move_angles_y;
                ang_z = e.move_angles_z;
                makevectors(ang);
-               self.move_origin_x = v_x * v_forward_x + v_y * v_forward_y + v_z * v_forward_z + e.move_origin_x;
-               self.move_origin_x = v_x * v_right_x + v_y * v_right_y + v_z * v_right_z + e.move_origin_y;
-               self.move_origin_x = v_x * v_up_x + v_y * v_up_y + v_z * v_up_z + e.move_origin_z;
+               this.move_origin_x = v_x * v_forward_x + v_y * v_forward_y + v_z * v_forward_z + e.move_origin_x;
+               this.move_origin_x = v_x * v_right_x + v_y * v_right_y + v_z * v_right_z + e.move_origin_y;
+               this.move_origin_x = v_x * v_up_x + v_y * v_up_y + v_z * v_up_z + e.move_origin_z;
        }
 
-       self.move_angles = e.move_angles + self.v_angle;
-       _Movetype_LinkEdict(false);
+       this.move_angles = e.move_angles + this.v_angle;
+       _Movetype_LinkEdict(this, false);
 }
index 8c96174f2316c7ff0955f47bb217c022e4cf2cb8..6cf3969e6fb168cfcb5c5f10c6e4e861387561db 100644 (file)
        #include "../../server/autocvars.qh"
 #endif
 
-void _Movetype_WallFriction(vector stepnormal)  // SV_WallFriction
+void _Movetype_WallFriction(entity this, vector stepnormal)  // SV_WallFriction
 {
        /*float d, i;
        vector into, side;
-       makevectors(self.v_angle);
+       makevectors(this.v_angle);
        d = (stepnormal * v_forward) + 0.5;
 
        if(d < 0)
        {
-           i = (stepnormal * self.move_velocity);
+           i = (stepnormal * this.move_velocity);
            into = i * stepnormal;
-           side = self.move_velocity - into;
-           self.move_velocity_x = side.x * (1 * d);
-           self.move_velocity_y = side.y * (1 * d);
+           side = this.move_velocity - into;
+           this.move_velocity_x = side.x * (1 * d);
+           this.move_velocity_y = side.y * (1 * d);
        }*/
 }
 
 vector planes[MAX_CLIP_PLANES];
-int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float stepheight) // SV_FlyMove
-{SELFPARAM();
+int _Movetype_FlyMove(entity this, float dt, bool applygravity, vector stepnormal, float stepheight) // SV_FlyMove
+{
        int blocked = 0, bumpcount;
        int i, j, numplanes = 0;
        float time_left = dt, grav = 0;
@@ -44,29 +44,29 @@ int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float step
 
        if(applygravity)
        {
-               self.move_didgravity = 1;
-               grav = dt * (PHYS_ENTGRAVITY(self) ? PHYS_ENTGRAVITY(self) : 1) * PHYS_GRAVITY;
+               this.move_didgravity = 1;
+               grav = dt * (PHYS_ENTGRAVITY(this) ? PHYS_ENTGRAVITY(this) : 1) * PHYS_GRAVITY;
 
-               if(!GAMEPLAYFIX_NOGRAVITYONGROUND || !(self.move_flags & FL_ONGROUND))
+               if(!GAMEPLAYFIX_NOGRAVITYONGROUND || !(this.move_flags & FL_ONGROUND))
                {
                        if(GRAVITY_UNAFFECTED_BY_TICRATE)
-                               self.move_velocity_z -= grav * 0.5;
+                               this.move_velocity_z -= grav * 0.5;
                        else
-                               self.move_velocity_z -= grav;
+                               this.move_velocity_z -= grav;
                }
        }
 
-       original_velocity = primal_velocity = restore_velocity = self.move_velocity;
+       original_velocity = primal_velocity = restore_velocity = this.move_velocity;
 
        for(bumpcount = 0;bumpcount < MAX_CLIP_PLANES;bumpcount++)
        {
-               if(self.move_velocity == '0 0 0')
+               if(this.move_velocity == '0 0 0')
                        break;
 
-               push = self.move_velocity * time_left;
-               vector prev_origin = self.move_origin;
-               _Movetype_PushEntity(push, true);
-               if(trace_startsolid && self.move_origin != prev_origin)
+               push = this.move_velocity * time_left;
+               vector prev_origin = this.move_origin;
+               _Movetype_PushEntity(this, push, true);
+               if(trace_startsolid && this.move_origin != prev_origin)
                {
                        // we got teleported by a touch function
                        // let's abort the move
@@ -78,7 +78,7 @@ int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float step
                // abort move if we're stuck in the world (and didn't make it out)
                if(trace_startsolid && trace_allsolid)
                {
-                       self.move_velocity = restore_velocity;
+                       this.move_velocity = restore_velocity;
                        return 3;
                }
 
@@ -101,47 +101,47 @@ int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float step
                                        trace_ent = world;
                                }
 
-                               self.move_flags |= FL_ONGROUND;
-                               self.move_groundentity = trace_ent;
+                               this.move_flags |= FL_ONGROUND;
+                               this.move_groundentity = trace_ent;
                        }
                }
                else if(stepheight)
                {
                        // step - handle it immediately
-                       vector org = self.move_origin;
+                       vector org = this.move_origin;
                        vector steppush = '0 0 1' * stepheight;
 
-                       _Movetype_PushEntity(steppush, true);
-                       if(trace_startsolid && self.move_origin != org)
+                       _Movetype_PushEntity(this, steppush, true);
+                       if(trace_startsolid && this.move_origin != org)
                        {
                                blocked |= 8;
                                break;
                        }
-                       _Movetype_PushEntity(push, true);
-                       if(trace_startsolid && self.move_origin != org)
+                       _Movetype_PushEntity(this, push, true);
+                       if(trace_startsolid && this.move_origin != org)
                        {
                                blocked |= 8;
                                break;
                        }
                        float trace2_fraction = trace_fraction;
-                       steppush = '0 0 1' * (org_z - self.move_origin_z);
-                       _Movetype_PushEntity(steppush, true);
-                       if(trace_startsolid && self.move_origin != org)
+                       steppush = '0 0 1' * (org_z - this.move_origin_z);
+                       _Movetype_PushEntity(this, steppush, true);
+                       if(trace_startsolid && this.move_origin != org)
                        {
                                blocked |= 8;
                                break;
                        }
 
                        // accept the new position if it made some progress...
-                       if(fabs(self.move_origin_x - org_x) >= 0.03125 || fabs(self.move_origin_y - org_y) >= 0.03125)
+                       if(fabs(this.move_origin_x - org_x) >= 0.03125 || fabs(this.move_origin_y - org_y) >= 0.03125)
                        {
-                               trace_endpos = self.move_origin;
+                               trace_endpos = this.move_origin;
                                time_left *= 1 - trace2_fraction;
                                numplanes = 0;
                                continue;
                        }
                        else
-                               self.move_origin = org;
+                               this.move_origin = org;
                }
                else
                {
@@ -155,7 +155,7 @@ int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float step
                if(my_trace_fraction >= 0.001)
                {
                        // actually covered some distance
-                       original_velocity = self.move_velocity;
+                       original_velocity = this.move_velocity;
                        numplanes = 0;
                }
 
@@ -165,7 +165,7 @@ int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float step
                if(numplanes >= MAX_CLIP_PLANES)
                {
                        // this shouldn't really happen
-                       self.move_velocity = '0 0 0';
+                       this.move_velocity = '0 0 0';
                        blocked = 3;
                        break;
                }
@@ -194,14 +194,14 @@ int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float step
                if(i != numplanes)
                {
                        // go along this plane
-                       self.move_velocity = new_velocity;
+                       this.move_velocity = new_velocity;
                }
                else
                {
                        // go along the crease
                        if(numplanes != 2)
                        {
-                               self.move_velocity = '0 0 0';
+                               this.move_velocity = '0 0 0';
                                blocked = 7;
                                break;
                        }
@@ -213,39 +213,39 @@ int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float step
                        dir.x *= ilength;
                        dir.y *= ilength;
                        dir.z *= ilength;
-                       float d = (dir * self.move_velocity);
-                       self.move_velocity = dir * d;
+                       float d = (dir * this.move_velocity);
+                       this.move_velocity = dir * d;
                }
 
                // if current velocity is against the original velocity,
                // stop dead to avoid tiny occilations in sloping corners
-               if((self.move_velocity * primal_velocity) <= 0)
+               if((this.move_velocity * primal_velocity) <= 0)
                {
-                       self.move_velocity = '0 0 0';
+                       this.move_velocity = '0 0 0';
                        break;
                }
        }
 
        // LordHavoc: this came from QW and allows you to get out of water more easily
-       if(GAMEPLAYFIX_EASIERWATERJUMP && (self.move_flags & FL_WATERJUMP) && !(blocked & 8))
-               self.move_velocity = primal_velocity;
+       if(GAMEPLAYFIX_EASIERWATERJUMP && (this.move_flags & FL_WATERJUMP) && !(blocked & 8))
+               this.move_velocity = primal_velocity;
 
        if(applygravity)
        {
-               if(!GAMEPLAYFIX_NOGRAVITYONGROUND || !(self.move_flags & FL_ONGROUND))
+               if(!GAMEPLAYFIX_NOGRAVITYONGROUND || !(this.move_flags & FL_ONGROUND))
                {
                        if(GRAVITY_UNAFFECTED_BY_TICRATE)
-                               self.move_velocity_z -= grav * 0.5f;
+                               this.move_velocity_z -= grav * 0.5f;
                }
        }
 
        return blocked;
 }
 
-void _Movetype_CheckVelocity()  // SV_CheckVelocity
+void _Movetype_CheckVelocity(entity this)  // SV_CheckVelocity
 {
-       // if(vlen(self.move_velocity) < 0.0001)
-       // self.move_velocity = '0 0 0';
+       // if(vlen(this.move_velocity) < 0.0001)
+       // this.move_velocity = '0 0 0';
 }
 
 bool _Movetype_CheckWater(entity ent)  // SV_CheckWater
@@ -315,22 +315,22 @@ void _Movetype_CheckWaterTransition(entity ent)  // SV_CheckWaterTransition
        }
 }
 
-void _Movetype_Impact(entity oth)  // SV_Impact
-{SELFPARAM();
+void _Movetype_Impact(entity this, entity oth)  // SV_Impact
+{
        entity oldother = other;
 
-       if(self.move_touch)
+       if(this.move_touch)
        {
                other = oth;
 
-               self.move_touch();
+               WITH(entity, self, this, this.move_touch());
 
                other = oldother;
        }
 
        if(oth.move_touch)
        {
-               other = self;
+               other = this;
 
                WITH(entity, self, oth, oth.move_touch());
 
@@ -338,15 +338,14 @@ void _Movetype_Impact(entity oth)  // SV_Impact
        }
 }
 
-void _Movetype_LinkEdict_TouchAreaGrid()  // SV_LinkEdict_TouchAreaGrid
-{SELFPARAM();
+void _Movetype_LinkEdict_TouchAreaGrid(entity this)  // SV_LinkEdict_TouchAreaGrid
+{
        entity oldother = other;
 
-       for (entity e = findradius(0.5 * (self.absmin + self.absmax), 0.5 * vlen(self.absmax - self.absmin)); e; e = e.chain)
+       for (entity e = findradius(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin)); e; e = e.chain)
        {
                if(e.move_touch && boxesoverlap(e.absmin, e.absmax, this.absmin, this.absmax))
                {
-                       setself(e);
                        other = this;
 
                        trace_allsolid = false;
@@ -359,32 +358,31 @@ void _Movetype_LinkEdict_TouchAreaGrid()  // SV_LinkEdict_TouchAreaGrid
                        trace_plane_dist = 0;
                        trace_ent = this;
 
-                       e.move_touch();
+                       WITH(entity, self, e, e.move_touch());
                }
        }
 
        other = oldother;
-       setself(this);
 }
 
-void _Movetype_LinkEdict(bool touch_triggers)  // SV_LinkEdict
-{SELFPARAM();
+void _Movetype_LinkEdict(entity this, bool touch_triggers)  // SV_LinkEdict
+{
        vector mi, ma;
-       if(self.solid == SOLID_BSP)
+       if(this.solid == SOLID_BSP)
        {
                // TODO set the absolute bbox
-               mi = self.mins;
-               ma = self.maxs;
+               mi = this.mins;
+               ma = this.maxs;
        }
        else
        {
-               mi = self.mins;
-               ma = self.maxs;
+               mi = this.mins;
+               ma = this.maxs;
        }
-       mi += self.move_origin;
-       ma += self.move_origin;
+       mi += this.move_origin;
+       ma += this.move_origin;
 
-       if(self.move_flags & FL_ITEM)
+       if(this.move_flags & FL_ITEM)
        {
                mi.x -= 15;
                mi.y -= 15;
@@ -403,53 +401,53 @@ void _Movetype_LinkEdict(bool touch_triggers)  // SV_LinkEdict
                ma.z += 1;
        }
 
-       self.absmin = mi;
-       self.absmax = ma;
+       this.absmin = mi;
+       this.absmax = ma;
 
        if(touch_triggers)
-               _Movetype_LinkEdict_TouchAreaGrid();
+               _Movetype_LinkEdict_TouchAreaGrid(this);
 }
 
-bool _Movetype_TestEntityPosition(vector ofs)  // SV_TestEntityPosition
-{SELFPARAM();
-//     vector org = self.move_origin + ofs;
+bool _Movetype_TestEntityPosition(entity this, vector ofs)  // SV_TestEntityPosition
+{
+//     vector org = this.move_origin + ofs;
 
-       int cont = self.dphitcontentsmask;
-       self.dphitcontentsmask = DPCONTENTS_SOLID;
-       tracebox(self.move_origin, self.mins, self.maxs, self.move_origin, MOVE_NOMONSTERS, self);
-       self.dphitcontentsmask = cont;
+       int cont = this.dphitcontentsmask;
+       this.dphitcontentsmask = DPCONTENTS_SOLID;
+       tracebox(this.move_origin, this.mins, this.maxs, this.move_origin, MOVE_NOMONSTERS, this);
+       this.dphitcontentsmask = cont;
 
        if(trace_startsolid)
                return true;
 
-       if(vlen(trace_endpos - self.move_origin) > 0.0001)
-               self.move_origin = trace_endpos;
+       if(vlen(trace_endpos - this.move_origin) > 0.0001)
+               this.move_origin = trace_endpos;
        return false;
 }
 
-bool _Movetype_UnstickEntity()  // SV_UnstickEntity
-{SELFPARAM();
-       if(!_Movetype_TestEntityPosition('0 0 0')) return true;
-       if(!_Movetype_TestEntityPosition('-1 0 0')) goto success;
-       if(!_Movetype_TestEntityPosition('1 0 0')) goto success;
-       if(!_Movetype_TestEntityPosition('0 -1 0')) goto success;
-       if(!_Movetype_TestEntityPosition('0 1 0')) goto success;
-       if(!_Movetype_TestEntityPosition('-1 -1 0')) goto success;
-       if(!_Movetype_TestEntityPosition('1 -1 0')) goto success;
-       if(!_Movetype_TestEntityPosition('-1 1 0')) goto success;
-       if(!_Movetype_TestEntityPosition('1 1 0')) goto success;
+bool _Movetype_UnstickEntity(entity this)  // SV_UnstickEntity
+{
+       if(!_Movetype_TestEntityPosition(this, '0 0 0')) return true;
+       if(!_Movetype_TestEntityPosition(this, '-1 0 0')) goto success;
+       if(!_Movetype_TestEntityPosition(this, '1 0 0')) goto success;
+       if(!_Movetype_TestEntityPosition(this, '0 -1 0')) goto success;
+       if(!_Movetype_TestEntityPosition(this, '0 1 0')) goto success;
+       if(!_Movetype_TestEntityPosition(this, '-1 -1 0')) goto success;
+       if(!_Movetype_TestEntityPosition(this, '1 -1 0')) goto success;
+       if(!_Movetype_TestEntityPosition(this, '-1 1 0')) goto success;
+       if(!_Movetype_TestEntityPosition(this, '1 1 0')) goto success;
        for (int i = 1; i <= 17; ++i)
        {
-               if(!_Movetype_TestEntityPosition('0 0 -1' * i)) goto success;
-               if(!_Movetype_TestEntityPosition('0 0 1' * i)) goto success;
+               if(!_Movetype_TestEntityPosition(this, '0 0 -1' * i)) goto success;
+               if(!_Movetype_TestEntityPosition(this, '0 0 1' * i)) goto success;
        }
        LOG_TRACEF("Can't unstick an entity (edict: %d, classname: %s, origin: %s)\n",
-               num_for_edict(self), self.classname, vtos(self.move_origin));
+               num_for_edict(this), this.classname, vtos(this.move_origin));
        return false;
        : success;
        LOG_TRACEF("Sucessfully unstuck an entity (edict: %d, classname: %s, origin: %s)\n",
-               num_for_edict(self), self.classname, vtos(self.move_origin));
-       _Movetype_LinkEdict(true);
+               num_for_edict(this), this.classname, vtos(this.move_origin));
+       _Movetype_LinkEdict(this, true);
        return true;
 }
 
@@ -464,34 +462,34 @@ vector _Movetype_ClipVelocity(vector vel, vector norm, float f)  // SV_ClipVeloc
        return vel;
 }
 
-void _Movetype_PushEntityTrace(vector push)
-{SELFPARAM();
-       vector end = self.move_origin + push;
+void _Movetype_PushEntityTrace(entity this, vector push)
+{
+       vector end = this.move_origin + push;
        int type;
-       if(self.move_nomonsters)
-               type = max(0, self.move_nomonsters);
-       else if(self.move_movetype == MOVETYPE_FLYMISSILE)
+       if(this.move_nomonsters)
+               type = max(0, this.move_nomonsters);
+       else if(this.move_movetype == MOVETYPE_FLYMISSILE)
                type = MOVE_MISSILE;
-       else if(self.solid == SOLID_TRIGGER || self.solid == SOLID_NOT)
+       else if(this.solid == SOLID_TRIGGER || this.solid == SOLID_NOT)
                type = MOVE_NOMONSTERS;
        else
                type = MOVE_NORMAL;
 
-       tracebox(self.move_origin, self.mins, self.maxs, end, type, self);
+       tracebox(this.move_origin, this.mins, this.maxs, end, type, this);
 }
 
-float _Movetype_PushEntity(vector push, bool failonstartsolid)  // SV_PushEntity
-{SELFPARAM();
-       _Movetype_PushEntityTrace(push);
+float _Movetype_PushEntity(entity this, vector push, bool failonstartsolid)  // SV_PushEntity
+{
+       _Movetype_PushEntityTrace(this, push);
 
        if(trace_startsolid && failonstartsolid)
                return trace_fraction;
 
-       self.move_origin = trace_endpos;
+       this.move_origin = trace_endpos;
 
        if(trace_fraction < 1)
-               if(self.solid >= SOLID_TRIGGER && (!(self.move_flags & FL_ONGROUND) || (self.move_groundentity != trace_ent)))
-                       _Movetype_Impact(trace_ent);
+               if(this.solid >= SOLID_TRIGGER && (!(this.move_flags & FL_ONGROUND) || (this.move_groundentity != trace_ent)))
+                       _Movetype_Impact(this, trace_ent);
 
        return trace_fraction;
 }
@@ -554,121 +552,121 @@ void makevectors_matrix(vector myangles)  // AngleVectorsFLU
        }
 }
 
-void _Movetype_Physics_Frame(float movedt)
-{SELFPARAM();
-       self.move_didgravity = -1;
-       switch (self.move_movetype)
+void _Movetype_Physics_Frame(entity this, float movedt)
+{
+       this.move_didgravity = -1;
+       switch (this.move_movetype)
        {
                case MOVETYPE_PUSH:
                case MOVETYPE_FAKEPUSH:
-                       _Movetype_Physics_Pusher(movedt);
+                       _Movetype_Physics_Pusher(this, movedt);
                        break;
                case MOVETYPE_NONE:
                        break;
                case MOVETYPE_FOLLOW:
-                       _Movetype_Physics_Follow();
+                       _Movetype_Physics_Follow(this);
                        break;
                case MOVETYPE_NOCLIP:
-                       _Movetype_CheckWater(self);
-                       self.move_origin = self.move_origin + TICRATE * self.move_velocity;
-                       self.move_angles = self.move_angles + TICRATE * self.move_avelocity;
-                       _Movetype_LinkEdict(false);
+                       _Movetype_CheckWater(this);
+                       this.move_origin = this.move_origin + TICRATE * this.move_velocity;
+                       this.move_angles = this.move_angles + TICRATE * this.move_avelocity;
+                       _Movetype_LinkEdict(this, false);
                        break;
                case MOVETYPE_STEP:
-                       _Movetype_Physics_Step(movedt);
+                       _Movetype_Physics_Step(this, movedt);
                        break;
                case MOVETYPE_WALK:
-                       _Movetype_Physics_Walk(movedt);
+                       _Movetype_Physics_Walk(this, movedt);
                        break;
                case MOVETYPE_TOSS:
                case MOVETYPE_BOUNCE:
                case MOVETYPE_BOUNCEMISSILE:
                case MOVETYPE_FLYMISSILE:
                case MOVETYPE_FLY:
-                       _Movetype_Physics_Toss(movedt);
+                       _Movetype_Physics_Toss(this, movedt);
                        break;
        }
 }
 
-void Movetype_Physics_NoMatchServer()  // optimized
-{SELFPARAM();
-       float movedt = time - self.move_time;
-       self.move_time = time;
+void Movetype_Physics_NoMatchServer(entity this)  // optimized
+{
+       float movedt = time - this.move_time;
+       this.move_time = time;
 
-       _Movetype_Physics_Frame(movedt);
-       if(wasfreed(self))
+       _Movetype_Physics_Frame(this, movedt);
+       if(wasfreed(this))
                return;
 
-       self.avelocity = self.move_avelocity;
-       self.velocity = self.move_velocity;
-       self.angles = self.move_angles;
-       setorigin(self, self.move_origin);
+       this.avelocity = this.move_avelocity;
+       this.velocity = this.move_velocity;
+       this.angles = this.move_angles;
+       setorigin(this, this.move_origin);
 }
 
-void Movetype_Physics_MatchServer(bool sloppy)
+void Movetype_Physics_MatchServer(entity this, bool sloppy)
 {
-       Movetype_Physics_MatchTicrate(TICRATE, sloppy);
+       Movetype_Physics_MatchTicrate(this, TICRATE, sloppy);
 }
 
-void Movetype_Physics_MatchTicrate(float tr, bool sloppy)  // SV_Physics_Entity
-{SELFPARAM();
+void Movetype_Physics_MatchTicrate(entity this, float tr, bool sloppy)  // SV_Physics_Entity
+{
        if(tr <= 0)
        {
-               Movetype_Physics_NoMatchServer();
+               Movetype_Physics_NoMatchServer(this);
                return;
        }
 
-       float dt = time - self.move_time;
+       float dt = time - this.move_time;
 
        int n = max(0, floor(dt / tr));
        dt -= n * tr;
-       self.move_time += n * tr;
+       this.move_time += n * tr;
 
-       if(!self.move_didgravity)
-               self.move_didgravity = ((self.move_movetype == MOVETYPE_BOUNCE || self.move_movetype == MOVETYPE_TOSS) && !(self.move_flags & FL_ONGROUND));
+       if(!this.move_didgravity)
+               this.move_didgravity = ((this.move_movetype == MOVETYPE_BOUNCE || this.move_movetype == MOVETYPE_TOSS) && !(this.move_flags & FL_ONGROUND));
 
        for (int i = 0; i < n; ++i)
        {
-               _Movetype_Physics_Frame(tr);
-               if(wasfreed(self))
+               _Movetype_Physics_Frame(this, tr);
+               if(wasfreed(this))
                        return;
        }
 
-       self.avelocity = self.move_avelocity;
+       this.avelocity = this.move_avelocity;
 
-       if(dt > 0 && self.move_movetype != MOVETYPE_NONE && !(self.move_flags & FL_ONGROUND))
+       if(dt > 0 && this.move_movetype != MOVETYPE_NONE && !(this.move_flags & FL_ONGROUND))
        {
                // now continue the move from move_time to time
-               self.velocity = self.move_velocity;
+               this.velocity = this.move_velocity;
 
-               if(self.move_didgravity > 0)
+               if(this.move_didgravity > 0)
                {
-                       self.velocity_z -= (GRAVITY_UNAFFECTED_BY_TICRATE ? 0.5 : 1)
+                       this.velocity_z -= (GRAVITY_UNAFFECTED_BY_TICRATE ? 0.5 : 1)
                            * dt
-                           * (self.gravity ? self.gravity : 1)
+                           * (this.gravity ? this.gravity : 1)
                            * PHYS_GRAVITY;
                }
 
-               self.angles = self.move_angles + dt * self.avelocity;
+               this.angles = this.move_angles + dt * this.avelocity;
 
-               if(sloppy || self.move_movetype == MOVETYPE_NOCLIP)
+               if(sloppy || this.move_movetype == MOVETYPE_NOCLIP)
                {
-                       setorigin(self, self.move_origin + dt * self.velocity);
+                       setorigin(this, this.move_origin + dt * this.velocity);
                }
                else
                {
-                       _Movetype_PushEntityTrace(dt * self.velocity);
+                       _Movetype_PushEntityTrace(this, dt * this.velocity);
                        if(!trace_startsolid)
-                               setorigin(self, trace_endpos);
+                               setorigin(this, trace_endpos);
                }
 
-               if(self.move_didgravity > 0 && GRAVITY_UNAFFECTED_BY_TICRATE)
-                       self.velocity_z -= 0.5 * dt * (self.gravity ? self.gravity : 1) * PHYS_GRAVITY;
+               if(this.move_didgravity > 0 && GRAVITY_UNAFFECTED_BY_TICRATE)
+                       this.velocity_z -= 0.5 * dt * (this.gravity ? this.gravity : 1) * PHYS_GRAVITY;
        }
        else
        {
-               self.velocity = self.move_velocity;
-               self.angles = self.move_angles;
-               setorigin(self, self.move_origin);
+               this.velocity = this.move_velocity;
+               this.angles = this.move_angles;
+               setorigin(this, this.move_origin);
        }
 }
index 362075da2d3bfdd2f9a5e22378f547463678e40c..2102247d5523f68fa577da36bc4dea20e12c834a 100644 (file)
@@ -45,27 +45,27 @@ float autocvar_cl_gameplayfix_fixedcheckwatertransition = 1;
 .float move_suspendedinair;
 .float move_didgravity;
 
-void _Movetype_WallFriction(vector stepnormal);
-int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float stepheight);
-void _Movetype_CheckVelocity();
+void _Movetype_WallFriction(entity this, vector stepnormal);
+int _Movetype_FlyMove(entity this, float dt, bool applygravity, vector stepnormal, float stepheight);
+void _Movetype_CheckVelocity(entity this);
 void _Movetype_CheckWaterTransition(entity ent);
 float _Movetype_CheckWater(entity ent);
-void _Movetype_LinkEdict_TouchAreaGrid();
-void _Movetype_LinkEdict(float touch_triggers);
-float _Movetype_TestEntityPosition(vector ofs);
-float _Movetype_UnstickEntity();
+void _Movetype_LinkEdict_TouchAreaGrid(entity this);
+void _Movetype_LinkEdict(entity this, float touch_triggers);
+float _Movetype_TestEntityPosition(entity this, vector ofs);
+float _Movetype_UnstickEntity(entity this);
 vector _Movetype_ClipVelocity(vector vel, vector norm, float f);
-void _Movetype_PushEntityTrace(vector push);
-float _Movetype_PushEntity(vector push, float failonstartsolid);
+void _Movetype_PushEntityTrace(entity this, vector push);
+float _Movetype_PushEntity(entity this, vector push, float failonstartsolid);
 void makevectors_matrix(vector myangles);
 
-void Movetype_Physics_MatchTicrate(float tr, bool sloppy);
-void Movetype_Physics_MatchServer(bool sloppy);
-void Movetype_Physics_NoMatchServer();
-void _Movetype_LinkEdict(float touch_triggers);
-void _Movetype_LinkEdict_TouchAreaGrid();
+void Movetype_Physics_MatchTicrate(entity this, float tr, bool sloppy);
+void Movetype_Physics_MatchServer(entity this, bool sloppy);
+void Movetype_Physics_NoMatchServer(entity this);
+void _Movetype_LinkEdict(entity this, float touch_triggers);
+void _Movetype_LinkEdict_TouchAreaGrid(entity this);
 
-float _Movetype_UnstickEntity();
+float _Movetype_UnstickEntity(entity this);
 
 const int MAX_CLIP_PLANES = 5;
 
index aeb75ded3053773acb45263e9fb46fe86636079b..c45fe5949dfde3360e86f2926e85be585f4f05b6 100644 (file)
@@ -1,12 +1,12 @@
-void _Movetype_PushMove(float dt)  // SV_PushMove
-{SELFPARAM();
-       if (self.move_velocity == '0 0 0' && self.move_avelocity == '0 0 0')
+void _Movetype_PushMove(entity this, float dt)  // SV_PushMove
+{
+       if (this.move_velocity == '0 0 0' && this.move_avelocity == '0 0 0')
        {
-               self.move_ltime += dt;
+               this.move_ltime += dt;
                return;
        }
 
-       switch (self.solid)
+       switch (this.solid)
        {
                // LordHavoc: valid pusher types
                case SOLID_BSP:
@@ -17,43 +17,43 @@ void _Movetype_PushMove(float dt)  // SV_PushMove
                // LordHavoc: no collisions
                case SOLID_NOT:
                case SOLID_TRIGGER:
-                       self.move_origin = self.move_origin + dt * self.move_velocity;
-                       self.move_angles = self.move_angles + dt * self.move_avelocity;
-                       self.move_angles_x -= 360.0 * floor(self.move_angles.x * (1.0 / 360.0));
-                       self.move_angles_y -= 360.0 * floor(self.move_angles.y * (1.0 / 360.0));
-                       self.move_angles_z -= 360.0 * floor(self.move_angles.z * (1.0 / 360.0));
-                       self.move_ltime += dt;
-                       _Movetype_LinkEdict(true);
+                       this.move_origin = this.move_origin + dt * this.move_velocity;
+                       this.move_angles = this.move_angles + dt * this.move_avelocity;
+                       this.move_angles_x -= 360.0 * floor(this.move_angles.x * (1.0 / 360.0));
+                       this.move_angles_y -= 360.0 * floor(this.move_angles.y * (1.0 / 360.0));
+                       this.move_angles_z -= 360.0 * floor(this.move_angles.z * (1.0 / 360.0));
+                       this.move_ltime += dt;
+                       _Movetype_LinkEdict(this, true);
                        return;
                default:
-                       LOG_TRACEF("_Movetype_PushMove: entity %e, unrecognized solid type %d\n", self, self.solid);
+                       LOG_TRACEF("_Movetype_PushMove: entity %e, unrecognized solid type %d\n", this, this.solid);
                        return;
        }
 
-       bool rotated = (self.move_angles * self.move_angles) + (self.move_avelocity * self.move_avelocity) > 0;
+       bool rotated = (this.move_angles * this.move_angles) + (this.move_avelocity * this.move_avelocity) > 0;
 
-       vector move1 = self.move_velocity * dt;
-       vector moveangle = self.move_avelocity * dt;
+       vector move1 = this.move_velocity * dt;
+       vector moveangle = this.move_avelocity * dt;
 
        makevectors_matrix(-moveangle);
 
-//     vector pushorig = self.move_origin;
-//     vector pushang = self.move_angles;
-//     float pushltime = self.move_ltime;
+//     vector pushorig = this.move_origin;
+//     vector pushang = this.move_angles;
+//     float pushltime = this.move_ltime;
 
 // move the pusher to its final position
 
-       self.move_origin = self.move_origin + dt * self.move_velocity;
-       self.move_angles = self.move_angles + dt * self.move_avelocity;
+       this.move_origin = this.move_origin + dt * this.move_velocity;
+       this.move_angles = this.move_angles + dt * this.move_avelocity;
 
-       self.move_ltime += dt;
-       _Movetype_LinkEdict(true);
+       this.move_ltime += dt;
+       _Movetype_LinkEdict(this, true);
 
-       int savesolid = self.solid;
+       int savesolid = this.solid;
 
-       if (self.move_movetype != MOVETYPE_FAKEPUSH)
+       if (this.move_movetype != MOVETYPE_FAKEPUSH)
        {
-               for (entity check = findradius(0.5 * (self.absmin + self.absmax), 0.5 * vlen(self.absmax - self.absmin)); check; check = check.chain)
+               for (entity check = findradius(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin)); check; check = check.chain)
                {
                        switch (check.move_movetype)
                        {
@@ -67,17 +67,17 @@ void _Movetype_PushMove(float dt)  // SV_PushMove
                                        break;
                        }
 
-                       if (check.owner == self)
+                       if (check.owner == this)
                                continue;
 
-                       if (self.owner == check)
+                       if (this.owner == check)
                                continue;
 
                        vector pivot = check.mins + 0.5 * (check.maxs - check.mins);
                        vector move;
                        if (rotated)
                        {
-                               vector org = (check.move_origin - self.move_origin) + pivot;
+                               vector org = (check.move_origin - this.move_origin) + pivot;
                                vector org2;
                                org2.x = org * v_forward;
                                org2.y = org * v_right;
@@ -93,48 +93,48 @@ void _Movetype_PushMove(float dt)  // SV_PushMove
                        if (check.move_movetype == 32)  // MOVETYPE_PHYSICS
                        {
                                check.move_origin = check.move_origin + move;
-                               WITH(entity, self, check, _Movetype_LinkEdict(true));
+                               WITH(entity, this, check, _Movetype_LinkEdict(this, true));
                                continue;
                        }
 
                        // try moving the contacted entity
-                       self.solid = SOLID_NOT;
+                       this.solid = SOLID_NOT;
                        bool flag;
-                       WITH(entity, self, check, {
-                               flag = _Movetype_PushEntity(move, true);
+                       WITH(entity, this, check, {
+                               flag = _Movetype_PushEntity(this, move, true);
                        });
                        if (!flag)
                        {
                                // entity "check" got teleported
                                check.move_angles_y += trace_fraction * moveangle.y;
-                               self.solid = savesolid;
+                               this.solid = savesolid;
                                continue;  // pushed enough
                        }
                        // FIXME: turn players specially
                        check.move_angles_y += trace_fraction * moveangle.y;
-                       self.solid = savesolid;
+                       this.solid = savesolid;
 
                        // this trace.fraction < 1 check causes items to fall off of pushers
                        // if they pass under or through a wall
                        // the groundentity check causes items to fall off of ledges
-                       if (check.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || check.move_groundentity != self))
+                       if (check.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || check.move_groundentity != this))
                                check.move_flags &= ~FL_ONGROUND;
                }
        }
 
-       self.move_angles_x -= 360.0 * floor(self.move_angles.x * (1.0 / 360.0));
-       self.move_angles_y -= 360.0 * floor(self.move_angles.y * (1.0 / 360.0));
-       self.move_angles_z -= 360.0 * floor(self.move_angles.z * (1.0 / 360.0));
+       this.move_angles_x -= 360.0 * floor(this.move_angles.x * (1.0 / 360.0));
+       this.move_angles_y -= 360.0 * floor(this.move_angles.y * (1.0 / 360.0));
+       this.move_angles_z -= 360.0 * floor(this.move_angles.z * (1.0 / 360.0));
 }
 
-void _Movetype_Physics_Pusher(float dt)  // SV_Physics_Pusher
-{SELFPARAM();
-       float oldltime = self.move_ltime;
-       float thinktime = self.move_nextthink;
+void _Movetype_Physics_Pusher(entity this, float dt)  // SV_Physics_Pusher
+{
+       float oldltime = this.move_ltime;
+       float thinktime = this.move_nextthink;
        float movetime;
-       if (thinktime < self.move_ltime + dt)
+       if (thinktime < this.move_ltime + dt)
        {
-               movetime = thinktime - self.move_ltime;
+               movetime = thinktime - this.move_ltime;
                if (movetime < 0)
                        movetime = 0;
        }
@@ -144,15 +144,14 @@ void _Movetype_Physics_Pusher(float dt)  // SV_Physics_Pusher
        }
 
        if (movetime)
-               // advances self.move_ltime if not blocked
-               _Movetype_PushMove(movetime);
+               // advances this.move_ltime if not blocked
+               _Movetype_PushMove(this, movetime);
 
-       if (thinktime > oldltime && thinktime <= self.move_ltime)
+       if (thinktime > oldltime && thinktime <= this.move_ltime)
        {
-               self.move_nextthink = 0;
-               self.move_time = time;
+               this.move_nextthink = 0;
+               this.move_time = time;
                other = world;
-               if (self.move_think)
-                       self.move_think();
+               WITH(entity, self, this, this.move_think());
        }
 }
index 685982b144b06e8f3e3967bd1de71da0405f857a..d0c8493b732956a6fc060ed3fe1d54292516d0bd 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef MOVETYPE_PUSH_H
 #define MOVETYPE_PUSH_H
 
-void _Movetype_Physics_Pusher(float dt);
+void _Movetype_Physics_Pusher(entity this, float dt);
 
 #endif
index f4884ba27a23a5137af32c369dade827dc06d282..eec9b4c0965d4b27e640bc29441d503625fca5f7 100644 (file)
@@ -1,23 +1,23 @@
-void _Movetype_Physics_Step(float dt) // SV_Physics_Step
-{SELFPARAM();
-       if(self.move_flags & FL_ONGROUND)
+void _Movetype_Physics_Step(entity this, float dt) // SV_Physics_Step
+{
+       if(this.move_flags & FL_ONGROUND)
        {
-               if(self.velocity_z >= (1.0 / 32.0) && UPWARD_VELOCITY_CLEARS_ONGROUND)
+               if(this.velocity_z >= (1.0 / 32.0) && UPWARD_VELOCITY_CLEARS_ONGROUND)
                {
-                       self.move_flags &= ~FL_ONGROUND;
-                       _Movetype_CheckVelocity();
-                       _Movetype_FlyMove(dt, true, '0 0 0', 0);
-                       _Movetype_LinkEdict(true);
+                       this.move_flags &= ~FL_ONGROUND;
+                       _Movetype_CheckVelocity(this);
+                       _Movetype_FlyMove(this, dt, true, '0 0 0', 0);
+                       _Movetype_LinkEdict(this, true);
                }
        }
        else
        {
-               _Movetype_CheckVelocity();
-               _Movetype_FlyMove(dt, true, '0 0 0', 0);
-               _Movetype_LinkEdict(true);
+               _Movetype_CheckVelocity(this);
+               _Movetype_FlyMove(this, dt, true, '0 0 0', 0);
+               _Movetype_LinkEdict(this, true);
 
                // TODO? movetypesteplandevent
        }
 
-       _Movetype_CheckWaterTransition(self);
+       _Movetype_CheckWaterTransition(this);
 }
index 32ce9ca31223f4afd2b42c00259ec2fce1e3f214..06302090f2189cd8e7143186072096fb4cd5e427 100644 (file)
@@ -1,52 +1,52 @@
 #include "../physics.qh"
 
-void _Movetype_Physics_Toss(float dt)  // SV_Physics_Toss
-{SELFPARAM();
-       if (self.move_flags & FL_ONGROUND)
+void _Movetype_Physics_Toss(entity this, float dt)  // SV_Physics_Toss
+{
+       if (this.move_flags & FL_ONGROUND)
        {
-               if (self.move_velocity.z >= 1 / 32)
+               if (this.move_velocity.z >= 1 / 32)
                {
-                       self.move_flags &= ~FL_ONGROUND;
+                       this.move_flags &= ~FL_ONGROUND;
                }
-               else if (!self.move_groundentity)
+               else if (!this.move_groundentity)
                {
                        return;
                }
-               else if (self.move_suspendedinair && wasfreed(self.move_groundentity))
+               else if (this.move_suspendedinair && wasfreed(this.move_groundentity))
                {
-                       self.move_groundentity = world;
+                       this.move_groundentity = world;
                        return;
                }
        }
 
-       self.move_suspendedinair = false;
+       this.move_suspendedinair = false;
 
-       _Movetype_CheckVelocity();
+       _Movetype_CheckVelocity(this);
 
-       if (self.move_movetype == MOVETYPE_BOUNCE || self.move_movetype == MOVETYPE_TOSS)
+       if (this.move_movetype == MOVETYPE_BOUNCE || this.move_movetype == MOVETYPE_TOSS)
        {
-               self.move_didgravity = 1;
-               self.move_velocity_z -= (GRAVITY_UNAFFECTED_BY_TICRATE ? 0.5 : 1)
+               this.move_didgravity = 1;
+               this.move_velocity_z -= (GRAVITY_UNAFFECTED_BY_TICRATE ? 0.5 : 1)
                    * dt
-                   * (self.gravity ? self.gravity : 1)
+                   * (this.gravity ? this.gravity : 1)
                    * PHYS_GRAVITY;
        }
 
-       self.move_angles = self.move_angles + self.move_avelocity * dt;
+       this.move_angles = this.move_angles + this.move_avelocity * dt;
 
        float movetime = dt;
        for (int bump = 0; bump < MAX_CLIP_PLANES && movetime > 0; ++bump)
        {
-               vector move = self.move_velocity * movetime;
-               _Movetype_PushEntity(move, true);
-               if (wasfreed(self))
+               vector move = this.move_velocity * movetime;
+               _Movetype_PushEntity(this, move, true);
+               if (wasfreed(this))
                        return;
 
                if (trace_startsolid)
                {
-                       _Movetype_UnstickEntity();
-                       _Movetype_PushEntity(move, false);
-                       if (wasfreed(self))
+                       _Movetype_UnstickEntity(this);
+                       _Movetype_PushEntity(this, move, false);
+                       if (wasfreed(this))
                                return;
                }
 
@@ -55,61 +55,61 @@ void _Movetype_Physics_Toss(float dt)  // SV_Physics_Toss
 
                movetime *= 1 - min(1, trace_fraction);
 
-               if (self.move_movetype == MOVETYPE_BOUNCEMISSILE)
+               if (this.move_movetype == MOVETYPE_BOUNCEMISSILE)
                {
-                       self.move_velocity = _Movetype_ClipVelocity(self.move_velocity, trace_plane_normal, 2.0);
-                       self.move_flags &= ~FL_ONGROUND;
+                       this.move_velocity = _Movetype_ClipVelocity(this.move_velocity, trace_plane_normal, 2.0);
+                       this.move_flags &= ~FL_ONGROUND;
                }
-               else if (self.move_movetype == MOVETYPE_BOUNCE)
+               else if (this.move_movetype == MOVETYPE_BOUNCE)
                {
-                       float bouncefac = self.move_bounce_factor;     if (!bouncefac)  bouncefac = 0.5;
-                       float bouncestop = self.move_bounce_stopspeed; if (!bouncestop) bouncestop = 60 / 800;
-                       bouncestop *= (self.gravity ? self.gravity : 1) * PHYS_GRAVITY;
+                       float bouncefac = this.move_bounce_factor;     if (!bouncefac)  bouncefac = 0.5;
+                       float bouncestop = this.move_bounce_stopspeed; if (!bouncestop) bouncestop = 60 / 800;
+                       bouncestop *= (this.gravity ? this.gravity : 1) * PHYS_GRAVITY;
 
-                       self.move_velocity = _Movetype_ClipVelocity(self.move_velocity, trace_plane_normal, 1 + bouncefac);
+                       this.move_velocity = _Movetype_ClipVelocity(this.move_velocity, trace_plane_normal, 1 + bouncefac);
 
-                       float d = trace_plane_normal * self.move_velocity;
+                       float d = trace_plane_normal * this.move_velocity;
                        if (trace_plane_normal.z > 0.7 && d < bouncestop && d > -bouncestop)
                        {
-                               self.move_flags |= FL_ONGROUND;
-                               self.move_groundentity = trace_ent;
-                               self.move_velocity = '0 0 0';
-                               self.move_avelocity = '0 0 0';
+                               this.move_flags |= FL_ONGROUND;
+                               this.move_groundentity = trace_ent;
+                               this.move_velocity = '0 0 0';
+                               this.move_avelocity = '0 0 0';
                        }
                        else
                        {
-                               self.move_flags &= ~FL_ONGROUND;
+                               this.move_flags &= ~FL_ONGROUND;
                        }
                }
                else
                {
-                       self.move_velocity = _Movetype_ClipVelocity(self.move_velocity, trace_plane_normal, 1.0);
+                       this.move_velocity = _Movetype_ClipVelocity(this.move_velocity, trace_plane_normal, 1.0);
                        if (trace_plane_normal.z > 0.7)
                        {
-                               self.move_flags |= FL_ONGROUND;
-                               self.move_groundentity = trace_ent;
+                               this.move_flags |= FL_ONGROUND;
+                               this.move_groundentity = trace_ent;
                                if (trace_ent.solid == SOLID_BSP)
-                                       self.move_suspendedinair = true;
-                               self.move_velocity = '0 0 0';
-                               self.move_avelocity = '0 0 0';
+                                       this.move_suspendedinair = true;
+                               this.move_velocity = '0 0 0';
+                               this.move_avelocity = '0 0 0';
                        }
                        else
                        {
-                               self.move_flags &= ~FL_ONGROUND;
+                               this.move_flags &= ~FL_ONGROUND;
                        }
                }
 
                // DP revision 8905 (just, WHY...)
-               if (self.move_movetype == MOVETYPE_BOUNCEMISSILE)
+               if (this.move_movetype == MOVETYPE_BOUNCEMISSILE)
                        break;
 
                // DP revision 8918 (WHY...)
-               if (self.move_flags & FL_ONGROUND)
+               if (this.move_flags & FL_ONGROUND)
                        break;
        }
 
-       if (GRAVITY_UNAFFECTED_BY_TICRATE && self.move_didgravity > 0 && !(self.move_flags & FL_ONGROUND))
-               self.move_velocity_z -= 0.5 * dt * (self.gravity ? self.gravity : 1) * PHYS_GRAVITY;
+       if (GRAVITY_UNAFFECTED_BY_TICRATE && this.move_didgravity > 0 && !(this.move_flags & FL_ONGROUND))
+               this.move_velocity_z -= 0.5 * dt * (this.gravity ? this.gravity : 1) * PHYS_GRAVITY;
 
-       _Movetype_CheckWaterTransition(self);
+       _Movetype_CheckWaterTransition(this);
 }
index 63152e007f6f2ab36a81e912e4f08a26ea3df0ec..cf5cf49bbc99af1ce61c3f5c6a9738ff8f626733 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef MOVETYPE_TOSS_H
 #define MOVETYPE_TOSS_H
 
-void _Movetype_Physics_Toss(float dt);
+void _Movetype_Physics_Toss(entity this, float dt);
 
 #endif
index 0f18a47bfc6ee4bcc487f464ddd6eeb625e615ef..23d6e01a8f0ce7e2790222785c05bd377ee5ab84 100644 (file)
@@ -1,5 +1,5 @@
-void _Movetype_Physics_Walk(float dt)  // SV_WalkMove
-{SELFPARAM();
+void _Movetype_Physics_Walk(entity this, float dt)  // SV_WalkMove
+{
        vector stepnormal = '0 0 0';
 
        // if frametime is 0 (due to client sending the same timestamp twice), don't move
@@ -7,61 +7,61 @@ void _Movetype_Physics_Walk(float dt)  // SV_WalkMove
                return;
 
        if (GAMEPLAYFIX_UNSTICKPLAYERS)
-               _Movetype_UnstickEntity();
+               _Movetype_UnstickEntity(this);
 
-       bool applygravity = (!_Movetype_CheckWater(self) && self.move_movetype == MOVETYPE_WALK && !(self.move_flags & FL_WATERJUMP));
+       bool applygravity = (!_Movetype_CheckWater(this) && this.move_movetype == MOVETYPE_WALK && !(this.move_flags & FL_WATERJUMP));
 
-       _Movetype_CheckVelocity();
+       _Movetype_CheckVelocity(this);
 
        // do a regular slide move unless it looks like you ran into a step
-       bool oldonground = (self.move_flags & FL_ONGROUND);
+       bool oldonground = (this.move_flags & FL_ONGROUND);
 
-       vector start_origin = self.move_origin;
-       vector start_velocity = self.move_velocity;
+       vector start_origin = this.move_origin;
+       vector start_velocity = this.move_velocity;
 
-       int clip = _Movetype_FlyMove(dt, applygravity, stepnormal, GAMEPLAYFIX_STEPMULTIPLETIMES ? PHYS_STEPHEIGHT : 0);
+       int clip = _Movetype_FlyMove(this, dt, applygravity, stepnormal, GAMEPLAYFIX_STEPMULTIPLETIMES ? PHYS_STEPHEIGHT : 0);
 
        if (GAMEPLAYFIX_DOWNTRACEONGROUND && !(clip & 1))
        {
                // only try this if there was no floor in the way in the trace (no,
                // this check seems to be not REALLY necessary, because if clip & 1,
                // our trace will hit that thing too)
-               vector upmove = self.move_origin + '0 0 1';
-               vector downmove = self.move_origin - '0 0 1';
+               vector upmove = this.move_origin + '0 0 1';
+               vector downmove = this.move_origin - '0 0 1';
                int type;
-               if (self.move_movetype == MOVETYPE_FLYMISSILE)
+               if (this.move_movetype == MOVETYPE_FLYMISSILE)
                        type = MOVE_MISSILE;
-               else if (self.move_movetype == MOVETYPE_FLY_WORLDONLY)
+               else if (this.move_movetype == MOVETYPE_FLY_WORLDONLY)
                        type = MOVE_WORLDONLY;
-               else if (self.solid == SOLID_TRIGGER || self.solid == SOLID_NOT)
+               else if (this.solid == SOLID_TRIGGER || this.solid == SOLID_NOT)
                        type = MOVE_NOMONSTERS;
                else type = MOVE_NORMAL;
-               tracebox(upmove, self.mins, self.maxs, downmove, type, self);
+               tracebox(upmove, this.mins, this.maxs, downmove, type, this);
                if (trace_fraction < 1 && trace_plane_normal.z > 0.7)
                        clip |= 1;  // but we HAVE found a floor
        }
 
        // if the move did not hit the ground at any point, we're not on ground
        if (!(clip & 1))
-               self.move_flags &= ~FL_ONGROUND;
+               this.move_flags &= ~FL_ONGROUND;
 
-       _Movetype_CheckVelocity();
-       _Movetype_LinkEdict(true);
+       _Movetype_CheckVelocity(this);
+       _Movetype_LinkEdict(this, true);
 
        if (clip & 8)  // teleport
                return;
 
-       if (self.move_flags & FL_WATERJUMP)
+       if (this.move_flags & FL_WATERJUMP)
                return;
 
        if (PHYS_NOSTEP)
                return;
 
-       vector originalmove_origin = self.move_origin;
-       vector originalmove_velocity = self.move_velocity;
+       vector originalmove_origin = this.move_origin;
+       vector originalmove_velocity = this.move_velocity;
        // originalmove_clip = clip;
-       int originalmove_flags = self.move_flags;
-       entity originalmove_groundentity = self.move_groundentity;
+       int originalmove_flags = this.move_flags;
+       entity originalmove_groundentity = this.move_groundentity;
 
        // if move didn't block on a step, return
        if (clip & 2)
@@ -70,39 +70,39 @@ void _Movetype_Physics_Walk(float dt)  // SV_WalkMove
                if (fabs(start_velocity.x) < 0.03125 && fabs(start_velocity.y) < 0.03125)
                        return;
 
-               if (self.move_movetype != MOVETYPE_FLY)
+               if (this.move_movetype != MOVETYPE_FLY)
                {
                        // return if gibbed by a trigger
-                       if (self.move_movetype != MOVETYPE_WALK)
+                       if (this.move_movetype != MOVETYPE_WALK)
                                return;
 
                        // return if attempting to jump while airborn (unless sv_jumpstep)
                        if (!PHYS_JUMPSTEP)
-                               if (!oldonground && self.move_waterlevel == 0)
+                               if (!oldonground && this.move_waterlevel == 0)
                                        return;
                }
 
                // try moving up and forward to go up a step
                // back to start pos
-               self.move_origin = start_origin;
-               self.move_velocity = start_velocity;
+               this.move_origin = start_origin;
+               this.move_velocity = start_velocity;
 
                // move up
                vector upmove = '0 0 1' * PHYS_STEPHEIGHT;
-               vector prev_origin = self.move_origin;
-               _Movetype_PushEntity(upmove, true);
-               if(wasfreed(self))
+               vector prev_origin = this.move_origin;
+               _Movetype_PushEntity(this, upmove, true);
+               if(wasfreed(this))
                        return;
-               if(trace_startsolid && self.move_origin != prev_origin)
+               if(trace_startsolid && this.move_origin != prev_origin)
                {
                        // we got teleported when upstepping... must abort the move
                        return;
                }
 
                // move forward
-               self.move_velocity_z = 0;
-               clip = _Movetype_FlyMove(dt, applygravity, stepnormal, 0);
-               self.move_velocity_z += start_velocity.z;
+               this.move_velocity_z = 0;
+               clip = _Movetype_FlyMove(this, dt, applygravity, stepnormal, 0);
+               this.move_velocity_z += start_velocity.z;
                if (clip & 8)
                {
                        // we got teleported when upstepping... must abort the move
@@ -110,22 +110,22 @@ void _Movetype_Physics_Walk(float dt)  // SV_WalkMove
                        return;
                }
 
-               _Movetype_CheckVelocity();
-               _Movetype_LinkEdict(true);
+               _Movetype_CheckVelocity(this);
+               _Movetype_LinkEdict(this, true);
 
                // check for stuckness, possibly due to the limited precision of floats
                // in the clipping hulls
                if (clip
-                   && fabs(originalmove_origin.y - self.move_origin.y) < 0.03125
-                   && fabs(originalmove_origin.x - self.move_origin.x) < 0.03125)
+                   && fabs(originalmove_origin.y - this.move_origin.y) < 0.03125
+                   && fabs(originalmove_origin.x - this.move_origin.x) < 0.03125)
                {
                        // Con_Printf("wall\n");
                        // stepping up didn't make any progress, revert to original move
-                       self.move_origin = originalmove_origin;
-                       self.move_velocity = originalmove_velocity;
+                       this.move_origin = originalmove_origin;
+                       this.move_velocity = originalmove_velocity;
                        // clip = originalmove_clip;
-                       self.move_flags = originalmove_flags;
-                       self.move_groundentity = originalmove_groundentity;
+                       this.move_flags = originalmove_flags;
+                       this.move_groundentity = originalmove_groundentity;
                        // now try to unstick if needed
                        // clip = SV_TryUnstick (ent, oldvel);
                        return;
@@ -135,22 +135,22 @@ void _Movetype_Physics_Walk(float dt)  // SV_WalkMove
 
                // extra friction based on view angle
                if ((clip & 2) && PHYS_WALLFRICTION)
-                       _Movetype_WallFriction(stepnormal);
+                       _Movetype_WallFriction(this, stepnormal);
        }
        // don't do the down move if stepdown is disabled, moving upward, not in water, or the move started offground or ended onground
-       else if (!GAMEPLAYFIX_STEPDOWN || self.move_waterlevel >= 3 || start_velocity.z >= (1.0 / 32.0) || !oldonground || (self.move_flags & FL_ONGROUND))
+       else if (!GAMEPLAYFIX_STEPDOWN || this.move_waterlevel >= 3 || start_velocity.z >= (1.0 / 32.0) || !oldonground || (this.move_flags & FL_ONGROUND))
        {
                return;
        }
 
        // move down
        vector downmove = '0 0 1' * (-PHYS_STEPHEIGHT + start_velocity.z * dt);
-       vector prev_origin = self.move_origin;
-       _Movetype_PushEntity(downmove, true);
-       if(wasfreed(self))
+       vector prev_origin = this.move_origin;
+       _Movetype_PushEntity(this, downmove, true);
+       if(wasfreed(this))
                return;
 
-       if(trace_startsolid && self.move_origin != prev_origin)
+       if(trace_startsolid && this.move_origin != prev_origin)
        {
                // we got teleported when downstepping... must abort the move
                return;
@@ -167,12 +167,12 @@ void _Movetype_Physics_Walk(float dt)  // SV_WalkMove
                // if the push down didn't end up on good ground, use the move without
                // the step up.  This happens near wall / slope combinations, and can
                // cause the player to hop up higher on a slope too steep to climb
-               self.move_origin = originalmove_origin;
-               self.move_velocity = originalmove_velocity;
-               self.move_flags = originalmove_flags;
-               self.move_groundentity = originalmove_groundentity;
+               this.move_origin = originalmove_origin;
+               this.move_velocity = originalmove_velocity;
+               this.move_flags = originalmove_flags;
+               this.move_groundentity = originalmove_groundentity;
        }
 
-       _Movetype_CheckVelocity();
-       _Movetype_LinkEdict(true);
+       _Movetype_CheckVelocity(this);
+       _Movetype_LinkEdict(this, true);
 }
index 10493c96f4e93fe9d28521dc7fc26416f5b33342..a920c7a4f831fed875c282b41a362b04c7f2bb30 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef MOVETYPE_WALK_H
 #define MOVETYPE_WALK_H
 
-void _Movetype_Physics_Walk(float dt);
+void _Movetype_Physics_Walk(entity this, float dt);
 
 #endif
index c310170558aaec5ff5ac89d191b4184c8a3fc095..9eb16b040d7d3d64a0fcc1aadae974b7ae6f3d08 100644 (file)
@@ -353,7 +353,7 @@ void RaceCarPhysics(entity this)
        this.angles_x = -smoothangles_x;
        this.angles_z =  smoothangles_z;
 
-       PM_ClientMovement_Move();
+       PM_ClientMovement_Move(this);
 }
 
 #ifdef SVQC
index 928440d9c9128ee47678d5af56ba62e33320f339..aab87365408e9c139caf783d20b0b69fec6b6e7d 100644 (file)
@@ -292,9 +292,14 @@ void PM_ClientMovement_UpdateStatus(entity this, bool ground)
                pmove_waterjumptime = 0;
 }
 
-void PM_ClientMovement_Move()
-{SELFPARAM();
+void PM_ClientMovement_Move(entity this)
+{
 #ifdef CSQC
+
+       PM_ClientMovement_UpdateStatus(this, false);
+       if(autocvar_cl_movement == 3)
+               return;
+
        int bump;
        float t;
        float f;
@@ -313,13 +318,11 @@ void PM_ClientMovement_Move()
        vector trace2_plane_normal = '0 0 0';
        vector trace3_plane_normal = '0 0 0';
 
-
-       PM_ClientMovement_UpdateStatus(this, false);
-       primalvelocity = self.velocity;
-       for(bump = 0, t = PHYS_INPUT_TIMELENGTH; bump < 8 && (self.velocity * self.velocity) > 0; bump++)
+       primalvelocity = this.velocity;
+       for(bump = 0, t = PHYS_INPUT_TIMELENGTH; bump < 8 && (this.velocity * this.velocity) > 0; bump++)
        {
-               neworigin = self.origin + t * self.velocity;
-               tracebox(self.origin, self.mins, self.maxs, neworigin, MOVE_NORMAL, self);
+               neworigin = this.origin + t * this.velocity;
+               tracebox(this.origin, this.mins, this.maxs, neworigin, MOVE_NORMAL, this);
                trace1_endpos = trace_endpos;
                trace1_fraction = trace_fraction;
                trace1_plane_normal = trace_plane_normal;
@@ -327,11 +330,11 @@ void PM_ClientMovement_Move()
                {
                        // may be a step or wall, try stepping up
                        // first move forward at a higher level
-                       currentorigin2 = self.origin;
+                       currentorigin2 = this.origin;
                        currentorigin2_z += PHYS_STEPHEIGHT;
                        neworigin2 = neworigin;
                        neworigin2_z += PHYS_STEPHEIGHT;
-                       tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self);
+                       tracebox(currentorigin2, this.mins, this.maxs, neworigin2, MOVE_NORMAL, this);
                        trace2_endpos = trace_endpos;
                        trace2_fraction = trace_fraction;
                        trace2_plane_normal = trace_plane_normal;
@@ -340,8 +343,8 @@ void PM_ClientMovement_Move()
                                // then move down from there
                                currentorigin2 = trace2_endpos;
                                neworigin2 = trace2_endpos;
-                               neworigin2_z = self.origin_z;
-                               tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self);
+                               neworigin2_z = this.origin_z;
+                               tracebox(currentorigin2, this.mins, this.maxs, neworigin2, MOVE_NORMAL, this);
                                trace3_endpos = trace_endpos;
                                trace3_fraction = trace_fraction;
                                trace3_plane_normal = trace_plane_normal;
@@ -358,7 +361,7 @@ void PM_ClientMovement_Move()
 
                // check if it moved at all
                if(trace1_fraction >= 0.001)
-                       setorigin(self, trace1_endpos);
+                       setorigin(this, trace1_endpos);
 
                // check if it moved all the way
                if(trace1_fraction == 1)
@@ -369,15 +372,15 @@ void PM_ClientMovement_Move()
                // this got commented out in a change that supposedly makes the code match QW better
                // so if this is broken, maybe put it in an if(cls.protocol != PROTOCOL_QUAKEWORLD) block
                if(trace1_plane_normal_z > 0.7)
-                       SET_ONGROUND(self);
+                       SET_ONGROUND(this);
 
                t -= t * trace1_fraction;
 
-               f = (self.velocity * trace1_plane_normal);
-               self.velocity = self.velocity + -f * trace1_plane_normal;
+               f = (this.velocity * trace1_plane_normal);
+               this.velocity = this.velocity + -f * trace1_plane_normal;
        }
        if(pmove_waterjumptime > 0)
-               self.velocity = primalvelocity;
+               this.velocity = primalvelocity;
 #endif
 }
 
@@ -888,7 +891,7 @@ void PM_fly(float maxspd_mod)
        if (time >= self.teleport_time)
 #endif
                PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
-       PM_ClientMovement_Move();
+       PM_ClientMovement_Move(self);
 }
 
 void PM_swim(float maxspd_mod)
@@ -971,7 +974,7 @@ void PM_swim(float maxspd_mod)
        }
        // water acceleration
        PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0);
-       PM_ClientMovement_Move();
+       PM_ClientMovement_Move(self);
 }
 
 void PM_ladder(float maxspd_mod)
@@ -1024,7 +1027,7 @@ void PM_ladder(float maxspd_mod)
 #endif
                // water acceleration
                PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE*maxspd_mod, 1, 0, 0, 0);
-       PM_ClientMovement_Move();
+       PM_ClientMovement_Move(self);
 }
 
 void PM_jetpack(float maxspd_mod)
@@ -1132,14 +1135,20 @@ void PM_jetpack(float maxspd_mod)
 
 #ifdef CSQC
        float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
-       if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
-               self.velocity_z -= g * 0.5;
-       else
-               self.velocity_z -= g;
-       PM_ClientMovement_Move();
-       if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
+       if(autocvar_cl_movement != 3)
+       {
                if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
                        self.velocity_z -= g * 0.5;
+               else
+                       self.velocity_z -= g;
+       }
+       PM_ClientMovement_Move(self);
+       if(autocvar_cl_movement != 3)
+       {
+               if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
+                       if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
+                               self.velocity_z -= g * 0.5;
+       }
 #endif
 }
 
@@ -1215,14 +1224,22 @@ void PM_walk(entity this, float maxspd_mod)
                const float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed);
                this.velocity += accelspeed * wishdir;
        }
+#ifdef CSQC
        const float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(this) * PHYS_INPUT_TIMELENGTH;
-       if (!(GAMEPLAYFIX_NOGRAVITYONGROUND))
-               this.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
+       if(autocvar_cl_movement != 3)
+       {
+               if (!(GAMEPLAYFIX_NOGRAVITYONGROUND))
+                       this.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1);
+       }
        if (vdist(this.velocity, >, 0))
-               PM_ClientMovement_Move();
-       if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
-               if (!IS_ONGROUND(this) || !GAMEPLAYFIX_NOGRAVITYONGROUND)
-                       this.velocity_z -= g * 0.5;
+               PM_ClientMovement_Move(self);
+       if(autocvar_cl_movement != 3)
+       {
+               if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
+                       if (!IS_ONGROUND(this) || !GAMEPLAYFIX_NOGRAVITYONGROUND)
+                               this.velocity_z -= g * 0.5;
+       }
+#endif
 }
 
 void PM_air(float buttons_prev, float maxspd_mod)
@@ -1287,15 +1304,21 @@ void PM_air(float buttons_prev, float maxspd_mod)
                if (PHYS_AIRCONTROL)
                        CPM_PM_Aircontrol(wishdir, wishspeed2);
        }
+#ifdef CSQC
        float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH;
+       if(autocvar_cl_movement != 3)
        if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
                self.velocity_z -= g * 0.5;
        else
                self.velocity_z -= g;
-       PM_ClientMovement_Move();
+#endif
+       PM_ClientMovement_Move(self);
+#ifdef CSQC
+       if(autocvar_cl_movement != 3)
        if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND))
                if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE)
                        self.velocity_z -= g * 0.5;
+#endif
 }
 
 // used for calculating airshots
index c93ccc488119fee00056e1efe1b9422053766a05..87496b217649b97e07041cb78ab5350f1e9be4aa 100644 (file)
@@ -801,7 +801,7 @@ spawnfunc(func_door)
 
 void door_draw(entity this)
 {
-       Movetype_Physics_NoMatchServer();
+       Movetype_Physics_NoMatchServer(this);
 
        trigger_draw_generic(this);
 }
index a419e62106ab3b7cab2ee2fff3686275594fc323..9e98d12ba25416508e57e06d22c865080fc35594 100644 (file)
@@ -124,7 +124,7 @@ spawnfunc(func_plat)
 #elif defined(CSQC)
 void plat_draw(entity this)
 {
-       Movetype_Physics_NoMatchServer();
+       Movetype_Physics_NoMatchServer(this);
        //Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
 }
 
index 0f827a60e37e4bdef4c8c031a84c5b927f9c11f7..80350e743b94ba07c27abf54cb3eb7c0f0bd47fb 100644 (file)
@@ -244,7 +244,7 @@ spawnfunc(func_train)
 void train_draw(entity this)
 {
        //Movetype_Physics_NoMatchServer();
-       Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
+       Movetype_Physics_MatchServer(this, autocvar_cl_projectiles_sloppy);
 }
 
 NET_HANDLE(ENT_CLIENT_TRAIN, bool isnew)
index e3b9c2e6963c5934506f804dc739f6a37be2e956..fa68533f4afcb594a6d727389fc65e4d23c78482 100644 (file)
@@ -15,7 +15,7 @@
 
 #elif defined(CSQC)
 
-       void _Movetype_LinkEdict(float touch_triggers);
+       void _Movetype_LinkEdict(entity this, float touch_triggers);
 
        #define SUB_ANGLES(s)   (s).move_angles
        #define SUB_VELOCITY    move_velocity
@@ -31,7 +31,7 @@
        void SUB_SETORIGIN(entity s, vector v)
        {SELFPARAM();
                s.move_origin = v;
-               WITH(entity, self, s, _Movetype_LinkEdict(true));
+               _Movetype_LinkEdict(s, true);
        }
 
 #endif
index 07378804f612efce71148c0ff2ac6db67e3f05d7..e05f519f4fb24d6decf4f8964e4a03d1e5dc22b1 100644 (file)
@@ -248,7 +248,7 @@ entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, flo
 void turret_gibboom();
 void turret_gib_draw(entity this)
 {
-       Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
+       Movetype_Physics_MatchTicrate(self, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
 
        self.drawmask = MASK_NORMAL;
 
index 6783a92cc9a4aa1d128ded8cdb73572b3b30e337..b86880dd27df0d7a80f8b4b1f0c04726de86f0e1 100644 (file)
@@ -268,7 +268,7 @@ void RaptorCBShellfragDraw(entity this)
     if(wasfreed(self))
         return;
 
-    Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
+    Movetype_Physics_MatchTicrate(self, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
     self.move_avelocity += randomvec() * 15;
     self.renderflags = 0;
 
index 17f6b4ce921ca3d90baec9c2c02791298b6ab07c..e0eaccae11f957539f2d42f565b911482da16d89 100644 (file)
@@ -35,7 +35,6 @@
 #include "../../common/viewloc.qh"
 
 float autocvar_cl_movement_errorcompensation = 0;
-bool autocvar_cl_movement = true;
 
 // engine stuff
 float pmove_onground; // weird engine flag we shouldn't really use but have to for now
@@ -130,22 +129,36 @@ void CSQCPlayer_SavePrediction(entity this)
 }
 
 void CSQC_ClientMovement_PlayerMove_Frame(entity this);
+void _Movetype_Physics_Frame(entity this, float movedt);
 
-void PM_Movement_Move(entity this)
+void Movetype_Physics_Spam(entity this)  // optimized
 {
-       runstandardplayerphysics(this);
-#ifdef CSQC
-       this.flags =
-                       ((this.pmove_flags & PMF_DUCKED) ? FL_DUCKED : 0) |
-                       (!(this.pmove_flags & PMF_JUMP_HELD) ? FL_JUMPRELEASED : 0) |
-                       ((this.pmove_flags & PMF_ONGROUND) ? FL_ONGROUND : 0);
-#endif
+       _Movetype_Physics_Frame(this, PHYS_INPUT_TIMELENGTH);
+       if(wasfreed(this))
+               return;
+
+       this.avelocity = this.move_avelocity;
+       this.velocity = this.move_velocity;
+       this.angles = this.move_angles;
+       setorigin(this, this.move_origin);
 }
 
 void CSQCPlayer_Physics(entity this)
 {
        if(autocvar_cl_movement)
+       {
                CSQC_ClientMovement_PlayerMove_Frame(this);
+
+               if(autocvar_cl_movement == 3)
+               {
+                       this.move_origin = this.origin;
+                       this.move_angles = this.angles;
+                       this.move_movetype = MOVETYPE_WALK; // temp
+                       this.move_velocity = this.velocity;
+                       this.move_avelocity = this.avelocity;
+                       Movetype_Physics_Spam(this);
+               }
+       }
 }
 
 void CSQCPlayer_PredictTo(entity this, float endframe, bool apply_error)
index 5b12dfa12cf7b60bbb6da8039c9057c58fbcefc2..1c97199c8e29684225649a78f116a9abca857778 100644 (file)
@@ -22,6 +22,8 @@
 #ifndef LIB_CSQCMODEL_CL_PLAYER_H
 #define LIB_CSQCMODEL_CL_PLAYER_H
 
+int autocvar_cl_movement = 1;
+
 entity csqcplayer;
 float csqcplayer_status;
 const int CSQCPLAYERSTATUS_UNPREDICTED = 0;
index 95b219ea034b8d49e8009a0410868b1abfb15124..086ab0cc22e7101b8b52532e38ac8613e1040704 100644 (file)
@@ -1240,6 +1240,11 @@ METHOD(Flag, giveTo, bool(Flag this, entity flag, entity toucher))
                        }
                        else if(CTF_SAMETEAM(toucher, flag) && (toucher.flagcarried) && DIFF_TEAM(toucher.flagcarried, flag) && is_not_monster)
                                ctf_Handle_Capture(flag, toucher, CAPTURE_NORMAL); // toucher just captured the enemies flag to his base
+                       else if(CTF_DIFFTEAM(toucher, flag) && (toucher.flagcarried) && CTF_SAMETEAM(toucher.flagcarried, toucher) && (!toucher.ctf_captureshielded) && autocvar_g_ctf_flag_return_carrying && (time > toucher.next_take_time) && is_not_monster)
+                       {
+                               ctf_Handle_Return(toucher.flagcarried, toucher); // return their current flag
+                               ctf_Handle_Pickup(flag, toucher, PICKUP_BASE); // now pickup the flag
+                       }
                        else if(CTF_DIFFTEAM(toucher, flag) && (!toucher.flagcarried) && (!toucher.ctf_captureshielded) && (time > toucher.next_take_time) && is_not_monster)
                                ctf_Handle_Pickup(flag, toucher, PICKUP_BASE); // toucher just stole the enemies flag
                        break;
index 219e483c703af0651f9b53921c62e5ca9067226f..64bdfa552559474ece73722e02f5ee60610ed1e9 100644 (file)
@@ -33,7 +33,7 @@ void ItemDraw(entity self)
 {
     if(self.gravity)
     {
-        Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
+        Movetype_Physics_MatchServer(self, autocvar_cl_projectiles_sloppy);
         if(self.move_flags & FL_ONGROUND)
         { // For some reason move_avelocity gets set to '0 0 0' here ...
             self.oldorigin = self.origin;
@@ -69,7 +69,7 @@ void ItemDrawSimple(entity this)
 {
     if(self.gravity)
     {
-        Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
+        Movetype_Physics_MatchServer(self, autocvar_cl_projectiles_sloppy);
 
         if(self.move_flags & FL_ONGROUND)
             self.gravity = 0;