diff options
Diffstat (limited to 'src/game/bg_pmove.c')
-rw-r--r-- | src/game/bg_pmove.c | 1211 |
1 files changed, 637 insertions, 574 deletions
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index e79a3a8c..cae5470b 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -47,7 +47,8 @@ PM_AddEvent =============== */ -void PM_AddEvent( int newEvent ) { +void PM_AddEvent( int newEvent ) +{ BG_AddPredictableEventToPlayerstate( newEvent, 0, pm->ps ); } @@ -56,25 +57,25 @@ void PM_AddEvent( int newEvent ) { PM_AddTouchEnt =============== */ -void PM_AddTouchEnt( int entityNum ) { +void PM_AddTouchEnt( int entityNum ) +{ int i; - if ( entityNum == ENTITYNUM_WORLD ) { + if( entityNum == ENTITYNUM_WORLD ) return; - } - if ( pm->numtouch == MAXTOUCH ) { + + if( pm->numtouch == MAXTOUCH ) return; - } // see if it is already added - for ( i = 0 ; i < pm->numtouch ; i++ ) { - if ( pm->touchents[ i ] == entityNum ) { + for( i = 0 ; i < pm->numtouch ; i++ ) + { + if( pm->touchents[ i ] == entityNum ) return; - } } // add it - pm->touchents[pm->numtouch] = entityNum; + pm->touchents[ pm->numtouch ] = entityNum; pm->numtouch++; } @@ -83,45 +84,51 @@ void PM_AddTouchEnt( int entityNum ) { PM_StartTorsoAnim =================== */ -static void PM_StartTorsoAnim( int anim ) { - if ( pm->ps->pm_type >= PM_DEAD ) { +static void PM_StartTorsoAnim( int anim ) +{ + if( pm->ps->pm_type >= PM_DEAD ) return; - } + pm->ps->torsoAnim = ( ( pm->ps->torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; } -static void PM_StartLegsAnim( int anim ) { - if ( pm->ps->pm_type >= PM_DEAD ) { + +static void PM_StartLegsAnim( int anim ) +{ + if( pm->ps->pm_type >= PM_DEAD ) return; - } - if ( pm->ps->legsTimer > 0 ) { + + if( pm->ps->legsTimer > 0 ) return; // a high priority animation is running - } + pm->ps->legsAnim = ( ( pm->ps->legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; } -static void PM_ContinueLegsAnim( int anim ) { - if ( ( pm->ps->legsAnim & ~ANIM_TOGGLEBIT ) == anim ) { +static void PM_ContinueLegsAnim( int anim ) +{ + if( ( pm->ps->legsAnim & ~ANIM_TOGGLEBIT ) == anim ) return; - } - if ( pm->ps->legsTimer > 0 ) { + + if( pm->ps->legsTimer > 0 ) return; // a high priority animation is running - } + PM_StartLegsAnim( anim ); } -static void PM_ContinueTorsoAnim( int anim ) { - if ( ( pm->ps->torsoAnim & ~ANIM_TOGGLEBIT ) == anim ) { +static void PM_ContinueTorsoAnim( int anim ) +{ + if( ( pm->ps->torsoAnim & ~ANIM_TOGGLEBIT ) == anim ) return; - } - if ( pm->ps->torsoTimer > 0 ) { + + if( pm->ps->torsoTimer > 0 ) return; // a high priority animation is running - } + PM_StartTorsoAnim( anim ); } -static void PM_ForceLegsAnim( int anim ) { +static void PM_ForceLegsAnim( int anim ) +{ pm->ps->legsTimer = 0; PM_StartLegsAnim( anim ); } @@ -134,25 +141,26 @@ PM_ClipVelocity Slide off of the impacting surface ================== */ -void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce ) { +void PM_ClipVelocity( vec3_t in, vec3_t normal, vec3_t out, float overbounce ) +{ float backoff; float change; int i; - backoff = DotProduct (in, normal); + backoff = DotProduct( in, normal ); //Com_Printf( "%1.0f ", backoff ); - if ( backoff < 0 ) { + if( backoff < 0 ) backoff *= overbounce; - } else { + else backoff /= overbounce; - } - for ( i=0 ; i<3 ; i++ ) { - change = normal[i]*backoff; + for( i = 0; i < 3; i++ ) + { + change = normal[ i ] * backoff; //Com_Printf( "%1.0f ", change ); - out[i] = in[i] - change; + out[ i ] = in[ i ] - change; } //Com_Printf( " " ); @@ -166,25 +174,27 @@ PM_Friction Handles both ground friction and water friction ================== */ -static void PM_Friction( void ) { +static void PM_Friction( void ) +{ vec3_t vec; - float *vel; - float speed, newspeed, control; - float drop; + float *vel; + float speed, newspeed, control; + float drop; vel = pm->ps->velocity; //TA: make sure vertical velocity is NOT set to zero when wall climbing VectorCopy( vel, vec ); - if ( pml.walking && - !( pm->ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) ) { + if( pml.walking && + !( pm->ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) ) vec[2] = 0; // ignore slope movement - } - speed = VectorLength(vec); - if (speed < 1) { - vel[0] = 0; - vel[1] = 0; // allow sinking underwater + speed = VectorLength( vec ); + + if( speed < 1 ) + { + vel[ 0 ] = 0; + vel[ 1 ] = 0; // allow sinking underwater // FIXME: still have z friction underwater? return; } @@ -192,42 +202,42 @@ static void PM_Friction( void ) { drop = 0; // apply ground friction - if ( pm->waterlevel <= 1 ) { - if ( pml.walking && !(pml.groundTrace.surfaceFlags & SURF_SLICK) ) { + if( pm->waterlevel <= 1 ) + { + if( pml.walking && !( pml.groundTrace.surfaceFlags & SURF_SLICK ) ) + { // if getting knocked back, no friction - if ( ! (pm->ps->pm_flags & PMF_TIME_KNOCKBACK) ) + if( !( pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) ) { float sticky = BG_FindStickyForClass( pm->ps->stats[ STAT_PCLASS ] ); - control = speed < pm_stopspeed*sticky ? pm_stopspeed*sticky : speed; + control = speed < pm_stopspeed * sticky ? pm_stopspeed * sticky : speed; drop += control*pm_friction*pml.frametime; } } } // apply water friction even if just wading - if ( pm->waterlevel ) { - drop += speed*pm_waterfriction*pm->waterlevel*pml.frametime; - } + if( pm->waterlevel ) + drop += speed * pm_waterfriction * pm->waterlevel * pml.frametime; // apply flying friction if( BG_gotItem( UP_JETPACK, pm->ps->stats ) && BG_activated( UP_JETPACK, pm->ps->stats ) ) drop += speed * pm_flightfriction * pml.frametime; - if ( pm->ps->pm_type == PM_SPECTATOR ) { - drop += speed*pm_spectatorfriction*pml.frametime; - } + if( pm->ps->pm_type == PM_SPECTATOR ) + drop += speed * pm_spectatorfriction * pml.frametime; // scale the velocity newspeed = speed - drop; - if (newspeed < 0) { + if( newspeed < 0 ) newspeed = 0; - } + newspeed /= speed; - vel[0] = vel[0] * newspeed; - vel[1] = vel[1] * newspeed; - vel[2] = vel[2] * newspeed; + vel[ 0 ] = vel[ 0 ] * newspeed; + vel[ 1 ] = vel[ 1 ] * newspeed; + vel[ 2 ] = vel[ 2 ] * newspeed; } @@ -238,40 +248,38 @@ PM_Accelerate Handles user intended acceleration ============== */ -static void PM_Accelerate( vec3_t wishdir, float wishspeed, float accel ) { +static void PM_Accelerate( vec3_t wishdir, float wishspeed, float accel ) +{ #if 1 // q2 style int i; float addspeed, accelspeed, currentspeed; - currentspeed = DotProduct (pm->ps->velocity, wishdir); + currentspeed = DotProduct( pm->ps->velocity, wishdir ); addspeed = wishspeed - currentspeed; - if (addspeed <= 0) { + if( addspeed <= 0 ) return; - } - accelspeed = accel*pml.frametime*wishspeed; - if (accelspeed > addspeed) { + + accelspeed = accel * pml.frametime * wishspeed; + if( accelspeed > addspeed ) accelspeed = addspeed; - } - for (i=0 ; i<3 ; i++) { - pm->ps->velocity[i] += accelspeed*wishdir[i]; - } + for( i = 0; i < 3; i++ ) + pm->ps->velocity[ i ] += accelspeed*wishdir[ i ]; #else // proper way (avoids strafe jump maxspeed bug), but feels bad vec3_t wishVelocity; vec3_t pushDir; - float pushLen; - float canPush; + float pushLen; + float canPush; VectorScale( wishdir, wishspeed, wishVelocity ); VectorSubtract( wishVelocity, pm->ps->velocity, pushDir ); pushLen = VectorNormalize( pushDir ); - canPush = accel*pml.frametime*wishspeed; - if (canPush > pushLen) { + canPush = accel * pml.frametime * wishspeed; + if( canPush > pushLen ) canPush = pushLen; - } VectorMA( pm->ps->velocity, canPush, pushDir, pm->ps->velocity ); #endif @@ -288,14 +296,15 @@ This allows the clients to use axial -127 to 127 values for all directions without getting a sqrt(2) distortion in speed. ============ */ -static float PM_CmdScale( usercmd_t *cmd ) { - int max; - float total; - float scale; - float modifier = 1.0f; - static int time; - int dTime; - int aForward, aRight; +static float PM_CmdScale( usercmd_t *cmd ) +{ + int max; + float total; + float scale; + float modifier = 1.0f; + static int time; + int dTime; + int aForward, aRight; dTime = pm->cmd.serverTime - time; time = pm->cmd.serverTime; @@ -336,15 +345,14 @@ static float PM_CmdScale( usercmd_t *cmd ) { cmd->upmove = 0; max = abs( cmd->forwardmove ); - if ( abs( cmd->rightmove ) > max ) { + if( abs( cmd->rightmove ) > max ) max = abs( cmd->rightmove ); - } - if ( abs( cmd->upmove ) > max ) { + + if( abs( cmd->upmove ) > max ) max = abs( cmd->upmove ); - } - if ( !max ) { + + if( !max ) return 0; - } total = sqrt( cmd->forwardmove * cmd->forwardmove + cmd->rightmove * cmd->rightmove + cmd->upmove * cmd->upmove ); @@ -363,34 +371,36 @@ Determine the rotation of the legs reletive to the facing dir ================ */ -static void PM_SetMovementDir( void ) { - if ( pm->cmd.forwardmove || pm->cmd.rightmove ) { - if ( pm->cmd.rightmove == 0 && pm->cmd.forwardmove > 0 ) { +static void PM_SetMovementDir( void ) +{ + if( pm->cmd.forwardmove || pm->cmd.rightmove ) + { + if( pm->cmd.rightmove == 0 && pm->cmd.forwardmove > 0 ) pm->ps->movementDir = 0; - } else if ( pm->cmd.rightmove < 0 && pm->cmd.forwardmove > 0 ) { + else if( pm->cmd.rightmove < 0 && pm->cmd.forwardmove > 0 ) pm->ps->movementDir = 1; - } else if ( pm->cmd.rightmove < 0 && pm->cmd.forwardmove == 0 ) { + else if( pm->cmd.rightmove < 0 && pm->cmd.forwardmove == 0 ) pm->ps->movementDir = 2; - } else if ( pm->cmd.rightmove < 0 && pm->cmd.forwardmove < 0 ) { + else if( pm->cmd.rightmove < 0 && pm->cmd.forwardmove < 0 ) pm->ps->movementDir = 3; - } else if ( pm->cmd.rightmove == 0 && pm->cmd.forwardmove < 0 ) { + else if( pm->cmd.rightmove == 0 && pm->cmd.forwardmove < 0 ) pm->ps->movementDir = 4; - } else if ( pm->cmd.rightmove > 0 && pm->cmd.forwardmove < 0 ) { + else if( pm->cmd.rightmove > 0 && pm->cmd.forwardmove < 0 ) pm->ps->movementDir = 5; - } else if ( pm->cmd.rightmove > 0 && pm->cmd.forwardmove == 0 ) { + else if( pm->cmd.rightmove > 0 && pm->cmd.forwardmove == 0 ) pm->ps->movementDir = 6; - } else if ( pm->cmd.rightmove > 0 && pm->cmd.forwardmove > 0 ) { + else if( pm->cmd.rightmove > 0 && pm->cmd.forwardmove > 0 ) pm->ps->movementDir = 7; - } - } else { + } + else + { // if they aren't actively going directly sideways, // change the animation to the diagonal so they // don't stop too crooked - if ( pm->ps->movementDir == 2 ) { + if( pm->ps->movementDir == 2 ) pm->ps->movementDir = 1; - } else if ( pm->ps->movementDir == 6 ) { + else if( pm->ps->movementDir == 6 ) pm->ps->movementDir = 7; - } } } @@ -453,14 +463,12 @@ static qboolean PM_CheckJump( void ) ( pm->ps->stats[ STAT_STAMINA ] < 0 ) ) return qfalse; - if ( pm->ps->pm_flags & PMF_RESPAWNED ) { + if( pm->ps->pm_flags & PMF_RESPAWNED ) return qfalse; // don't allow jump until all buttons are up - } - if ( pm->cmd.upmove < 10 ) { + if( pm->cmd.upmove < 10 ) // not holding jump return qfalse; - } //can't jump whilst grabbed if( pm->ps->pm_type == PM_GRABBED && pm->ps->pm_type == PM_KNOCKED ) @@ -470,7 +478,8 @@ static qboolean PM_CheckJump( void ) } // must wait for jump to be released - if ( pm->ps->pm_flags & PMF_JUMP_HELD ) { + if( pm->ps->pm_flags & PMF_JUMP_HELD ) + { // clear upmove so cmdscale doesn't lower running speed pm->cmd.upmove = 0; return qfalse; @@ -497,14 +506,17 @@ static qboolean PM_CheckJump( void ) VectorMA( pm->ps->velocity, JUMP_VELOCITY, normal, pm->ps->velocity ); } else - pm->ps->velocity[2] = JUMP_VELOCITY; + pm->ps->velocity[ 2 ] = JUMP_VELOCITY; PM_AddEvent( EV_JUMP ); - if ( pm->cmd.forwardmove >= 0 ) { + if( pm->cmd.forwardmove >= 0 ) + { PM_ForceLegsAnim( LEGS_JUMP ); pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; - } else { + } + else + { PM_ForceLegsAnim( LEGS_JUMPB ); pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; } @@ -517,41 +529,40 @@ static qboolean PM_CheckJump( void ) PM_CheckWaterJump ============= */ -static qboolean PM_CheckWaterJump( void ) { +static qboolean PM_CheckWaterJump( void ) +{ vec3_t spot; - int cont; + int cont; vec3_t flatforward; - if (pm->ps->pm_time) { + if( pm->ps->pm_time ) return qfalse; - } // check for water jump - if ( pm->waterlevel != 2 ) { + if( pm->waterlevel != 2 ) return qfalse; - } - flatforward[0] = pml.forward[0]; - flatforward[1] = pml.forward[1]; - flatforward[2] = 0; - VectorNormalize (flatforward); + flatforward[ 0 ] = pml.forward[ 0 ]; + flatforward[ 1 ] = pml.forward[ 1 ]; + flatforward[ 2 ] = 0; + VectorNormalize( flatforward ); - VectorMA (pm->ps->origin, 30, flatforward, spot); - spot[2] += 4; - cont = pm->pointcontents (spot, pm->ps->clientNum ); - if ( !(cont & CONTENTS_SOLID) ) { + VectorMA( pm->ps->origin, 30, flatforward, spot ); + spot[ 2 ] += 4; + cont = pm->pointcontents( spot, pm->ps->clientNum ); + + if( !( cont & CONTENTS_SOLID ) ) return qfalse; - } - spot[2] += 16; - cont = pm->pointcontents (spot, pm->ps->clientNum ); - if ( cont ) { + spot[ 2 ] += 16; + cont = pm->pointcontents( spot, pm->ps->clientNum ); + + if( cont ) return qfalse; - } // jump out of water - VectorScale (pml.forward, 200, pm->ps->velocity); - pm->ps->velocity[2] = 350; + VectorScale( pml.forward, 200, pm->ps->velocity ); + pm->ps->velocity[ 2 ] = 350; pm->ps->pm_flags |= PMF_TIME_WATERJUMP; pm->ps->pm_time = 2000; @@ -569,13 +580,15 @@ PM_WaterJumpMove Flying out of the water =================== */ -static void PM_WaterJumpMove( void ) { +static void PM_WaterJumpMove( void ) +{ // waterjump has no control, but falls PM_StepSlideMove( qtrue, qfalse ); - pm->ps->velocity[2] -= pm->ps->gravity * pml.frametime; - if (pm->ps->velocity[2] < 0) { + pm->ps->velocity[ 2 ] -= pm->ps->gravity * pml.frametime; + if( pm->ps->velocity[ 2 ] < 0 ) + { // cancel as soon as we are falling down again pm->ps->pm_flags &= ~PMF_ALL_TIMES; pm->ps->pm_time = 0; @@ -588,7 +601,8 @@ PM_WaterMove =================== */ -static void PM_WaterMove( void ) { +static void PM_WaterMove( void ) +{ int i; vec3_t wishvel; float wishspeed; @@ -596,7 +610,8 @@ static void PM_WaterMove( void ) { float scale; float vel; - if ( PM_CheckWaterJump() ) { + if( PM_CheckWaterJump( ) ) + { PM_WaterJumpMove(); return; } @@ -614,41 +629,44 @@ static void PM_WaterMove( void ) { } } #endif - PM_Friction (); + PM_Friction( ); scale = PM_CmdScale( &pm->cmd ); // // user intentions // - if ( !scale ) { - wishvel[0] = 0; - wishvel[1] = 0; - wishvel[2] = -60; // sink towards bottom - } else { - for (i=0 ; i<3 ; i++) - wishvel[i] = scale * pml.forward[i]*pm->cmd.forwardmove + scale * pml.right[i]*pm->cmd.rightmove; + if( !scale ) + { + wishvel[ 0 ] = 0; + wishvel[ 1 ] = 0; + wishvel[ 2 ] = -60; // sink towards bottom + } + else + { + for( i = 0; i < 3; i++ ) + wishvel[ i ] = scale * pml.forward[ i ] * pm->cmd.forwardmove + scale * pml.right[ i ] * pm->cmd.rightmove; - wishvel[2] += scale * pm->cmd.upmove; + wishvel[ 2 ] += scale * pm->cmd.upmove; } - VectorCopy (wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); - if ( wishspeed > pm->ps->speed * pm_swimScale ) { + if( wishspeed > pm->ps->speed * pm_swimScale ) wishspeed = pm->ps->speed * pm_swimScale; - } - PM_Accelerate (wishdir, wishspeed, pm_wateraccelerate); + PM_Accelerate( wishdir, wishspeed, pm_wateraccelerate ); // make sure we can go up slopes easily under water - if ( pml.groundPlane && DotProduct( pm->ps->velocity, pml.groundTrace.plane.normal ) < 0 ) { - vel = VectorLength(pm->ps->velocity); + if( pml.groundPlane && DotProduct( pm->ps->velocity, pml.groundTrace.plane.normal ) < 0 ) + { + vel = VectorLength( pm->ps->velocity ); // slide along the ground plane - PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal, + PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP ); - VectorNormalize(pm->ps->velocity); - VectorScale(pm->ps->velocity, vel, pm->ps->velocity); + VectorNormalize( pm->ps->velocity ); + VectorScale( pm->ps->velocity, vel, pm->ps->velocity ); } PM_SlideMove( qfalse ); @@ -661,7 +679,8 @@ PM_JetPackMove Only with the jetpack =================== */ -static void PM_JetPackMove( void ) { +static void PM_JetPackMove( void ) +{ int i; vec3_t wishvel; float wishspeed; @@ -702,36 +721,39 @@ PM_FlyMove Only with the flight powerup =================== */ -static void PM_FlyMove( void ) { - int i; +static void PM_FlyMove( void ) +{ + int i; vec3_t wishvel; - float wishspeed; + float wishspeed; vec3_t wishdir; - float scale; + float scale; // normal slowdown - PM_Friction (); + PM_Friction( ); scale = PM_CmdScale( &pm->cmd ); // // user intentions // - if ( !scale ) { - wishvel[0] = 0; - wishvel[1] = 0; - wishvel[2] = 0; - } else { - for (i=0 ; i<3 ; i++) { - wishvel[i] = scale * pml.forward[i]*pm->cmd.forwardmove + scale * pml.right[i]*pm->cmd.rightmove; - } + if( !scale ) + { + wishvel[ 0 ] = 0; + wishvel[ 1 ] = 0; + wishvel[ 2 ] = 0; + } + else + { + for( i = 0; i < 3; i++ ) + wishvel[ i ] = scale * pml.forward[ i ] * pm->cmd.forwardmove + scale * pml.right[ i ] * pm->cmd.rightmove; - wishvel[2] += scale * pm->cmd.upmove; + wishvel[ 2 ] += scale * pm->cmd.upmove; } - VectorCopy (wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); - PM_Accelerate (wishdir, wishspeed, pm_flyaccelerate); + PM_Accelerate( wishdir, wishspeed, pm_flyaccelerate ); PM_StepSlideMove( qfalse, qfalse ); } @@ -743,16 +765,17 @@ PM_AirMove =================== */ -static void PM_AirMove( void ) { - int i; +static void PM_AirMove( void ) +{ + int i; vec3_t wishvel; - float fmove, smove; + float fmove, smove; vec3_t wishdir; - float wishspeed; - float scale; + float wishspeed; + float scale; usercmd_t cmd; - PM_Friction(); + PM_Friction( ); fmove = pm->cmd.forwardmove; smove = pm->cmd.rightmove; @@ -761,33 +784,32 @@ static void PM_AirMove( void ) { scale = PM_CmdScale( &cmd ); // set the movementDir so clients can rotate the legs for strafing - PM_SetMovementDir(); + PM_SetMovementDir( ); // project moves down to flat plane - pml.forward[2] = 0; - pml.right[2] = 0; - VectorNormalize (pml.forward); - VectorNormalize (pml.right); + pml.forward[ 2 ] = 0; + pml.right[ 2 ] = 0; + VectorNormalize( pml.forward ); + VectorNormalize( pml.right ); - for ( i = 0 ; i < 2 ; i++ ) { - wishvel[i] = pml.forward[i]*fmove + pml.right[i]*smove; - } - wishvel[2] = 0; + for( i = 0; i < 2; i++ ) + wishvel[ i ] = pml.forward[ i ] * fmove + pml.right[ i ] * smove; - VectorCopy (wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); + wishvel[ 2 ] = 0; + + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); wishspeed *= scale; // not on ground, so little effect on velocity - PM_Accelerate (wishdir, wishspeed, pm_airaccelerate); + PM_Accelerate( wishdir, wishspeed, pm_airaccelerate ); // we may have a ground plane that is very steep, even // though we don't have a groundentity // slide along the steep plane - if ( pml.groundPlane ) { - PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal, + if( pml.groundPlane ) + PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP ); - } #if 0 //ZOID: If we are on the grapple, try stair-stepping @@ -799,7 +821,7 @@ static void PM_AirMove( void ) { PM_SlideMove ( qtrue ); #endif - PM_StepSlideMove ( qtrue, qfalse ); + PM_StepSlideMove( qtrue, qfalse ); } /* @@ -808,22 +830,23 @@ PM_GrappleMove =================== */ -static void PM_GrappleMove( void ) { - vec3_t vel, v; - float vlen; - - VectorScale(pml.forward, -16, v); - VectorAdd(pm->ps->grapplePoint, v, v); - VectorSubtract(v, pm->ps->origin, vel); - vlen = VectorLength(vel); +static void PM_GrappleMove( void ) +{ + vec3_t vel, v; + float vlen; + + VectorScale( pml.forward, -16, v ); + VectorAdd( pm->ps->grapplePoint, v, v ); + VectorSubtract( v, pm->ps->origin, vel ); + vlen = VectorLength( vel ); VectorNormalize( vel ); - if (vlen <= 100) - VectorScale(vel, 10 * vlen, vel); + if( vlen <= 100 ) + VectorScale( vel, 10 * vlen, vel ); else - VectorScale(vel, 800, vel); + VectorScale( vel, 800, vel ); - VectorCopy(vel, pm->ps->velocity); + VectorCopy( vel, pm->ps->velocity ); pml.groundPlane = qfalse; } @@ -835,35 +858,38 @@ PM_ClimbMove =================== */ -static void PM_ClimbMove( void ) { - int i; +static void PM_ClimbMove( void ) +{ + int i; vec3_t wishvel; - float fmove, smove; + float fmove, smove; vec3_t wishdir; - float wishspeed; - float scale; + float wishspeed; + float scale; usercmd_t cmd; - float accelerate; - float vel; + float accelerate; + float vel; - if ( pm->waterlevel > 2 && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) { + if( pm->waterlevel > 2 && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) + { // begin swimming - PM_WaterMove(); + PM_WaterMove( ); return; } - if ( PM_CheckJump( ) || PM_CheckPounce( ) ) { + if( PM_CheckJump( ) || PM_CheckPounce( ) ) + { // jumped away - if ( pm->waterlevel > 1 ) { - PM_WaterMove(); - } else { - PM_AirMove(); - } + if( pm->waterlevel > 1 ) + PM_WaterMove( ); + else + PM_AirMove( ); + return; } - PM_Friction (); + PM_Friction( ); fmove = pm->cmd.forwardmove; smove = pm->cmd.rightmove; @@ -872,71 +898,68 @@ static void PM_ClimbMove( void ) { scale = PM_CmdScale( &cmd ); // set the movementDir so clients can rotate the legs for strafing - PM_SetMovementDir(); + PM_SetMovementDir( ); // project the forward and right directions onto the ground plane - PM_ClipVelocity (pml.forward, pml.groundTrace.plane.normal, pml.forward, OVERCLIP ); - PM_ClipVelocity (pml.right, pml.groundTrace.plane.normal, pml.right, OVERCLIP ); + PM_ClipVelocity( pml.forward, pml.groundTrace.plane.normal, pml.forward, OVERCLIP ); + PM_ClipVelocity( pml.right, pml.groundTrace.plane.normal, pml.right, OVERCLIP ); // - VectorNormalize (pml.forward); - VectorNormalize (pml.right); + VectorNormalize( pml.forward ); + VectorNormalize( pml.right ); + + for( i = 0; i < 3; i++ ) + wishvel[ i ] = pml.forward[ i ] * fmove + pml.right[ i ] * smove; - for ( i = 0 ; i < 3 ; i++ ) { - wishvel[i] = pml.forward[i]*fmove + pml.right[i]*smove; - } // when going up or down slopes the wish velocity should Not be zero // wishvel[2] = 0; - VectorCopy (wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); wishspeed *= scale; // clamp the speed lower if ducking - if ( pm->ps->pm_flags & PMF_DUCKED ) { - if ( wishspeed > pm->ps->speed * pm_duckScale ) { + if( pm->ps->pm_flags & PMF_DUCKED ) + { + if( wishspeed > pm->ps->speed * pm_duckScale ) wishspeed = pm->ps->speed * pm_duckScale; - } } // clamp the speed lower if wading or walking on the bottom - if ( pm->waterlevel ) { + if( pm->waterlevel ) + { float waterScale; waterScale = pm->waterlevel / 3.0; waterScale = 1.0 - ( 1.0 - pm_swimScale ) * waterScale; - if ( wishspeed > pm->ps->speed * waterScale ) { + if( wishspeed > pm->ps->speed * waterScale ) wishspeed = pm->ps->speed * waterScale; - } } // when a player gets hit, they temporarily lose // full control, which allows them to be moved a bit - if ( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) { + if( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) accelerate = pm_airaccelerate; - } else { + else accelerate = pm_accelerate; - } - PM_Accelerate (wishdir, wishspeed, accelerate); + PM_Accelerate( wishdir, wishspeed, accelerate ); - if ( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) { - pm->ps->velocity[2] -= pm->ps->gravity * pml.frametime; - } + if( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) + pm->ps->velocity[ 2 ] -= pm->ps->gravity * pml.frametime; - vel = VectorLength(pm->ps->velocity); + vel = VectorLength( pm->ps->velocity ); // slide along the ground plane - PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal, + PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP ); // don't decrease velocity when going up or down a slope - VectorNormalize(pm->ps->velocity); - VectorScale(pm->ps->velocity, vel, pm->ps->velocity); + VectorNormalize( pm->ps->velocity ); + VectorScale( pm->ps->velocity, vel, pm->ps->velocity ); // don't do anything if standing still - if (!pm->ps->velocity[0] && !pm->ps->velocity[1] && !pm->ps->velocity[2]) { + if( !pm->ps->velocity[ 0 ] && !pm->ps->velocity[ 1 ] && !pm->ps->velocity[ 2 ] ) return; - } PM_StepSlideMove( qfalse, qfalse ); } @@ -948,35 +971,38 @@ PM_WalkMove =================== */ -static void PM_WalkMove( void ) { - int i; +static void PM_WalkMove( void ) +{ + int i; vec3_t wishvel; - float fmove, smove; + float fmove, smove; vec3_t wishdir; - float wishspeed; - float scale; + float wishspeed; + float scale; usercmd_t cmd; - float accelerate; - float vel; + float accelerate; + float vel; - if ( pm->waterlevel > 2 && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) { + if( pm->waterlevel > 2 && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) + { // begin swimming - PM_WaterMove(); + PM_WaterMove( ); return; } - if( PM_CheckJump( ) || PM_CheckPounce( ) ) { + if( PM_CheckJump( ) || PM_CheckPounce( ) ) + { // jumped away - if ( pm->waterlevel > 1 ) { - PM_WaterMove(); - } else { - PM_AirMove(); - } + if( pm->waterlevel > 1 ) + PM_WaterMove( ); + else + PM_AirMove( ); + return; } - PM_Friction (); + PM_Friction( ); fmove = pm->cmd.forwardmove; smove = pm->cmd.rightmove; @@ -985,81 +1011,80 @@ static void PM_WalkMove( void ) { scale = PM_CmdScale( &cmd ); // set the movementDir so clients can rotate the legs for strafing - PM_SetMovementDir(); + PM_SetMovementDir( ); // project moves down to flat plane - pml.forward[2] = 0; - pml.right[2] = 0; + pml.forward[ 2 ] = 0; + pml.right[ 2 ] = 0; // project the forward and right directions onto the ground plane - PM_ClipVelocity (pml.forward, pml.groundTrace.plane.normal, pml.forward, OVERCLIP ); - PM_ClipVelocity (pml.right, pml.groundTrace.plane.normal, pml.right, OVERCLIP ); + PM_ClipVelocity( pml.forward, pml.groundTrace.plane.normal, pml.forward, OVERCLIP ); + PM_ClipVelocity( pml.right, pml.groundTrace.plane.normal, pml.right, OVERCLIP ); // - VectorNormalize (pml.forward); - VectorNormalize (pml.right); + VectorNormalize( pml.forward ); + VectorNormalize( pml.right ); + + for( i = 0; i < 3; i++ ) + wishvel[ i ] = pml.forward[ i ] * fmove + pml.right[ i ] * smove; - for ( i = 0 ; i < 3 ; i++ ) { - wishvel[i] = pml.forward[i]*fmove + pml.right[i]*smove; - } // when going up or down slopes the wish velocity should Not be zero // wishvel[2] = 0; - VectorCopy (wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); wishspeed *= scale; // clamp the speed lower if ducking - if ( pm->ps->pm_flags & PMF_DUCKED ) { - if ( wishspeed > pm->ps->speed * pm_duckScale ) { + if( pm->ps->pm_flags & PMF_DUCKED ) + { + if( wishspeed > pm->ps->speed * pm_duckScale ) wishspeed = pm->ps->speed * pm_duckScale; - } } // clamp the speed lower if wading or walking on the bottom - if ( pm->waterlevel ) { + if( pm->waterlevel ) + { float waterScale; waterScale = pm->waterlevel / 3.0; waterScale = 1.0 - ( 1.0 - pm_swimScale ) * waterScale; - if ( wishspeed > pm->ps->speed * waterScale ) { + if( wishspeed > pm->ps->speed * waterScale ) wishspeed = pm->ps->speed * waterScale; - } } // when a player gets hit, they temporarily lose // full control, which allows them to be moved a bit - if ( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) { + if( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) accelerate = pm_airaccelerate; - } else { + else accelerate = pm_accelerate; - } - PM_Accelerate (wishdir, wishspeed, accelerate); + PM_Accelerate( wishdir, wishspeed, accelerate ); //Com_Printf("velocity = %1.1f %1.1f %1.1f\n", pm->ps->velocity[0], pm->ps->velocity[1], pm->ps->velocity[2]); //Com_Printf("velocity1 = %1.1f\n", VectorLength(pm->ps->velocity)); - if ( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) { - pm->ps->velocity[2] -= pm->ps->gravity * pml.frametime; - } else { + if( ( pml.groundTrace.surfaceFlags & SURF_SLICK ) || pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) + pm->ps->velocity[ 2 ] -= pm->ps->gravity * pml.frametime; + else + { // don't reset the z velocity for slopes // pm->ps->velocity[2] = 0; } - vel = VectorLength(pm->ps->velocity); + vel = VectorLength( pm->ps->velocity ); // slide along the ground plane - PM_ClipVelocity (pm->ps->velocity, pml.groundTrace.plane.normal, + PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP ); // don't decrease velocity when going up or down a slope - VectorNormalize(pm->ps->velocity); - VectorScale(pm->ps->velocity, vel, pm->ps->velocity); + VectorNormalize( pm->ps->velocity ); + VectorScale( pm->ps->velocity, vel, pm->ps->velocity ); // don't do anything if standing still - if (!pm->ps->velocity[0] && !pm->ps->velocity[1]) { + if( !pm->ps->velocity[ 0 ] && !pm->ps->velocity[ 1 ] ) return; - } PM_StepSlideMove( qfalse, qfalse ); @@ -1073,22 +1098,24 @@ static void PM_WalkMove( void ) { PM_DeadMove ============== */ -static void PM_DeadMove( void ) { +static void PM_DeadMove( void ) +{ float forward; - if ( !pml.walking ) { + if( !pml.walking ) return; - } // extra friction - forward = VectorLength (pm->ps->velocity); + forward = VectorLength( pm->ps->velocity ); forward -= 20; - if ( forward <= 0 ) { - VectorClear (pm->ps->velocity); - } else { - VectorNormalize (pm->ps->velocity); - VectorScale (pm->ps->velocity, forward, pm->ps->velocity); + + if( forward <= 0 ) + VectorClear( pm->ps->velocity ); + else + { + VectorNormalize( pm->ps->velocity ); + VectorScale( pm->ps->velocity, forward, pm->ps->velocity ); } } @@ -1098,12 +1125,13 @@ static void PM_DeadMove( void ) { PM_NoclipMove =============== */ -static void PM_NoclipMove( void ) { - float speed, drop, friction, control, newspeed; +static void PM_NoclipMove( void ) +{ + float speed, drop, friction, control, newspeed; int i; - vec3_t wishvel; + vec3_t wishvel; float fmove, smove; - vec3_t wishdir; + vec3_t wishdir; float wishspeed; float scale; @@ -1111,26 +1139,29 @@ static void PM_NoclipMove( void ) { // friction - speed = VectorLength (pm->ps->velocity); - if (speed < 1) + speed = VectorLength( pm->ps->velocity ); + + if( speed < 1 ) { - VectorCopy (vec3_origin, pm->ps->velocity); + VectorCopy( vec3_origin, pm->ps->velocity ); } else { drop = 0; - friction = pm_friction*1.5; // extra friction + friction = pm_friction * 1.5; // extra friction control = speed < pm_stopspeed ? pm_stopspeed : speed; - drop += control*friction*pml.frametime; + drop += control * friction * pml.frametime; // scale the velocity newspeed = speed - drop; - if (newspeed < 0) + + if( newspeed < 0 ) newspeed = 0; + newspeed /= speed; - VectorScale (pm->ps->velocity, newspeed, pm->ps->velocity); + VectorScale( pm->ps->velocity, newspeed, pm->ps->velocity ); } // accelerate @@ -1139,18 +1170,19 @@ static void PM_NoclipMove( void ) { fmove = pm->cmd.forwardmove; smove = pm->cmd.rightmove; - for (i=0 ; i<3 ; i++) - wishvel[i] = pml.forward[i]*fmove + pml.right[i]*smove; - wishvel[2] += pm->cmd.upmove; + for( i = 0; i < 3; i++ ) + wishvel[ i ] = pml.forward[ i ] * fmove + pml.right[ i ] * smove; + + wishvel[ 2 ] += pm->cmd.upmove; - VectorCopy (wishvel, wishdir); - wishspeed = VectorNormalize(wishdir); + VectorCopy( wishvel, wishdir ); + wishspeed = VectorNormalize( wishdir ); wishspeed *= scale; PM_Accelerate( wishdir, wishspeed, pm_accelerate ); // move - VectorMA (pm->ps->origin, pml.frametime, pm->ps->velocity, pm->ps->origin); + VectorMA( pm->ps->origin, pml.frametime, pm->ps->velocity, pm->ps->origin ); } //============================================================================ @@ -1185,7 +1217,8 @@ PM_CrashLand Check for hard landings that generate sound events ================= */ -static void PM_CrashLand( void ) { +static void PM_CrashLand( void ) +{ float delta; float dist; float vel, acc; @@ -1193,17 +1226,16 @@ static void PM_CrashLand( void ) { float a, b, c, den; // decide which landing animation to use - if ( pm->ps->pm_flags & PMF_BACKWARDS_JUMP ) { + if( pm->ps->pm_flags & PMF_BACKWARDS_JUMP ) PM_ForceLegsAnim( LEGS_LANDB ); - } else { + else PM_ForceLegsAnim( LEGS_LAND ); - } pm->ps->legsTimer = TIMER_LAND; // calculate the exact velocity on landing - dist = pm->ps->origin[2] - pml.previous_origin[2]; - vel = pml.previous_velocity[2]; + dist = pm->ps->origin[ 2 ] - pml.previous_origin[ 2 ]; + vel = pml.previous_velocity[ 2 ]; acc = -pm->ps->gravity; a = acc / 2; @@ -1211,53 +1243,52 @@ static void PM_CrashLand( void ) { c = -dist; den = b * b - 4 * a * c; - if ( den < 0 ) { + if( den < 0 ) return; - } + t = (-b - sqrt( den ) ) / ( 2 * a ); delta = vel + t * acc; delta = delta*delta * 0.0001; // ducking while falling doubles damage - if ( pm->ps->pm_flags & PMF_DUCKED ) { + if( pm->ps->pm_flags & PMF_DUCKED ) delta *= 2; - } // never take falling damage if completely underwater - if ( pm->waterlevel == 3 ) { + if( pm->waterlevel == 3 ) return; - } // reduce falling damage if there is standing water - if ( pm->waterlevel == 2 ) { + if( pm->waterlevel == 2 ) delta *= 0.25; - } - if ( pm->waterlevel == 1 ) { + + if( pm->waterlevel == 1 ) delta *= 0.5; - } - if ( delta < 1 ) { + if( delta < 1 ) return; - } // create a local entity event to play the sound // SURF_NODAMAGE is used for bounce pads where you don't ever // want to take damage or play a crunch sound - if ( !(pml.groundTrace.surfaceFlags & SURF_NODAMAGE) ) { - if ( delta > 60 ) { + if( !( pml.groundTrace.surfaceFlags & SURF_NODAMAGE ) ) + { + if( delta > 60 ) + { PM_AddEvent( EV_FALL_FAR ); - } else if ( delta > 40 ) { + } + else if( delta > 40 ) + { // this is a pain grunt, so don't play it if dead - if ( pm->ps->stats[STAT_HEALTH] > 0 ) { + if( pm->ps->stats[STAT_HEALTH] > 0 ) PM_AddEvent( EV_FALL_MEDIUM ); - } - } else if ( delta > 7 ) { - PM_AddEvent( EV_FALL_SHORT ); - } else { - PM_AddEvent( PM_FootstepForSurface() ); } + else if( delta > 7 ) + PM_AddEvent( EV_FALL_SHORT ); + else + PM_AddEvent( PM_FootstepForSurface( ) ); } // start footstep cycle over @@ -1270,29 +1301,34 @@ static void PM_CrashLand( void ) { PM_CorrectAllSolid ============= */ -static int PM_CorrectAllSolid( trace_t *trace ) { - int i, j, k; +static int PM_CorrectAllSolid( trace_t *trace ) +{ + int i, j, k; vec3_t point; - if ( pm->debugLevel ) { + if( pm->debugLevel ) Com_Printf("%i:allsolid\n", c_pmove); - } // jitter around - for (i = -1; i <= 1; i++) { - for (j = -1; j <= 1; j++) { - for (k = -1; k <= 1; k++) { - VectorCopy(pm->ps->origin, point); - point[0] += (float) i; - point[1] += (float) j; - point[2] += (float) k; - pm->trace (trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); - if ( !trace->allsolid ) { - point[0] = pm->ps->origin[0]; - point[1] = pm->ps->origin[1]; - point[2] = pm->ps->origin[2] - 0.25; - - pm->trace (trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); + for( i = -1; i <= 1; i++ ) + { + for( j = -1; j <= 1; j++ ) + { + for( k = -1; k <= 1; k++ ) + { + VectorCopy( pm->ps->origin, point ); + point[ 0 ] += (float)i; + point[ 1 ] += (float)j; + point[ 2 ] += (float)k; + pm->trace( trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask ); + + if( !trace->allsolid ) + { + point[ 0 ] = pm->ps->origin[ 0 ]; + point[ 1 ] = pm->ps->origin[ 1 ]; + point[ 2 ] = pm->ps->origin[ 2 ] - 0.25; + + pm->trace( trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask ); pml.groundTrace = *trace; return qtrue; } @@ -1315,27 +1351,32 @@ PM_GroundTraceMissed The ground trace didn't hit a surface, so we are in freefall ============= */ -static void PM_GroundTraceMissed( void ) { +static void PM_GroundTraceMissed( void ) +{ trace_t trace; vec3_t point; - if ( pm->ps->groundEntityNum != ENTITYNUM_NONE ) { + if( pm->ps->groundEntityNum != ENTITYNUM_NONE ) + { // we just transitioned into freefall - if ( pm->debugLevel ) { - Com_Printf("%i:lift\n", c_pmove); - } + if( pm->debugLevel ) + Com_Printf( "%i:lift\n", c_pmove ); // if they aren't in a jumping animation and the ground is a ways away, force into it // if we didn't do the trace, the player would be backflipping down staircases VectorCopy( pm->ps->origin, point ); - point[2] -= 64; + point[ 2 ] -= 64; - pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); - if ( trace.fraction == 1.0 ) { - if ( pm->cmd.forwardmove >= 0 ) { + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask ); + if( trace.fraction == 1.0 ) + { + if( pm->cmd.forwardmove >= 0 ) + { PM_ForceLegsAnim( LEGS_JUMP ); pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; - } else { + } + else + { PM_ForceLegsAnim( LEGS_JUMPB ); pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; } @@ -1639,7 +1680,8 @@ static void PM_GroundClimbTrace( void ) PM_GroundTrace ============= */ -static void PM_GroundTrace( void ) { +static void PM_GroundTrace( void ) +{ vec3_t point, forward, srotAxis; vec3_t refNormal = { 0.0f, 0.0f, 1.0f }; trace_t trace; @@ -1678,26 +1720,27 @@ static void PM_GroundTrace( void ) { if( BG_ClassHasAbility( pm->ps->stats[ STAT_PCLASS ], SCA_WALLCLIMBER ) ) VectorCopy( refNormal, pm->ps->grapplePoint ); - point[0] = pm->ps->origin[0]; - point[1] = pm->ps->origin[1]; - point[2] = pm->ps->origin[2] - 0.25; + point[ 0 ] = pm->ps->origin[ 0 ]; + point[ 1 ] = pm->ps->origin[ 1 ]; + point[ 2 ] = pm->ps->origin[ 2 ] - 0.25; //FIXME: hack until i find out where CONTENTS_BODY is getting unset for uhm.. bodies. if( pm->ps->pm_type == PM_DEAD ) - pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, MASK_PLAYERSOLID ); + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, MASK_PLAYERSOLID ); else - pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask); + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask ); + pml.groundTrace = trace; // do something corrective if the trace starts in a solid... if( trace.allsolid ) - if( !PM_CorrectAllSolid(&trace) ) + if( !PM_CorrectAllSolid( &trace ) ) return; // if the trace didn't hit anything, we are in free fall if( trace.fraction == 1.0 ) { - PM_GroundTraceMissed(); + PM_GroundTraceMissed( ); pml.groundPlane = qfalse; pml.walking = qfalse; @@ -1705,15 +1748,19 @@ static void PM_GroundTrace( void ) { } // check if getting thrown off the ground - if ( pm->ps->velocity[2] > 0 && DotProduct( pm->ps->velocity, trace.plane.normal ) > 10 ) { - if ( pm->debugLevel ) { - Com_Printf("%i:kickoff\n", c_pmove); - } + if( pm->ps->velocity[ 2 ] > 0 && DotProduct( pm->ps->velocity, trace.plane.normal ) > 10 ) + { + if( pm->debugLevel ) + Com_Printf( "%i:kickoff\n", c_pmove ); + // go into jump animation - if ( pm->cmd.forwardmove >= 0 ) { + if( pm->cmd.forwardmove >= 0 ) + { PM_ForceLegsAnim( LEGS_JUMP ); pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; - } else { + } + else + { PM_ForceLegsAnim( LEGS_JUMPB ); pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; } @@ -1725,10 +1772,11 @@ static void PM_GroundTrace( void ) { } // slopes that are too steep will not be considered onground - if ( trace.plane.normal[2] < MIN_WALK_NORMAL ) { - if ( pm->debugLevel ) { - Com_Printf("%i:steep\n", c_pmove); - } + if( trace.plane.normal[ 2 ] < MIN_WALK_NORMAL ) + { + if( pm->debugLevel ) + Com_Printf( "%i:steep\n", c_pmove ); + // FIXME: if they can't slide down the slope, let them // walk (sharp crevices) pm->ps->groundEntityNum = ENTITYNUM_NONE; @@ -1741,23 +1789,24 @@ static void PM_GroundTrace( void ) { pml.walking = qtrue; // hitting solid ground will end a waterjump - if (pm->ps->pm_flags & PMF_TIME_WATERJUMP) + if( pm->ps->pm_flags & PMF_TIME_WATERJUMP ) { - pm->ps->pm_flags &= ~(PMF_TIME_WATERJUMP | PMF_TIME_LAND); + pm->ps->pm_flags &= ~( PMF_TIME_WATERJUMP | PMF_TIME_LAND ); pm->ps->pm_time = 0; } - if ( pm->ps->groundEntityNum == ENTITYNUM_NONE ) { + if( pm->ps->groundEntityNum == ENTITYNUM_NONE ) + { // just hit the ground - if ( pm->debugLevel ) { - Com_Printf("%i:Land\n", c_pmove); - } + if( pm->debugLevel ) + Com_Printf( "%i:Land\n", c_pmove ); if( BG_ClassHasAbility( pm->ps->stats[ STAT_PCLASS ], SCA_TAKESFALLDAMAGE ) ) - PM_CrashLand(); + PM_CrashLand( ); // don't do landing time if we were just going down a slope - if ( pml.previous_velocity[2] < -200 ) { + if( pml.previous_velocity[ 2 ] < -200 ) + { // don't allow another jump for a little while pm->ps->pm_flags |= PMF_TIME_LAND; pm->ps->pm_time = 250; @@ -1778,8 +1827,9 @@ static void PM_GroundTrace( void ) { PM_SetWaterLevel FIXME: avoid this twice? certainly if not moving ============= */ -static void PM_SetWaterLevel( void ) { - vec3_t point; +static void PM_SetWaterLevel( void ) +{ + vec3_t point; int cont; int sample1; int sample2; @@ -1790,29 +1840,31 @@ static void PM_SetWaterLevel( void ) { pm->waterlevel = 0; pm->watertype = 0; - point[0] = pm->ps->origin[0]; - point[1] = pm->ps->origin[1]; - point[2] = pm->ps->origin[2] + MINS_Z + 1; + point[ 0 ] = pm->ps->origin[ 0 ]; + point[ 1 ] = pm->ps->origin[ 1 ]; + point[ 2 ] = pm->ps->origin[ 2 ] + MINS_Z + 1; cont = pm->pointcontents( point, pm->ps->clientNum ); - if ( cont & MASK_WATER ) { + if( cont & MASK_WATER ) + { sample2 = pm->ps->viewheight - MINS_Z; sample1 = sample2 / 2; pm->watertype = cont; pm->waterlevel = 1; - point[2] = pm->ps->origin[2] + MINS_Z + sample1; - cont = pm->pointcontents (point, pm->ps->clientNum ); - if ( cont & MASK_WATER ) { + point[ 2 ] = pm->ps->origin[ 2 ] + MINS_Z + sample1; + cont = pm->pointcontents( point, pm->ps->clientNum ); + + if( cont & MASK_WATER ) + { pm->waterlevel = 2; - point[2] = pm->ps->origin[2] + MINS_Z + sample2; - cont = pm->pointcontents (point, pm->ps->clientNum ); - if ( cont & MASK_WATER ){ + point[ 2 ] = pm->ps->origin[ 2 ] + MINS_Z + sample2; + cont = pm->pointcontents( point, pm->ps->clientNum ); + + if( cont & MASK_WATER ) pm->waterlevel = 3; - } } } - } @@ -1837,13 +1889,13 @@ static void PM_CheckDuck (void) if( pm->ps->persistant[ PERS_TEAM ] == TEAM_SPECTATOR ) PCcvh = PCvh; - pm->mins[0] = PCmins[0]; - pm->mins[1] = PCmins[1]; + pm->mins[ 0 ] = PCmins[ 0 ]; + pm->mins[ 1 ] = PCmins[ 1 ]; - pm->maxs[0] = PCmaxs[0]; - pm->maxs[1] = PCmaxs[1]; + pm->maxs[ 0 ] = PCmaxs[ 0 ]; + pm->maxs[ 1 ] = PCmaxs[ 1 ]; - pm->mins[2] = PCmins[2]; + pm->mins[ 2 ] = PCmins[ 2 ]; if (pm->ps->pm_type == PM_DEAD) { @@ -1863,21 +1915,21 @@ static void PM_CheckDuck (void) if (pm->ps->pm_flags & PMF_DUCKED) { // try to stand up - pm->maxs[2] = PCmaxs[2]; - pm->trace (&trace, pm->ps->origin, pm->mins, pm->maxs, pm->ps->origin, pm->ps->clientNum, pm->tracemask ); - if (!trace.allsolid) + pm->maxs[ 2 ] = PCmaxs[ 2 ]; + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, pm->ps->origin, pm->ps->clientNum, pm->tracemask ); + if( !trace.allsolid ) pm->ps->pm_flags &= ~PMF_DUCKED; } } - if (pm->ps->pm_flags & PMF_DUCKED) + if( pm->ps->pm_flags & PMF_DUCKED ) { - pm->maxs[2] = PCcmaxs[2]; + pm->maxs[ 2 ] = PCcmaxs[ 2 ]; pm->ps->viewheight = PCcvh; } else { - pm->maxs[2] = PCmaxs[2]; + pm->maxs[ 2 ] = PCmaxs[ 2 ]; pm->ps->viewheight = PCvh; } } @@ -1892,9 +1944,10 @@ static void PM_CheckDuck (void) PM_Footsteps =============== */ -static void PM_Footsteps( void ) { - float bobmove; - int old; +static void PM_Footsteps( void ) +{ + float bobmove; + int old; qboolean footstep; // @@ -1904,31 +1957,33 @@ static void PM_Footsteps( void ) { if( BG_ClassHasAbility( pm->ps->stats[ STAT_PCLASS ], SCA_WALLCLIMBER ) && ( pml.groundPlane ) ) { //TA: FIXME: yes yes i know this is wrong - pm->xyspeed = sqrt( pm->ps->velocity[0] * pm->ps->velocity[0] - + pm->ps->velocity[1] * pm->ps->velocity[1] - + pm->ps->velocity[2] * pm->ps->velocity[2] ); + pm->xyspeed = sqrt( pm->ps->velocity[ 0 ] * pm->ps->velocity[ 0 ] + + pm->ps->velocity[ 1 ] * pm->ps->velocity[ 1 ] + + pm->ps->velocity[ 2 ] * pm->ps->velocity[ 2 ] ); } else - pm->xyspeed = sqrt( pm->ps->velocity[0] * pm->ps->velocity[0] - + pm->ps->velocity[1] * pm->ps->velocity[1] ); + pm->xyspeed = sqrt( pm->ps->velocity[ 0 ] * pm->ps->velocity[ 0 ] + + pm->ps->velocity[ 1 ] * pm->ps->velocity[ 1 ] ); - if ( pm->ps->groundEntityNum == ENTITYNUM_NONE ) { + if( pm->ps->groundEntityNum == ENTITYNUM_NONE ) + { // airborne leaves position in cycle intact, but doesn't advance - if ( pm->waterlevel > 1 ) { + if( pm->waterlevel > 1 ) PM_ContinueLegsAnim( LEGS_SWIM ); - } + return; } // if not trying to move - if ( !pm->cmd.forwardmove && !pm->cmd.rightmove ) { - if ( pm->xyspeed < 5 ) { + if( !pm->cmd.forwardmove && !pm->cmd.rightmove ) + { + if( pm->xyspeed < 5 ) + { pm->ps->bobCycle = 0; // start at beginning of cycle again - if ( pm->ps->pm_flags & PMF_DUCKED ) { + if( pm->ps->pm_flags & PMF_DUCKED ) PM_ContinueLegsAnim( LEGS_IDLECR ); - } else { + else PM_ContinueLegsAnim( LEGS_IDLE ); - } } return; } @@ -1936,14 +1991,15 @@ static void PM_Footsteps( void ) { footstep = qfalse; - if ( pm->ps->pm_flags & PMF_DUCKED ) { + if( pm->ps->pm_flags & PMF_DUCKED ) + { bobmove = 0.5; // ducked characters bob much faster - if ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) { + + if( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) PM_ContinueLegsAnim( LEGS_BACKCR ); - } - else { + else PM_ContinueLegsAnim( LEGS_WALKCR ); - } + // ducked characters never play footsteps /* } else if ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) { @@ -1955,26 +2011,28 @@ static void PM_Footsteps( void ) { } PM_ContinueLegsAnim( LEGS_BACK ); */ - } else { + } + else + { //TA: switch walking/running anims based on speed //if ( !( pm->cmd.buttons & BUTTON_WALKING ) ) { - if ( pm->xyspeed > 160 ) { + if( pm->xyspeed > 160 ) + { bobmove = 0.4f; // faster speeds bob faster - if ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) { + if( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) PM_ContinueLegsAnim( LEGS_BACK ); - } - else { + else PM_ContinueLegsAnim( LEGS_RUN ); - } + footstep = qtrue; - } else { + } + else + { bobmove = 0.3f; // walking bobs slow - if ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) { + if( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) PM_ContinueLegsAnim( LEGS_BACKWALK ); - } - else { + else PM_ContinueLegsAnim( LEGS_WALK ); - } } } @@ -1983,21 +2041,27 @@ static void PM_Footsteps( void ) { pm->ps->bobCycle = (int)( old + bobmove * pml.msec ) & 255; // if we just crossed a cycle boundary, play an apropriate footstep event - if ( ( ( old + 64 ) ^ ( pm->ps->bobCycle + 64 ) ) & 128 ) { - if ( pm->waterlevel == 0 ) { + if( ( ( old + 64 ) ^ ( pm->ps->bobCycle + 64 ) ) & 128 ) + { + if( pm->waterlevel == 0 ) + { // on ground will only play sounds if running - if ( footstep && !pm->noFootsteps ) { - PM_AddEvent( PM_FootstepForSurface() ); - } - } else if ( pm->waterlevel == 1 ) { + if( footstep && !pm->noFootsteps ) + PM_AddEvent( PM_FootstepForSurface( ) ); + } + else if( pm->waterlevel == 1 ) + { // splashing PM_AddEvent( EV_FOOTSPLASH ); - } else if ( pm->waterlevel == 2 ) { + } + else if( pm->waterlevel == 2 ) + { // wading / swimming at surface PM_AddEvent( EV_SWIM ); - } else if ( pm->waterlevel == 3 ) { + } + else if( pm->waterlevel == 3 ) + { // no sound when completely underwater - } } } @@ -2009,34 +2073,32 @@ PM_WaterEvents Generate sound events for entering and leaving water ============== */ -static void PM_WaterEvents( void ) { // FIXME? +static void PM_WaterEvents( void ) +{ + // FIXME? // // if just entered a water volume, play a sound // - if (!pml.previous_waterlevel && pm->waterlevel) { + if( !pml.previous_waterlevel && pm->waterlevel ) PM_AddEvent( EV_WATER_TOUCH ); - } // // if just completely exited a water volume, play a sound // - if (pml.previous_waterlevel && !pm->waterlevel) { + if( pml.previous_waterlevel && !pm->waterlevel ) PM_AddEvent( EV_WATER_LEAVE ); - } // // check for head just going under water // - if (pml.previous_waterlevel != 3 && pm->waterlevel == 3) { + if( pml.previous_waterlevel != 3 && pm->waterlevel == 3 ) PM_AddEvent( EV_WATER_UNDER ); - } // // check for head just coming out of water // - if (pml.previous_waterlevel == 3 && pm->waterlevel != 3) { + if( pml.previous_waterlevel == 3 && pm->waterlevel != 3 ) PM_AddEvent( EV_WATER_CLEAR ); - } } @@ -2045,18 +2107,16 @@ static void PM_WaterEvents( void ) { // FIXME? PM_BeginWeaponChange =============== */ -static void PM_BeginWeaponChange( int weapon ) { - if ( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS ) { +static void PM_BeginWeaponChange( int weapon ) +{ + if( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS ) return; - } - if ( !BG_gotWeapon( weapon, pm->ps->stats ) && weapon != WP_NONE ) { + if( !BG_gotWeapon( weapon, pm->ps->stats ) && weapon != WP_NONE ) return; - } - if ( pm->ps->weaponstate == WEAPON_DROPPING ) { + if( pm->ps->weaponstate == WEAPON_DROPPING ) return; - } PM_AddEvent( EV_CHANGE_WEAPON ); pm->ps->weaponstate = WEAPON_DROPPING; @@ -2070,17 +2130,16 @@ static void PM_BeginWeaponChange( int weapon ) { PM_FinishWeaponChange =============== */ -static void PM_FinishWeaponChange( void ) { +static void PM_FinishWeaponChange( void ) +{ int weapon; weapon = pm->cmd.weapon; - if ( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS ) { + if( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS ) weapon = WP_NONE; - } - if ( !BG_gotWeapon( weapon, pm->ps->stats ) ) { + if( !BG_gotWeapon( weapon, pm->ps->stats ) ) weapon = WP_NONE; - } pm->ps->weapon = weapon; pm->ps->weaponstate = WEAPON_RAISING; @@ -2097,7 +2156,7 @@ PM_TorsoAnimation */ static void PM_TorsoAnimation( void ) { - if ( pm->ps->weaponstate == WEAPON_READY ) + if( pm->ps->weaponstate == WEAPON_READY ) PM_ContinueTorsoAnim( TORSO_STAND ); } @@ -2139,11 +2198,11 @@ static void PM_Weapon( void ) qboolean attack3 = qfalse; // don't allow attack until all buttons are up - if ( pm->ps->pm_flags & PMF_RESPAWNED ) + if( pm->ps->pm_flags & PMF_RESPAWNED ) return; // ignore if spectator - if ( pm->ps->persistant[PERS_TEAM] == TEAM_SPECTATOR ) + if( pm->ps->persistant[ PERS_TEAM ] == TEAM_SPECTATOR ) return; if( pm->ps->stats[ STAT_STATE ] & SS_INFESTING ) @@ -2156,16 +2215,15 @@ static void PM_Weapon( void ) return; // check for dead player - if ( pm->ps->stats[STAT_HEALTH] <= 0 ) + if( pm->ps->stats[ STAT_HEALTH ] <= 0 ) { pm->ps->weapon = WP_NONE; return; } // make weapon function - if ( pm->ps->weaponTime > 0 ) { + if( pm->ps->weaponTime > 0 ) pm->ps->weaponTime -= pml.msec; - } //TA: if we haven't got the weapon if( !BG_gotWeapon( pm->ps->weapon, pm->ps->stats ) && pm->ps->weapon != WP_NONE ) @@ -2433,9 +2491,12 @@ static void PM_Weapon( void ) PM_Animate ================ */ -static void PM_Animate( void ) { - if ( pm->cmd.buttons & BUTTON_GESTURE ) { - if ( pm->ps->torsoTimer == 0 ) { +static void PM_Animate( void ) +{ + if( pm->cmd.buttons & BUTTON_GESTURE ) + { + if( pm->ps->torsoTimer == 0 ) + { PM_StartTorsoAnim( TORSO_GESTURE ); pm->ps->torsoTimer = TIMER_GESTURE; PM_AddEvent( EV_TAUNT ); @@ -2449,30 +2510,35 @@ static void PM_Animate( void ) { PM_DropTimers ================ */ -static void PM_DropTimers( void ) { +static void PM_DropTimers( void ) +{ // drop misc timing counter - if ( pm->ps->pm_time ) { - if ( pml.msec >= pm->ps->pm_time ) { + if( pm->ps->pm_time ) + { + if( pml.msec >= pm->ps->pm_time ) + { pm->ps->pm_flags &= ~PMF_ALL_TIMES; pm->ps->pm_time = 0; - } else { - pm->ps->pm_time -= pml.msec; } + else + pm->ps->pm_time -= pml.msec; } // drop animation counter - if ( pm->ps->legsTimer > 0 ) { + if( pm->ps->legsTimer > 0 ) + { pm->ps->legsTimer -= pml.msec; - if ( pm->ps->legsTimer < 0 ) { + + if( pm->ps->legsTimer < 0 ) pm->ps->legsTimer = 0; - } } - if ( pm->ps->torsoTimer > 0 ) { + if( pm->ps->torsoTimer > 0 ) + { pm->ps->torsoTimer -= pml.msec; - if ( pm->ps->torsoTimer < 0 ) { + + if( pm->ps->torsoTimer < 0 ) pm->ps->torsoTimer = 0; - } } } @@ -2616,44 +2682,42 @@ void PmoveSingle (pmove_t *pmove) // make sure walking button is clear if they are running, to avoid // proxy no-footsteps cheats - if ( abs( pm->cmd.forwardmove ) > 64 || abs( pm->cmd.rightmove ) > 64 ) { + if( abs( pm->cmd.forwardmove ) > 64 || abs( pm->cmd.rightmove ) > 64 ) pm->cmd.buttons &= ~BUTTON_WALKING; - } // set the talk balloon flag - if ( pm->cmd.buttons & BUTTON_TALK ) { + if( pm->cmd.buttons & BUTTON_TALK ) pm->ps->eFlags |= EF_TALK; - } else { + else pm->ps->eFlags &= ~EF_TALK; - } // set the firing flag for continuous beam weapons - if ( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION - && ( pm->cmd.buttons & BUTTON_ATTACK ) - && ( ( ammo > 0 || clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) ) + if( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION && + ( pm->cmd.buttons & BUTTON_ATTACK ) && + ( ( ammo > 0 || clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) ) pm->ps->eFlags |= EF_FIRING; else pm->ps->eFlags &= ~EF_FIRING; // set the firing flag for continuous beam weapons - if ( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION - && ( pm->cmd.buttons & BUTTON_ATTACK2 ) - && ( ( ammo > 0 || clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) ) + if( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION && + ( pm->cmd.buttons & BUTTON_ATTACK2 ) && + ( ( ammo > 0 || clips > 0 ) || BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) ) pm->ps->eFlags |= EF_FIRING2; else pm->ps->eFlags &= ~EF_FIRING2; // clear the respawned flag if attack and use are cleared - if ( pm->ps->stats[STAT_HEALTH] > 0 && - !( pm->cmd.buttons & (BUTTON_ATTACK | BUTTON_USE_HOLDABLE) ) ) { + if( pm->ps->stats[STAT_HEALTH] > 0 && + !( pm->cmd.buttons & ( BUTTON_ATTACK | BUTTON_USE_HOLDABLE ) ) ) pm->ps->pm_flags &= ~PMF_RESPAWNED; - } // if talk button is down, dissallow all other input // this is to prevent any possible intercept proxy from // adding fake talk balloons - if ( pmove->cmd.buttons & BUTTON_TALK ) { + if( pmove->cmd.buttons & BUTTON_TALK ) + { pmove->cmd.buttons = BUTTON_TALK; pmove->cmd.forwardmove = 0; pmove->cmd.rightmove = 0; @@ -2661,38 +2725,39 @@ void PmoveSingle (pmove_t *pmove) } // clear all pmove local vars - memset (&pml, 0, sizeof(pml)); + memset( &pml, 0, sizeof( pml ) ); // determine the time pml.msec = pmove->cmd.serverTime - pm->ps->commandTime; - if ( pml.msec < 1 ) { + + if( pml.msec < 1 ) pml.msec = 1; - } else if ( pml.msec > 200 ) { + else if( pml.msec > 200 ) pml.msec = 200; - } + pm->ps->commandTime = pmove->cmd.serverTime; // save old org in case we get stuck - VectorCopy (pm->ps->origin, pml.previous_origin); + VectorCopy( pm->ps->origin, pml.previous_origin ); // save old velocity for crashlanding - VectorCopy (pm->ps->velocity, pml.previous_velocity); + VectorCopy( pm->ps->velocity, pml.previous_velocity ); pml.frametime = pml.msec * 0.001; AngleVectors( pm->ps->viewangles, pml.forward, pml.right, pml.up ); - if ( pm->cmd.upmove < 10 ) { + if( pm->cmd.upmove < 10 ) + { // not holding jump pm->ps->pm_flags &= ~PMF_JUMP_HELD; } // decide if backpedaling animations should be used - if ( pm->cmd.forwardmove < 0 ) { + if( pm->cmd.forwardmove < 0 ) pm->ps->pm_flags |= PMF_BACKWARDS_RUN; - } else if ( pm->cmd.forwardmove > 0 || ( pm->cmd.forwardmove == 0 && pm->cmd.rightmove ) ) { + else if( pm->cmd.forwardmove > 0 || ( pm->cmd.forwardmove == 0 && pm->cmd.rightmove ) ) pm->ps->pm_flags &= ~PMF_BACKWARDS_RUN; - } if ( pm->ps->pm_type >= PM_DEAD ) { @@ -2701,38 +2766,38 @@ void PmoveSingle (pmove_t *pmove) pm->cmd.upmove = 0; } - if ( pm->ps->pm_type == PM_SPECTATOR ) { + if( pm->ps->pm_type == PM_SPECTATOR ) + { // update the viewangles PM_UpdateViewAngles( pm->ps, &pm->cmd ); - PM_CheckDuck (); - PM_FlyMove (); - PM_DropTimers (); + PM_CheckDuck( ); + PM_FlyMove( ); + PM_DropTimers( ); return; } - if ( pm->ps->pm_type == PM_NOCLIP ) { - PM_NoclipMove (); - PM_DropTimers (); + if( pm->ps->pm_type == PM_NOCLIP ) + { + PM_NoclipMove( ); + PM_DropTimers( ); return; } - if (pm->ps->pm_type == PM_FREEZE) { + if( pm->ps->pm_type == PM_FREEZE) return; // no movement at all - } - if ( pm->ps->pm_type == PM_INTERMISSION || pm->ps->pm_type == PM_SPINTERMISSION ) { + if( pm->ps->pm_type == PM_INTERMISSION || pm->ps->pm_type == PM_SPINTERMISSION ) return; // no movement at all - } // set watertype, and waterlevel - PM_SetWaterLevel(); + PM_SetWaterLevel( ); pml.previous_waterlevel = pmove->waterlevel; // set mins, maxs, and viewheight - PM_CheckDuck (); + PM_CheckDuck( ); // set groundentity - PM_GroundTrace(); + PM_GroundTrace( ); // update the viewangles PM_UpdateViewAngles( pm->ps, &pm->cmd ); @@ -2798,46 +2863,44 @@ Pmove Can be called by either the server or the client ================ */ -void Pmove (pmove_t *pmove) { - int finalTime; +void Pmove( pmove_t *pmove ) +{ + int finalTime; finalTime = pmove->cmd.serverTime; - if ( finalTime < pmove->ps->commandTime ) { + if( finalTime < pmove->ps->commandTime ) return; // should not happen - } - if ( finalTime > pmove->ps->commandTime + 1000 ) { + if( finalTime > pmove->ps->commandTime + 1000 ) pmove->ps->commandTime = finalTime - 1000; - } - pmove->ps->pmove_framecount = (pmove->ps->pmove_framecount+1) & ((1<<PS_PMOVEFRAMECOUNTBITS)-1); + pmove->ps->pmove_framecount = ( pmove->ps->pmove_framecount + 1 ) & ( ( 1 << PS_PMOVEFRAMECOUNTBITS ) - 1 ); // chop the move up if it is too long, to prevent framerate // dependent behavior - while ( pmove->ps->commandTime != finalTime ) { + while( pmove->ps->commandTime != finalTime ) + { int msec; msec = finalTime - pmove->ps->commandTime; - if ( pmove->pmove_fixed ) { - if ( msec > pmove->pmove_msec ) { + if( pmove->pmove_fixed ) + { + if( msec > pmove->pmove_msec ) msec = pmove->pmove_msec; - } } - else { - if ( msec > 66 ) { + else + { + if( msec > 66 ) msec = 66; - } } pmove->cmd.serverTime = pmove->ps->commandTime + msec; PmoveSingle( pmove ); - if ( pmove->ps->pm_flags & PMF_JUMP_HELD ) { + if( pmove->ps->pm_flags & PMF_JUMP_HELD ) pmove->cmd.upmove = 20; - } } - } |