]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Some minor adjustments to the push movetype, fix QC physics entities not running...
authorMario <mario.mario@y7mail.com>
Mon, 1 Jun 2020 19:23:34 +0000 (05:23 +1000)
committerMario <mario.mario@y7mail.com>
Mon, 1 Jun 2020 19:23:34 +0000 (05:23 +1000)
qcsrc/common/physics/movetypes/movetypes.qc
qcsrc/common/physics/movetypes/push.qc
qcsrc/common/physics/movetypes/push.qh
qcsrc/server/g_world.qc

index 99ff92150b5683efd2753ad42474cfb5015d734b..7e7945e1c920d0f0bc19b487c96f94805bec5891 100644 (file)
@@ -25,7 +25,7 @@ bool _Movetype_NudgeOutOfSolid_PivotIsKnownGood(entity this, vector pivot) // SV
        for(int bump = 0; bump < 6; bump++)
        {
                int coord = 2 - (bump >> 1);
-               int dir = (bump & 1);
+               bool dir = (bump & 1);
 
                for(int subbump = 0; ; ++subbump)
                {
@@ -52,7 +52,7 @@ bool _Movetype_NudgeOutOfSolid_PivotIsKnownGood(entity this, vector pivot) // SV
                        }
 
                        tracebox(stuckorigin, goodmins, goodmaxs, testorigin, MOVE_NOMONSTERS, this);
-                       if(trace_startsolid) // NOTE: this checks for bmodelstartsolid in the engine
+                       if(trace_startsolid && trace_ent.solid == SOLID_BSP) // NOTE: this checks for bmodelstartsolid in the engine
                        {
                                
                                // BAD BAD, can't fix that
index 1ff815174c408b21734bdc68f624cb26679a3864..3df79a0380e2dcfbba1c0d62bfba935831332642 100644 (file)
@@ -71,9 +71,9 @@ void _Movetype_PushMove(entity this, float dt) // SV_PushMove
 
        IL_CLEAR(g_pushmove_moved); // make sure it's not somehow uncleared
 
-       FOREACH_ENTITY_RADIUS(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin), true,
+       for(entity check = findradius((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1); check; check = check.chain)
        {
-               switch(it.move_movetype)
+               switch(check.move_movetype)
                {
                        case MOVETYPE_NONE:
                        case MOVETYPE_PUSH:
@@ -85,24 +85,24 @@ void _Movetype_PushMove(entity this, float dt) // SV_PushMove
                                break;
                }
 
-               if(it.owner == this || this.owner == it)
+               if(check.owner == this || this.owner == check)
                        continue;
 
                // if the entity is standing on the pusher, it will definitely be moved
                // if the entity is not standing on the pusher, but is in the pusher's
                // final position, move it
-               if (!IS_ONGROUND(it) || it.groundentity != this)
+               if (!IS_ONGROUND(check) || check.groundentity != this)
                {
-                       tracebox(it.origin, it.mins, it.maxs, it.origin, MOVE_NORMAL, it);
+                       tracebox(check.origin, check.mins, check.maxs, check.origin, MOVE_NORMAL, check);
                        if(!trace_startsolid)
                                continue;
                }
-               vector pivot = it.mins + 0.5 * it.maxs;
+               vector pivot = check.mins + 0.5 * check.maxs;
                vector move;
 
                if(rotated)
                {
-                       vector org = it.origin - this.origin;
+                       vector org = check.origin - this.origin;
                        org = org + pivot;
 
                        vector org2;
@@ -115,47 +115,47 @@ void _Movetype_PushMove(entity this, float dt) // SV_PushMove
                else
                        move = move1;
 
-               it.moved_from = it.origin;
-               it.moved_fromangles = it.angles;
-               IL_PUSH(g_pushmove_moved, it);
+               check.moved_from = check.origin;
+               check.moved_fromangles = check.angles;
+               IL_PUSH(g_pushmove_moved, check);
 
                // physics objects need better collisions than this code can do
-               if(it.move_movetype == MOVETYPE_PHYSICS)
+               if(check.move_movetype == MOVETYPE_PHYSICS)
                {
-                       it.origin = it.origin + move;
-                       _Movetype_LinkEdict(it, true);
+                       check.origin = check.origin + move;
+                       _Movetype_LinkEdict(check, true);
                        continue;
                }
 
                // try moving the contacted entity
                int savesolid = this.solid;
                this.solid = SOLID_NOT;
-               if(!_Movetype_PushEntity(it, move, true, false))
+               if(!_Movetype_PushEntity(check, move, true, true))
                {
                        // entity "check" got teleported
-                       it.angles_y += trace_fraction * moveangle.y;
+                       check.angles_y += trace_fraction * moveangle.y;
                        this.solid = savesolid;
                        continue; // pushed enough
                }
                // FIXME: turn players specially
-               it.angles_y += trace_fraction * moveangle.y;
+               check.angles_y += trace_fraction * moveangle.y;
                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(it.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || it.groundentity != this))
-                       UNSET_ONGROUND(it);
+               if(check.move_movetype != MOVETYPE_WALK && (trace_fraction < 1 || check.groundentity != this))
+                       UNSET_ONGROUND(check);
 
                // if it is still inside the pusher, block
-               tracebox(it.origin, it.mins, it.maxs, it.origin, MOVE_NORMAL, it);
+               tracebox(check.origin, check.mins, check.maxs, check.origin, MOVE_HITMODEL, check);
                if(trace_startsolid)
                {
-                       if(_Movetype_NudgeOutOfSolid_PivotIsKnownGood(it, pivot))
+                       if(_Movetype_NudgeOutOfSolid_PivotIsKnownGood(check, pivot))
                        {
                                // hack to invoke all necessary movement triggers
                                vector move2 = '0 0 0';
-                               if(!_Movetype_PushEntity(it, move2, true, false))
+                               if(!_Movetype_PushEntity(check, move2, true, true))
                                {
                                        // entity "check" got teleported
                                        continue;
@@ -167,13 +167,13 @@ void _Movetype_PushMove(entity this, float dt) // SV_PushMove
                        // still inside pusher, so it's really blocked
 
                        // fail the move
-                       if(it.mins_x == it.maxs_x)
+                       if(check.mins_x == check.maxs_x)
                                continue;
-                       if(it.solid == SOLID_NOT || it.solid == SOLID_TRIGGER)
+                       if(check.solid == SOLID_NOT || check.solid == SOLID_TRIGGER)
                        {
                                // corpse
-                               it.mins_x = it.mins_y = 0;
-                               it.maxs = it.mins;
+                               check.mins_x = check.mins_y = 0;
+                               check.maxs = check.mins;
                                continue;
                        }
 
@@ -185,17 +185,17 @@ void _Movetype_PushMove(entity this, float dt) // SV_PushMove
                        // move back any entities we already moved
                        IL_EACH(g_pushmove_moved, true,
                        {
-                               it.origin = it.moved_from;
-                               it.angles = it.moved_fromangles;
-                               _Movetype_LinkEdict(it, false);
+                               check.origin = check.moved_from;
+                               check.angles = check.moved_fromangles;
+                               _Movetype_LinkEdict(check, false);
                        });
 
                        // if the pusher has a "blocked" function, call it, otherwise just stay in place until the obstacle is gone
                        if(getblocked(this))
-                               getblocked(this)(this, it);
+                               getblocked(this)(this, check);
                        break;
                }
-       });
+       }
        this.angles_x -= 360.0 * floor(this.angles_x * (1.0 / 360.0));
        this.angles_y -= 360.0 * floor(this.angles_y * (1.0 / 360.0));
        this.angles_z -= 360.0 * floor(this.angles_z * (1.0 / 360.0));
index f33e76191cf0104db2cc20ca2a18b095914c8a59..442386085a2ad3fbbcd8a4861259be644cb86f27 100644 (file)
@@ -9,4 +9,6 @@ STATIC_INIT(g_pushmove_moved) { g_pushmove_moved = IL_NEW(); }
 
 #ifdef CSQC
 .float ltime;
+
+const int MOVE_HITMODEL = 4;
 #endif
index 1d9205f023d2559860a44fd551741654ba56d96a..56dc473a9466429cb9d998c689721825ef567e05 100644 (file)
@@ -2071,10 +2071,7 @@ void Physics_Frame()
                // inline the set_movetype function, since this is called a lot
                it.movetype = (it.move_qcphysics) ? MOVETYPE_QCENTITY : it.move_movetype;
 
-               if(it.move_movetype == MOVETYPE_NONE)
-                       continue;
-
-               if(it.move_qcphysics)
+               if(it.move_qcphysics && it.move_movetype != MOVETYPE_NONE)
                        Movetype_Physics_NoMatchTicrate(it, PHYS_INPUT_TIMELENGTH, false);
 
                if(it.movetype >= MOVETYPE_USER_FIRST && it.movetype <= MOVETYPE_USER_LAST) // these cases have no think handling