]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix an obscure bug causing QC physics-driven projectiles to sit on kill triggers...
authorMario <mario.mario@y7mail.com>
Tue, 22 Jun 2021 14:45:50 +0000 (14:45 +0000)
committerterencehill <piuntn@gmail.com>
Tue, 22 Jun 2021 14:45:50 +0000 (14:45 +0000)
.gitlab-ci.yml
qcsrc/common/physics/movetypes/movetypes.qc
qcsrc/common/physics/movetypes/movetypes.qh
qcsrc/server/client.qc
qcsrc/server/world.qc

index a9c91730779de7c3609daa8a166cf5971f2930b3..937914db0b8e48499007d7f50b989ad0c3ee18c4 100644 (file)
@@ -32,7 +32,7 @@ test_sv_game:
     - wget -O data/maps/stormkeep.waypoints https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/stormkeep.waypoints\r
     - wget -O data/maps/stormkeep.waypoints.cache https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/stormkeep.waypoints.cache\r
     - make\r
-    - EXPECT=695aaf75cbf57edbd43322b281fcb978\r
+    - EXPECT=f48f0950921140f6133c866bcc6e9d79\r
     - HASH=$(${ENGINE} -noconfig -nohome +timestamps 1 +exec serverbench.cfg\r
       | tee /dev/stderr\r
       | sed -e 's,^\[[^]]*\] ,,'\r
index e207551838e03cd6bbe0f363f1677d17a1a6738f..48216f39297d7fd8178b41f3982f02f2d0cc291d 100644 (file)
@@ -6,6 +6,8 @@ void set_movetype(entity this, int mt)
        this.move_movetype = mt;
        if (mt == MOVETYPE_PHYSICS) {
                this.move_qcphysics = false;
+       } else if (autocvar_sv_qcphysics == 2) {
+               this.move_qcphysics = true;
        }
        if(!IL_CONTAINS(g_moveables, this))
                IL_PUSH(g_moveables, this); // add it to the moveable entities list (even if it doesn't move!) logic: if an object never sets its movetype, we assume it never does anything notable
@@ -424,6 +426,21 @@ void _Movetype_LinkEdict_TouchAreaGrid(entity this)  // SV_LinkEdict_TouchAreaGr
        if(this.solid == SOLID_NOT)
                return;
 
+       // due to a lack of pointers in QC, we must save the trace values and restore them for other functions
+       bool save_trace_allsolid = trace_allsolid;
+       bool save_trace_startsolid = trace_startsolid;
+       float save_trace_fraction = trace_fraction;
+       bool save_trace_inwater = trace_inwater;
+       bool save_trace_inopen = trace_inopen;
+       vector save_trace_endpos = trace_endpos;
+       vector save_trace_plane_normal = trace_plane_normal;
+       float save_trace_plane_dist = trace_plane_dist;
+       entity save_trace_ent = trace_ent;
+       int save_trace_dpstartcontents = trace_dpstartcontents;
+       int save_trace_dphitcontents = trace_dphitcontents;
+       int save_trace_dphitq3surfaceflags = trace_dphitq3surfaceflags;
+       string save_trace_dphittexturename = trace_dphittexturename;
+
     FOREACH_ENTITY_RADIUS_ORDERED(0.5 * (this.absmin + this.absmax), 0.5 * vlen(this.absmax - this.absmin), true, {
                if (it.solid == SOLID_TRIGGER && it != this)
                if (it.move_nomonsters != MOVE_NOMONSTERS && it.move_nomonsters != MOVE_WORLDONLY)
@@ -446,6 +463,20 @@ void _Movetype_LinkEdict_TouchAreaGrid(entity this)  // SV_LinkEdict_TouchAreaGr
                        gettouch(it)(it, this);
                }
     });
+
+       trace_allsolid = save_trace_allsolid;
+       trace_startsolid = save_trace_startsolid;
+       trace_fraction = save_trace_fraction;
+       trace_inwater = save_trace_inwater;
+       trace_inopen = save_trace_inopen;
+       trace_endpos = save_trace_endpos;
+       trace_plane_normal = save_trace_plane_normal;
+       trace_plane_dist = save_trace_plane_dist;
+       trace_ent = save_trace_ent;
+       trace_dpstartcontents = save_trace_dpstartcontents;
+       trace_dphitcontents = save_trace_dphitcontents;
+       trace_dphitq3surfaceflags = save_trace_dphitq3surfaceflags;
+       trace_dphittexturename = save_trace_dphittexturename;
 }
 
 bool autocvar__movetype_debug = false;
index d3de0ba9cf3de35617c8604c8d9023fc92631926..79b0ea7badd26ad287a1f427d99f2d363029e870 100644 (file)
@@ -3,6 +3,8 @@
 #ifdef SVQC
 // undefined on client, engine cvar
 bool autocvar_physics_ode;
+
+int autocvar_sv_qcphysics = 1; // TODO this is for testing - remove when qcphysics work
 #endif
 
 // water levels
index e0f0e2b19ef665ae190020c295f6a24b1100e7ba..20ee5c2518589ced5b7d7ed1441f63e832b6b886 100644 (file)
@@ -1075,8 +1075,6 @@ string getwelcomemessage(entity this)
        return s;
 }
 
-bool autocvar_sv_qcphysics = true; // TODO this is for testing - remove when qcphysics work
-
 /**
 =============
 ClientConnect
index 7214c1550d13eab2396351747b83f951c76b3003..99e30265f49e9eb24217dfd6b150154afa7d65d8 100644 (file)
@@ -388,6 +388,7 @@ void cvar_changes_init()
                BADCVAR("sv_minigames");
                BADCVAR("sv_namechangetimer");
                BADCVAR("sv_precacheplayermodels");
+               BADCVAR("sv_qcphysics");
                BADCVAR("sv_radio");
                BADCVAR("sv_stepheight");
                BADCVAR("sv_timeout");
@@ -2211,11 +2212,11 @@ void droptofloor(entity this)
 }
 
 bool autocvar_sv_gameplayfix_multiplethinksperframe = true;
-void RunThink(entity this)
+void RunThink(entity this, float dt)
 {
        // don't let things stay in the past.
        // it is possible to start that way by a trigger with a local time.
-       if(this.nextthink <= 0 || this.nextthink > time + frametime)
+       if(this.nextthink <= 0 || this.nextthink > time + dt)
                return;
 
        float oldtime = time; // do we need to save this?
@@ -2231,7 +2232,7 @@ void RunThink(entity this)
                // we don't want to loop in that case, so exit if the new nextthink is
                // <= the time the qc was told, also exit if it is past the end of the
                // frame
-               if(this.nextthink <= time || this.nextthink > oldtime + frametime || !autocvar_sv_gameplayfix_multiplethinksperframe)
+               if(this.nextthink <= time || this.nextthink > oldtime + dt || !autocvar_sv_gameplayfix_multiplethinksperframe)
                        break;
        }
 
@@ -2261,8 +2262,8 @@ void Physics_Frame()
                        if(it.move_movetype == MOVETYPE_PUSH || it.move_movetype == MOVETYPE_FAKEPUSH)
                                continue; // these movetypes have no regular think function
                        // handle thinking here
-                       if (getthink(it) && it.nextthink > 0 && it.nextthink <= time + frametime)
-                               RunThink(it);
+                       if (getthink(it) && it.nextthink > 0 && it.nextthink <= time + PHYS_INPUT_TIMELENGTH)
+                               RunThink(it, PHYS_INPUT_TIMELENGTH);
                }
        });