From 7dd0a2cb9aaec4150f9412e3f71c0850d356cc80 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 22 Jun 2021 14:45:50 +0000 Subject: [PATCH] Fix an obscure bug causing QC physics-driven projectiles to sit on kill triggers, add an option to force QC physics on for all entities --- .gitlab-ci.yml | 2 +- qcsrc/common/physics/movetypes/movetypes.qc | 31 +++++++++++++++++++++ qcsrc/common/physics/movetypes/movetypes.qh | 2 ++ qcsrc/server/client.qc | 2 -- qcsrc/server/world.qc | 11 ++++---- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a9c917307..937914db0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 - wget -O data/maps/stormkeep.waypoints.cache https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/stormkeep.waypoints.cache - make - - EXPECT=695aaf75cbf57edbd43322b281fcb978 + - EXPECT=f48f0950921140f6133c866bcc6e9d79 - HASH=$(${ENGINE} -noconfig -nohome +timestamps 1 +exec serverbench.cfg | tee /dev/stderr | sed -e 's,^\[[^]]*\] ,,' diff --git a/qcsrc/common/physics/movetypes/movetypes.qc b/qcsrc/common/physics/movetypes/movetypes.qc index e20755183..48216f392 100644 --- a/qcsrc/common/physics/movetypes/movetypes.qc +++ b/qcsrc/common/physics/movetypes/movetypes.qc @@ -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; diff --git a/qcsrc/common/physics/movetypes/movetypes.qh b/qcsrc/common/physics/movetypes/movetypes.qh index d3de0ba9c..79b0ea7ba 100644 --- a/qcsrc/common/physics/movetypes/movetypes.qh +++ b/qcsrc/common/physics/movetypes/movetypes.qh @@ -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 diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index e0f0e2b19..20ee5c251 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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 diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index 7214c1550..99e30265f 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -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); } }); -- 2.39.2