From 81c807a647d49a50684ab4cc898f27f0ef27fb21 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 28 Jun 2022 11:59:38 +1000 Subject: [PATCH 1/1] Port the droptofloor function to QC, removes the final use of a macro to store the self global --- qcsrc/lib/self.qh | 2 +- qcsrc/server/world.qc | 50 ++++++++++++++++++++++++++++++++++++++++++- qcsrc/server/world.qh | 1 + 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/qcsrc/lib/self.qh b/qcsrc/lib/self.qh index d5ddf202d..b057faee5 100644 --- a/qcsrc/lib/self.qh +++ b/qcsrc/lib/self.qh @@ -43,7 +43,7 @@ #endif // Step 7: remove WITHSELF, no replacement -#if 0 +#if 1 #undef WITHSELF #define WITHSELF(value, block) block #endif diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index 41c9705da..43e697f2d 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -2195,7 +2195,55 @@ void InitializeEntitiesRun() // deferred dropping void DropToFloor_Handler(entity this) { - WITHSELF(this, builtin_droptofloor()); + if(!this || wasfreed(this)) + { + // no modifying free entities + return; + } + + vector end = this.origin - '0 0 256'; + + // NOTE: NudgeOutOfSolid support is not added as Xonotic's physics do not use it! + //if(autocvar_sv_gameplayfix_droptofloorstartsolid_nudgetocorrect) + //SV_NudgeOutOfSolid(this); + + tracebox(this.origin, this.mins, this.maxs, end, MOVE_NORMAL, this); + + if(trace_startsolid && autocvar_sv_gameplayfix_droptofloorstartsolid) + { + vector offset, org; + offset = 0.5 * (this.mins + this.maxs); + org = this.origin + offset; + traceline(org, end, MOVE_NORMAL, this); + trace_endpos = trace_endpos - offset; + if(trace_startsolid) + { + LOG_DEBUGF("DropToFloor_Handler: %v could not fix badly placed entity", this.origin); + _Movetype_LinkEdict(this, false); + this.groundentity = NULL; + } + else if(trace_fraction < 1) + { + LOG_DEBUGF("DropToFloor_Handler: %v fixed badly placed entity", this.origin); + //if(autocvar_sv_gameplayfix_droptofloorstartsolid_nudgetocorrect) + //SV_NudgeOutOfSolid(this); + setorigin(this, trace_endpos); + this.groundentity = trace_ent; + // if support is destroyed, keep suspended (gross hack for floating items in various maps) + this.move_suspendedinair = true; + } + } + else + { + if(!trace_allsolid && trace_fraction < 1) + { + setorigin(this, trace_endpos); + this.groundentity = trace_ent; + // if support is destroyed, keep suspended (gross hack for floating items in various maps) + this.move_suspendedinair = true; + } + } + SET_ONGROUND(this); this.dropped_origin = this.origin; } diff --git a/qcsrc/server/world.qh b/qcsrc/server/world.qh index e74ab2dc7..91ad5438b 100644 --- a/qcsrc/server/world.qh +++ b/qcsrc/server/world.qh @@ -27,6 +27,7 @@ float autocvar_timelimit_max; float autocvar_timelimit_overtime; int autocvar_timelimit_overtimes; float autocvar_timelimit_suddendeath; +bool autocvar_sv_gameplayfix_droptofloorstartsolid; float checkrules_equality; float checkrules_suddendeathwarning; -- 2.39.2