From: Mario Date: Wed, 31 Jul 2024 05:01:49 +0000 (+0000) Subject: Scale player hitbox size on death to fix potential crashes X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0e28124a8e0dc228194c24324f868aa79b36548d;p=xonotic%2Fxonotic-data.pk3dir.git Scale player hitbox size on death to fix potential crashes --- diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 708f4c845..132504a9f 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -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 diff --git a/qcsrc/lib/csqcmodel/cl_player.qc b/qcsrc/lib/csqcmodel/cl_player.qc index a92fcc5c5..13c7c556e 100644 --- a/qcsrc/lib/csqcmodel/cl_player.qc +++ b/qcsrc/lib/csqcmodel/cl_player.qc @@ -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); } } diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index bc5c57600..575d6d971 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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);