]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Port the droptofloor function to QC, removes the final use of a macro to store the...
authorMario <mario.mario@y7mail.com>
Tue, 28 Jun 2022 01:59:38 +0000 (11:59 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 28 Jun 2022 01:59:38 +0000 (11:59 +1000)
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 41c9705da06f510026176c49d70f787505ad95fa..43e697f2d664da69f4ed87b18404c350db90fcaf 100644 (file)
@@ -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;
 }
 
index e74ab2dc7589733b4ca9e4034ab587c49daa78d1..91ad5438b282b3a96e71feaf1bbe7028a0e25a0f 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;