]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Scale player hitbox size on death to fix potential crashes
authorMario <mario.mario@y7mail.com>
Wed, 31 Jul 2024 05:01:49 +0000 (05:01 +0000)
committerDr. Jaska <drjaska83@gmail.com>
Wed, 31 Jul 2024 05:01:49 +0000 (05:01 +0000)
qcsrc/common/constants.qh
qcsrc/lib/csqcmodel/cl_player.qc
qcsrc/server/client.qc

index 708f4c845c51630d2565132c67fd764e00e7acdb..132504a9ff22ce5eb1c4536cab35960fad802e56 100644 (file)
@@ -57,6 +57,8 @@ const vector PL_MIN_CONST = '-16 -16 -24';
 const vector PL_CROUCH_MAX_CONST = '16 16 25';
 const vector PL_CROUCH_MIN_CONST = '-16 -16 -24';
 
+const float PL_CORPSE_SCALE = 0.235; // average hitbox height is scaled by this when the player dies
+
 // gametype vote flags
 const int GTV_FORBIDDEN = 0; // Cannot be voted
 const int GTV_AVAILABLE = 1; // Can be voted
index a92fcc5c5b600294e8825dc037063f3eb949dace..13c7c556ef9b523fba0211925f9d19392964f0ef 100644 (file)
@@ -108,8 +108,11 @@ void CSQCPlayer_SetMinsMaxs(entity this)
        {
                this.mins = PHYS_PL_MIN(this);
                this.maxs = PHYS_PL_MAX(this);
-               if (IS_DEAD(this))
-                       this.maxs.z = 5;
+               if(IS_DEAD(this))
+               {
+                       float h = ceil((this.mins.z + this.maxs.z) * PL_CORPSE_SCALE * 10) / 10;
+                       this.maxs.z = max(h, this.mins.z + 1);
+               }
                this.view_ofs = PHYS_PL_VIEWOFS(this);
        }
 }
index bc5c576003b76562e54b58224e9510d0c3ca1391..575d6d971816ec8bfee5b7e0e2e779af92895db0 100644 (file)
@@ -2659,7 +2659,8 @@ void PlayerPostThink (entity this)
                {
                        // player's bbox gets resized now, instead of in the damage event that killed the player,
                        // once all the damage events of this frame have been processed with normal size
-                       this.maxs.z = 5;
+                       float h = ceil((this.mins.z + this.maxs.z) * PL_CORPSE_SCALE * 10) / 10;
+                       this.maxs.z = max(h, this.mins.z + 1);
                        setsize(this, this.mins, this.maxs);
                }
                DrownPlayer(this);