]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'Mario/qc_droptofloor' into 'master'
authorMario <mario.mario@y7mail.com>
Tue, 11 Oct 2022 11:04:09 +0000 (11:04 +0000)
committerMario <mario.mario@y7mail.com>
Tue, 11 Oct 2022 11:04:09 +0000 (11:04 +0000)
Merge branch Mario/qc_droptofloor (XS merge request)

See merge request xonotic/xonotic-data.pk3dir!1042

qcsrc/lib/self.qh
qcsrc/server/world.qc
qcsrc/server/world.qh

index d5ddf202d43b93573ef4d6af6ac927ca6bb9a43a..b057faee58bdc606a8a743c331febece5582f397 100644 (file)
@@ -43,7 +43,7 @@
 #endif
 
 // Step 7: remove WITHSELF, no replacement
-#if 0
+#if 1
     #undef WITHSELF
     #define WITHSELF(value, block) block
 #endif
index 7f651fa7748291ff5e7090192793cf39c206afa9..38431a71733a53225bb21d420665469f270a09d4 100644 (file)
@@ -2228,9 +2228,61 @@ void InitializeEntitiesRun()
 }
 
 // deferred dropping
+// ported from VM_SV_droptofloor TODO: make a common function for the client-side?
 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);
+               offset.z = this.mins.z;
+               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);
+                       SET_ONGROUND(this);
+                       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);
+                       SET_ONGROUND(this);
+                       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);
+                       SET_ONGROUND(this);
+                       this.groundentity = trace_ent;
+                       // if support is destroyed, keep suspended (gross hack for floating items in various maps)
+                       this.move_suspendedinair = true;
+               }
+       }
        this.dropped_origin = this.origin;
 }
 
index d82469c11ef1ca7573752897113a614c673e01f3..affa49e5669155e000e3a671d49b5750a3fd995c 100644 (file)
@@ -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;