Skip to content

Commit

Permalink
Fix players not being able to jump when stopped from falling by two s…
Browse files Browse the repository at this point in the history
…teep planes.
  • Loading branch information
lamefun committed Nov 19, 2017
1 parent dc4c370 commit f25efb1
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/game/bg_pmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ static void PM_GetDesiredDirAndSpeed( vec3_t dir, float *speed, vec3_t normal )
PM_CheckJump
=============
*/
static qboolean PM_CheckJump( void )
static qboolean PM_CheckJump( vec3_t customNormal )
{
// Ground normal under the player.
vec3_t normal;
Expand All @@ -1361,9 +1361,6 @@ static qboolean PM_CheckJump( void )
// Loop index.
int i;

if( pm->ps->groundEntityNum == ENTITYNUM_NONE )
return qfalse;

if( BG_Class( pm->ps->stats[ STAT_CLASS ] )->jumpMagnitude == 0.0f )
return qfalse;

Expand Down Expand Up @@ -1418,8 +1415,11 @@ static qboolean PM_CheckJump( void )

pm->ps->groundEntityNum = ENTITYNUM_NONE;

// jump away from wall
BG_GetClientNormal( pm->ps, normal );
// If not using a custom normal, jump away from the ground or the wall.
if( !customNormal )
BG_GetClientNormal( pm->ps, normal );
else
VectorCopy( customNormal, normal );

if( pm->ps->velocity[ 2 ] < 0 )
pm->ps->velocity[ 2 ] = 0;
Expand Down Expand Up @@ -1943,10 +1943,22 @@ static void PM_AirMove( void )
if( pml.groundPlane )
{
float *groundNormal = pml.groundTrace.plane.normal;
float previousZ = pm->ps->origin[ 2 ];

PM_ClipVelocity( pm->ps->velocity, groundNormal, pm->ps->velocity );
}
PM_StepSlideMove( qtrue, qfalse );

PM_StepSlideMove( qtrue, qfalse );
// Check if we haven't moved down despite the gravity pulling on us. If this
// is the case, we're probably stuck between two steep planes, allow jumping
// as if on a level ground.
if( fabs( pm->ps->gravity ) > 0.1f &&
fabs( pm->ps->origin[ 2 ] - previousZ ) < 0.05f )
PM_CheckJump( upNormal );
}
else
{
PM_StepSlideMove( qtrue, qfalse );
}
}

/*
Expand Down Expand Up @@ -1975,7 +1987,7 @@ static void PM_ClimbMove( void )
}


if( PM_CheckJump( ) || PM_CheckPounce( ) )
if( PM_CheckJump( NULL ) || PM_CheckPounce( ) )
{
// jumped away
if( pm->waterlevel > 1 )
Expand Down Expand Up @@ -2091,7 +2103,7 @@ static void PM_WalkMove( void )
return;
}

if( PM_CheckJump( ) || PM_CheckPounce( ) )
if( PM_CheckJump( NULL ) || PM_CheckPounce( ) )
{
// jumped away
if( pm->waterlevel > 1 )
Expand Down

0 comments on commit f25efb1

Please sign in to comment.