From 0602b6ad4b4953a89e773617beb277b054d4d401 Mon Sep 17 00:00:00 2001 From: serge_shubin Date: Sat, 21 Mar 2026 04:31:49 +0800 Subject: [PATCH] Extract PM_Jump from PM_CheckJump (QL-style refactor) Separate the jump execution (velocity, event, animation) from the gate logic (respawn check, upmove threshold, jump-held check). This prepares the code for QL features that need to trigger jumps from contexts other than the normal ground jump path (step jump, double jump, etc). No behavior change. Co-Authored-By: Claude Opus 4.6 (1M context) --- code/game/bg_pmove.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/code/game/bg_pmove.c b/code/game/bg_pmove.c index 3711869..93e11f5 100644 --- a/code/game/bg_pmove.c +++ b/code/game/bg_pmove.c @@ -351,6 +351,33 @@ static void PM_SetMovementDir( void ) { } +/* +============= +PM_Jump + +Applies jump velocity, event, and animation. +Extracted from PM_CheckJump so it can be called +from other contexts (step jump, double jump, etc). +============= +*/ +static void PM_Jump( void ) { + pml.groundPlane = qfalse; // jumping away + pml.walking = qfalse; + pm->ps->pm_flags |= PMF_JUMP_HELD; + + pm->ps->groundEntityNum = ENTITYNUM_NONE; + pm->ps->velocity[2] = JUMP_VELOCITY; + PM_AddEvent( EV_JUMP ); + + if ( pm->cmd.forwardmove >= 0 ) { + PM_ForceLegsAnim( LEGS_JUMP ); + pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; + } else { + PM_ForceLegsAnim( LEGS_JUMPB ); + pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; + } +} + /* ============= PM_CheckJump @@ -373,21 +400,7 @@ static qboolean PM_CheckJump( void ) { return qfalse; } - pml.groundPlane = qfalse; // jumping away - pml.walking = qfalse; - pm->ps->pm_flags |= PMF_JUMP_HELD; - - pm->ps->groundEntityNum = ENTITYNUM_NONE; - pm->ps->velocity[2] = JUMP_VELOCITY; - PM_AddEvent( EV_JUMP ); - - if ( pm->cmd.forwardmove >= 0 ) { - PM_ForceLegsAnim( LEGS_JUMP ); - pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; - } else { - PM_ForceLegsAnim( LEGS_JUMPB ); - pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; - } + PM_Jump(); return qtrue; }