Merge branch 'master' into TimePath/global_self
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / movetypes / movetypes.qc
index ac2f9034ea7c7e47e5d782b8d0b183d5d49dd010..cfa6346dc44178904f2003208d28e4a63198bb1e 100644 (file)
@@ -33,7 +33,7 @@ void _Movetype_WallFriction(vector stepnormal)  // SV_WallFriction
 
 vector planes[MAX_CLIP_PLANES];
 int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float stepheight) // SV_FlyMove
-{
+{SELFPARAM();
        int blocked = 0, bumpcount;
        int i, j, numplanes = 0;
        float time_left = dt, grav = 0;
@@ -317,8 +317,7 @@ void _Movetype_CheckWaterTransition(entity ent)  // SV_CheckWaterTransition
 }
 
 void _Movetype_Impact(entity oth)  // SV_Impact
-{
-       entity oldself = self;
+{SELFPARAM();
        entity oldother = other;
 
        if(self.move_touch)
@@ -333,26 +332,23 @@ void _Movetype_Impact(entity oth)  // SV_Impact
        if(oth.move_touch)
        {
                other = self;
-               self = oth;
 
-               self.move_touch();
+               WITH(entity, self, oth, oth.move_touch());
 
-               self = oldself;
                other = oldother;
        }
 }
 
 void _Movetype_LinkEdict_TouchAreaGrid()  // SV_LinkEdict_TouchAreaGrid
-{
-       entity oldself = self;
+{SELFPARAM();
        entity oldother = other;
 
        for (entity e = findradius(0.5 * (self.absmin + self.absmax), 0.5 * vlen(self.absmax - self.absmin)); e; e = e.chain)
        {
-               if(e.move_touch && boxesoverlap(e.absmin, e.absmax, oldself.absmin, oldself.absmax))
+               if(e.move_touch && boxesoverlap(e.absmin, e.absmax, this.absmin, this.absmax))
                {
-                       self = e;
-                       other = oldself;
+                       setself(e);
+                       other = this;
 
                        trace_allsolid = false;
                        trace_startsolid = false;
@@ -362,18 +358,18 @@ void _Movetype_LinkEdict_TouchAreaGrid()  // SV_LinkEdict_TouchAreaGrid
                        trace_endpos = e.origin;
                        trace_plane_normal = '0 0 1';
                        trace_plane_dist = 0;
-                       trace_ent = oldself;
+                       trace_ent = this;
 
                        e.move_touch();
                }
        }
 
        other = oldother;
-       self = oldself;
+       setself(this);
 }
 
 void _Movetype_LinkEdict(bool touch_triggers)  // SV_LinkEdict
-{
+{SELFPARAM();
        vector mi, ma;
        if(self.solid == SOLID_BSP)
        {
@@ -416,7 +412,7 @@ void _Movetype_LinkEdict(bool touch_triggers)  // SV_LinkEdict
 }
 
 bool _Movetype_TestEntityPosition(vector ofs)  // SV_TestEntityPosition
-{
+{SELFPARAM();
 //     vector org = self.move_origin + ofs;
 
        int cont = self.dphitcontentsmask;
@@ -433,7 +429,7 @@ bool _Movetype_TestEntityPosition(vector ofs)  // SV_TestEntityPosition
 }
 
 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;
@@ -470,7 +466,7 @@ vector _Movetype_ClipVelocity(vector vel, vector norm, float f)  // SV_ClipVeloc
 }
 
 void _Movetype_PushEntityTrace(vector push)
-{
+{SELFPARAM();
        vector end = self.move_origin + push;
        int type;
        if(self.move_nomonsters)
@@ -486,7 +482,7 @@ void _Movetype_PushEntityTrace(vector push)
 }
 
 float _Movetype_PushEntity(vector push, bool failonstartsolid)  // SV_PushEntity
-{
+{SELFPARAM();
        _Movetype_PushEntityTrace(push);
 
        if(trace_startsolid && failonstartsolid)
@@ -560,7 +556,7 @@ void makevectors_matrix(vector myangles)  // AngleVectorsFLU
 }
 
 void _Movetype_Physics_Frame(float movedt)
-{
+{SELFPARAM();
        self.move_didgravity = -1;
        switch (self.move_movetype)
        {
@@ -596,7 +592,7 @@ void _Movetype_Physics_Frame(float movedt)
 }
 
 void Movetype_Physics_NoMatchServer()  // optimized
-{
+{SELFPARAM();
        float movedt = time - self.move_time;
        self.move_time = time;
 
@@ -616,7 +612,7 @@ void Movetype_Physics_MatchServer(bool sloppy)
 }
 
 void Movetype_Physics_MatchTicrate(float tr, bool sloppy)  // SV_Physics_Entity
-{
+{SELFPARAM();
        if(tr <= 0)
        {
                Movetype_Physics_NoMatchServer();