diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index 8d586570c..144b8480d 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -1,9 +1,9 @@ /*** * * Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. * All Rights Reserved. * * Use, distribution, and modification of this source code and/or resulting @@ -85,6 +85,7 @@ typedef struct hull_s #define VEC_HULL_MAX 36 #define VEC_VIEW 28 #define STOP_EPSILON 0.1 +#define DIST_EPSILON 0.125f // Max error from network coordinate quantization #define CTEXTURESMAX 512 // max number of textures loaded #define CBTEXTURENAMEMAX 13 // only load first n chars of name @@ -130,7 +131,7 @@ typedef struct hull_s // left / right #define YAW 1 // fall over -#define ROLL 2 +#define ROLL 2 #define MAX_CLIENTS 32 @@ -148,7 +149,7 @@ static int rgStuckLast[MAX_CLIENTS][2]; // Texture names static int gcTextures = 0; -static char grgszTextureName[CTEXTURESMAX][CBTEXTURENAMEMAX]; +static char grgszTextureName[CTEXTURESMAX][CBTEXTURENAMEMAX]; static char grgchTextureType[CTEXTURESMAX]; int g_onladder = 0; @@ -160,7 +161,7 @@ void PM_SwapTextures( int i, int j ) strcpy( szTemp, grgszTextureName[ i ] ); chTemp = grgchTextureType[ i ]; - + strcpy( grgszTextureName[ i ], grgszTextureName[ j ] ); grgchTextureType[ i ] = grgchTextureType[ j ]; @@ -218,7 +219,7 @@ void PM_InitTextureTypes() i = 0; while(buffer[i] && isspace(buffer[i])) i++; - + if (!buffer[i]) continue; @@ -232,7 +233,7 @@ void PM_InitTextureTypes() // skip whitespace while(buffer[i] && isspace(buffer[i])) i++; - + if (!buffer[i]) continue; @@ -302,7 +303,7 @@ void PM_PlayStepSound( int step, float fvol ) { return; } - + irand = pmove->RandomLong(0,1) + ( pmove->iStepLeft * 2 ); // FIXME mp_footsteps needs to be a movevar @@ -436,18 +437,18 @@ void PM_PlayStepSound( int step, float fvol ) } break; } -} +} int PM_MapTextureTypeStepType(char chTextureType) { switch (chTextureType) { default: - case CHAR_TEX_CONCRETE: return STEP_CONCRETE; - case CHAR_TEX_METAL: return STEP_METAL; - case CHAR_TEX_DIRT: return STEP_DIRT; - case CHAR_TEX_VENT: return STEP_VENT; - case CHAR_TEX_GRATE: return STEP_GRATE; + case CHAR_TEX_CONCRETE: return STEP_CONCRETE; + case CHAR_TEX_METAL: return STEP_METAL; + case CHAR_TEX_DIRT: return STEP_DIRT; + case CHAR_TEX_VENT: return STEP_VENT; + case CHAR_TEX_GRATE: return STEP_GRATE; case CHAR_TEX_TILE: return STEP_TILE; case CHAR_TEX_SLOSH: return STEP_SLOSH; } @@ -486,12 +487,12 @@ void PM_CatagorizeTextureType( void ) if (*pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ') pTextureName++; // '}}' - + strcpy( pmove->sztexturename, pTextureName); pmove->sztexturename[ CBTEXTURENAMEMAX - 1 ] = 0; - + // get texture type - pmove->chtexturetype = PM_FindTextureType( pmove->sztexturename ); + pmove->chtexturetype = PM_FindTextureType( pmove->sztexturename ); } void PM_UpdateStepSound( void ) @@ -522,7 +523,7 @@ void PM_UpdateStepSound( void ) // determine if we are on a ladder fLadder = ( pmove->movetype == MOVETYPE_FLY );// IsOnLadder(); - // UNDONE: need defined numbers for run, walk, crouch, crouch run velocities!!!! + // UNDONE: need defined numbers for run, walk, crouch, crouch run velocities!!!! if ( ( pmove->flags & FL_DUCKING) || fLadder ) { velwalk = 60; // These constants should be based on cl_movespeedkey * cl_forwardspeed somehow @@ -543,7 +544,7 @@ void PM_UpdateStepSound( void ) ( Length( pmove->velocity ) > 0.0 ) && ( speed >= velwalk || !pmove->flTimeStepSound ) ) { - fWalking = speed < velrun; + fWalking = speed < velrun; VectorCopy( pmove->origin, center ); VectorCopy( pmove->origin, knee ); @@ -571,33 +572,33 @@ void PM_UpdateStepSound( void ) { step = STEP_SLOSH; fvol = fWalking ? 0.2 : 0.5; - pmove->flTimeStepSound = fWalking ? 400 : 300; + pmove->flTimeStepSound = fWalking ? 400 : 300; } else { - // find texture under player, if different from current texture, + // find texture under player, if different from current texture, // get material type step = PM_MapTextureTypeStepType( pmove->chtexturetype ); switch ( pmove->chtexturetype ) { default: - case CHAR_TEX_CONCRETE: + case CHAR_TEX_CONCRETE: fvol = fWalking ? 0.2 : 0.5; pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_METAL: + case CHAR_TEX_METAL: fvol = fWalking ? 0.2 : 0.5; pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_DIRT: + case CHAR_TEX_DIRT: fvol = fWalking ? 0.25 : 0.55; pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_VENT: + case CHAR_TEX_VENT: fvol = fWalking ? 0.4 : 0.7; pmove->flTimeStepSound = fWalking ? 400 : 300; break; @@ -607,7 +608,7 @@ void PM_UpdateStepSound( void ) pmove->flTimeStepSound = fWalking ? 400 : 300; break; - case CHAR_TEX_TILE: + case CHAR_TEX_TILE: fvol = fWalking ? 0.2 : 0.5; pmove->flTimeStepSound = fWalking ? 400 : 300; break; @@ -618,7 +619,7 @@ void PM_UpdateStepSound( void ) break; } } - + pmove->flTimeStepSound += flduck; // slower step time if ducking // play the sound @@ -689,7 +690,7 @@ void PM_CheckVelocity () } // Bound it. - if (pmove->velocity[i] > pmove->movevars->maxvelocity) + if (pmove->velocity[i] > pmove->movevars->maxvelocity) { pmove->Con_DPrintf ("PM Got a velocity too high on %i\n", i); pmove->velocity[i] = pmove->movevars->maxvelocity; @@ -716,17 +717,17 @@ int PM_ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce) { float backoff; float change; - float angle; + float angle; int i, blocked; - + angle = normal[ 2 ]; blocked = 0x00; // Assume unblocked. if (angle > 0) // If the plane that is blocking us has a positive z component, then assume it's a floor. - blocked |= 0x01; // + blocked |= 0x01; // if (!angle) // If the plane has no Z, it is vertical (wall/step) - blocked |= 0x02; // - + blocked |= 0x02; // + // Determine how far along plane to slide based on incoming direction. // Scale by overbounce factor. backoff = DotProduct (in, normal) * overbounce; @@ -739,7 +740,17 @@ int PM_ClipVelocity (vec3_t in, vec3_t normal, vec3_t out, float overbounce) if (out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON) out[i] = 0; } - + + // iterate once to make sure we aren't still moving through the plane + float adjust = DotProduct(out, normal); + if (adjust <= 0.0f) + { + // min this against a small number (but no further from zero than -DIST_EPSILON) to account for crossing a plane with a near-parallel normal + adjust = min(adjust, -DIST_EPSILON); + for (i=0 ; i<3 ; i++) + out[i] -= normal[i]*adjust; + } + // Return blocking flags. return blocked; } @@ -757,7 +768,7 @@ void PM_AddCorrectGravity () ent_gravity = 1.0; // Add gravity so they'll be in the correct position during movement - // yes, this 0.5 looks wrong, but it's not. + // yes, this 0.5 looks wrong, but it's not. pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * 0.5 * pmove->frametime ); pmove->velocity[2] += pmove->basevelocity[2] * pmove->frametime; pmove->basevelocity[2] = 0; @@ -778,7 +789,7 @@ void PM_FixupGravityVelocity () else ent_gravity = 1.0; - // Get the correct velocity for the end of the dt + // Get the correct velocity for the end of the dt pmove->velocity[2] -= (ent_gravity * pmove->movevars->gravity * pmove->frametime * 0.5 ); PM_CheckVelocity(); @@ -805,14 +816,14 @@ int PM_FlyMove (void) vec3_t end; float time_left, allFraction; int blocked; - + numbumps = 4; // Bump up to four times - + blocked = 0; // Assume not blocked numplanes = 0; // and not sliding along any planes VectorCopy (pmove->velocity, original_velocity); // Store original velocity VectorCopy (pmove->velocity, primal_velocity); - + allFraction = 0; time_left = pmove->frametime; // Total time for this movement operation. @@ -841,7 +852,7 @@ int PM_FlyMove (void) } // If we moved some portion of the total distance, then - // copy the end position into the pmove->origin and + // copy the end position into the pmove->origin and // zero the plane counter. if (trace.fraction > 0) { // actually covered some distance @@ -869,7 +880,7 @@ int PM_FlyMove (void) { blocked |= 1; // floor } - // If the plane has a zero z component in the normal, then it's a + // If the plane has a zero z component in the normal, then it's a // step or wall if (!trace.plane.normal[2]) { @@ -880,7 +891,7 @@ int PM_FlyMove (void) // Reduce amount of pmove->frametime left by total time left * fraction // that we covered. time_left -= time_left * trace.fraction; - + // Did we run out of planes to clip against? if (numplanes >= MAX_CLIP_PLANES) { // this shouldn't really happen @@ -908,7 +919,7 @@ int PM_FlyMove (void) PM_ClipVelocity( original_velocity, planes[i], new_velocity, 1 ); VectorCopy( new_velocity, original_velocity ); } - else + else PM_ClipVelocity( original_velocity, planes[i], new_velocity, 1.0 + pmove->movevars->bounce * (1-pmove->friction) ); } @@ -934,12 +945,12 @@ int PM_FlyMove (void) if (j == numplanes) // Didn't have to clip, so we're ok break; } - + // Did we go all the way through plane set if (i != numplanes) { // go along this plane // pmove->velocity is set in clipping call, no need to set again. - ; + ; } else { // go along the crease @@ -1008,15 +1019,15 @@ void PM_Accelerate (vec3_t wishdir, float wishspeed, float accel) // Determine amount of accleration. accelspeed = accel * pmove->frametime * wishspeed * pmove->friction; - + // Cap at addspeed if (accelspeed > addspeed) accelspeed = addspeed; - + // Adjust velocity. for (i=0 ; i<3 ; i++) { - pmove->velocity[i] += accelspeed * wishdir[i]; + pmove->velocity[i] += accelspeed * wishdir[i]; } } @@ -1045,21 +1056,21 @@ void PM_WalkMove () float downdist, updist; pmtrace_t trace; - + // Copy movement amounts fmove = pmove->cmd.forwardmove; smove = pmove->cmd.sidemove; - + // Zero out z components of movement vectors pmove->forward[2] = 0; pmove->right[2] = 0; - + VectorNormalize (pmove->forward); // Normalize remainder of vectors. - VectorNormalize (pmove->right); // + VectorNormalize (pmove->right); // for (i=0 ; i<2 ; i++) // Determine x and y parts of velocity wishvel[i] = pmove->forward[i]*fmove + pmove->right[i]*smove; - + wishvel[2] = 0; // Zero out z part of velocity VectorCopy (wishvel, wishdir); // Determine maginitude of speed of move @@ -1096,9 +1107,9 @@ void PM_WalkMove () oldonground = pmove->onground; -// first try just moving to the destination +// first try just moving to the destination dest[0] = pmove->origin[0] + pmove->velocity[0]*pmove->frametime; - dest[1] = pmove->origin[1] + pmove->velocity[1]*pmove->frametime; + dest[1] = pmove->origin[1] + pmove->velocity[1]*pmove->frametime; dest[2] = pmove->origin[2]; // first try moving directly to the next spot @@ -1139,7 +1150,7 @@ void PM_WalkMove () // Start out up one stair height VectorCopy (pmove->origin, dest); dest[2] += pmove->movevars->stepsize; - + trace = pmove->PM_PlayerTrace (pmove->origin, dest, PM_NORMAL, -1 ); // If we started okay and made it part of the way at least, // copy the results to the movement start position and then @@ -1156,7 +1167,7 @@ void PM_WalkMove () // press down the stepheight VectorCopy (pmove->origin, dest); dest[2] -= pmove->movevars->stepsize; - + trace = pmove->PM_PlayerTrace (pmove->origin, dest, PM_NORMAL, -1 ); // If we are not on the ground any more then @@ -1202,17 +1213,17 @@ void PM_Friction (void) float friction; float drop; vec3_t newvel; - + // If we are in water jump cycle, don't apply friction if (pmove->waterjumptime) return; // Get velocity vel = pmove->velocity; - + // Calculate speed speed = sqrt(vel[0]*vel[0] +vel[1]*vel[1] + vel[2]*vel[2]); - + // If too slow, return if (speed < 0.1f) { @@ -1238,9 +1249,9 @@ void PM_Friction (void) friction = pmove->movevars->friction*pmove->movevars->edgefriction; else friction = pmove->movevars->friction; - + // Grab friction value. - //friction = pmove->movevars->friction; + //friction = pmove->movevars->friction; friction *= pmove->friction; // player friction? @@ -1276,7 +1287,7 @@ void PM_AirAccelerate (vec3_t wishdir, float wishspeed, float accel) { int i; float addspeed, accelspeed, currentspeed, wishspd = wishspeed; - + if (pmove->dead) return; if (pmove->waterjumptime) @@ -1284,7 +1295,7 @@ void PM_AirAccelerate (vec3_t wishdir, float wishspeed, float accel) // Cap speed //wishspd = VectorNormalize (pmove->wishveloc); - + if (wishspd > 30) wishspd = 30; // Determine veer amount @@ -1300,11 +1311,11 @@ void PM_AirAccelerate (vec3_t wishdir, float wishspeed, float accel) // Cap it if (accelspeed > addspeed) accelspeed = addspeed; - + // Adjust pmove vel. for (i=0 ; i<3 ; i++) { - pmove->velocity[i] += accelspeed*wishdir[i]; + pmove->velocity[i] += accelspeed*wishdir[i]; } } @@ -1398,7 +1409,7 @@ void PM_WaterMove (void) VectorCopy (trace.endpos, pmove->origin); return; } - + // Try moving straight along out normal path. PM_FlyMove (); } @@ -1421,7 +1432,7 @@ void PM_AirMove (void) // Copy movement amounts fmove = pmove->cmd.forwardmove; smove = pmove->cmd.sidemove; - + // Zero out z components of movement vectors pmove->forward[2] = 0; pmove->right[2] = 0; @@ -1430,15 +1441,15 @@ void PM_AirMove (void) VectorNormalize (pmove->right); // Determine x and y parts of velocity - for (i=0 ; i<2 ; i++) + for (i=0 ; i<2 ; i++) { wishvel[i] = pmove->forward[i]*fmove + pmove->right[i]*smove; } // Zero out z part of velocity - wishvel[2] = 0; + wishvel[2] = 0; // Determine maginitude of speed of move - VectorCopy (wishvel, wishdir); + VectorCopy (wishvel, wishdir); wishspeed = VectorNormalize(wishdir); // Clamp to server defined max speed @@ -1447,7 +1458,7 @@ void PM_AirMove (void) VectorScale (wishvel, pmove->maxspeed/wishspeed, wishvel); wishspeed = pmove->maxspeed; } - + PM_AirAccelerate (wishdir, wishspeed, pmove->movevars->airaccelerate); // Add in any base velocity to the current velocity. @@ -1480,7 +1491,7 @@ qboolean PM_CheckWater () point[0] = pmove->origin[0] + (pmove->player_mins[pmove->usehull][0] + pmove->player_maxs[pmove->usehull][0]) * 0.5; point[1] = pmove->origin[1] + (pmove->player_mins[pmove->usehull][1] + pmove->player_maxs[pmove->usehull][1]) * 0.5; point[2] = pmove->origin[2] + pmove->player_mins[pmove->usehull][2] + 1; - + // Assume that we are not in water at all. pmove->waterlevel = 0; pmove->watertype = CONTENTS_EMPTY; @@ -1512,7 +1523,7 @@ qboolean PM_CheckWater () point[2] = pmove->origin[2] + pmove->view_ofs[2]; cont = pmove->PM_PointContents (point, NULL ); - if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) + if (cont <= CONTENTS_WATER && cont > CONTENTS_TRANSLUCENT ) pmove->waterlevel = 3; // In over our eyes } @@ -1547,7 +1558,7 @@ void PM_CatagorizePosition (void) // if the player hull point one unit down is solid, the player // is on ground -// see if standing on something solid +// see if standing on something solid // Doing this before we move may introduce a potential latency in water detection, but // doing it after can get us stuck on the bottom in water if the amount we move up @@ -1650,9 +1661,9 @@ int PM_CheckStuck (void) VectorCopy (pmove->origin, base); - // + // // Deal with precision error in network. - // + // if (!pmove->server) { // World or BSP model @@ -1661,7 +1672,7 @@ int PM_CheckStuck (void) { int nReps = 0; PM_ResetStuckOffsets( pmove->player_index, pmove->server ); - do + do { i = PM_GetRandomStuckOffsets(pmove->player_index, pmove->server, offset); @@ -1669,7 +1680,7 @@ int PM_CheckStuck (void) if (pmove->PM_TestPlayerPosition (test, &traceresult ) == -1) { PM_ResetStuckOffsets( pmove->player_index, pmove->server ); - + VectorCopy ( test, pmove->origin ); return 0; } @@ -1687,7 +1698,7 @@ int PM_CheckStuck (void) fTime = pmove->Sys_FloatTime(); // Too soon? - if (rgStuckCheckTime[pmove->player_index][idx] >= + if (rgStuckCheckTime[pmove->player_index][idx] >= ( fTime - PM_CHECKSTUCK_MINTIME ) ) { return 1; @@ -1720,7 +1731,7 @@ int PM_CheckStuck (void) float zstep = 18.0; float xyminmax = xystep; float zminmax = 4 * zstep; - + for ( z = 0; z <= zminmax; z += zstep ) { for ( x = -xyminmax; x <= xyminmax; x += xystep ) @@ -1766,7 +1777,7 @@ void PM_SpectatorMove (void) // there a two different main move types : track player or moce freely (OBS_ROAMING) // doesn't need excate track position, only to generate PVS, so just copy // targets position and real view position is calculated on client (saves server CPU) - + if ( pmove->iuser1 == OBS_ROAMING) { @@ -1782,7 +1793,7 @@ void PM_SpectatorMove (void) } #endif // Move around in normal spectator method - + speed = Length (pmove->velocity); if (speed < 1) { @@ -1808,7 +1819,7 @@ void PM_SpectatorMove (void) // accelerate fmove = pmove->cmd.forwardmove; smove = pmove->cmd.sidemove; - + VectorNormalize (pmove->forward); VectorNormalize (pmove->right); @@ -1838,9 +1849,9 @@ void PM_SpectatorMove (void) accelspeed = pmove->movevars->accelerate*pmove->frametime*wishspeed; if (accelspeed > addspeed) accelspeed = addspeed; - + for (i=0 ; i<3 ; i++) - pmove->velocity[i] += accelspeed*wishdir[i]; + pmove->velocity[i] += accelspeed*wishdir[i]; // move VectorMA (pmove->origin, pmove->frametime, pmove->velocity, pmove->origin); @@ -1902,8 +1913,8 @@ void PM_FixPlayerCrouchStuck( int direction ) hitent = pmove->PM_TestPlayerPosition ( pmove->origin, NULL ); if (hitent == -1 ) return; - - VectorCopy( pmove->origin, test ); + + VectorCopy( pmove->origin, test ); for ( i = 0; i < 36; i++ ) { pmove->origin[2] += direction; @@ -1930,7 +1941,7 @@ void PM_UnDuck( void ) newOrigin[i] += ( pmove->player_mins[1][i] - pmove->player_mins[0][i] ); } } - + trace = pmove->PM_PlayerTrace( newOrigin, newOrigin, PM_NORMAL, -1 ); if ( !trace.startsolid ) @@ -1951,7 +1962,7 @@ void PM_UnDuck( void ) pmove->bInDuck = false; pmove->view_ofs[2] = VEC_VIEW; pmove->flDuckTime = 0; - + VectorCopy( newOrigin, pmove->origin ); // Recatagorize position since ducking can change origin @@ -2010,7 +2021,7 @@ void PM_Duck( void ) } time = max( 0.0, ( 1.0 - (float)pmove->flDuckTime / 1000.0 ) ); - + if ( pmove->bInDuck ) { // Finish ducking immediately if duck time is over or not on ground @@ -2064,7 +2075,7 @@ void PM_LadderMove( physent_t *pLadder ) if ( pmove->movetype == MOVETYPE_NOCLIP ) return; - + #if defined( _TFC ) // this is how TFC freezes players, so we don't want them climbing ladders if ( pmove->maxspeed <= 1.0 ) @@ -2145,7 +2156,7 @@ void PM_LadderMove( physent_t *pLadder ) VectorScale( vpn, forward, velocity ); VectorMA( velocity, right, v_right, velocity ); - + // Perpendicular in the ladder plane // Vector perp = CrossProduct( Vector(0,0,1), trace.vecPlaneNormal ); // perp = perp.Normalize(); @@ -2196,7 +2207,7 @@ physent_t *PM_Ladder( void ) for ( i = 0; i < pmove->nummoveent; i++ ) { pe = &pmove->moveents[i]; - + if ( pe->model && (modtype_t)pmove->PM_GetModelType( pe->model ) == mod_brush && pe->skin == CONTENTS_LADDER ) { @@ -2209,7 +2220,7 @@ physent_t *PM_Ladder( void ) // Test the player's hull for intersection with this model if ( pmove->PM_HullPointContents (hull, num, test) == CONTENTS_EMPTY) continue; - + return pe; } } @@ -2273,11 +2284,11 @@ pmtrace_t PM_PushEntity (vec3_t push) { pmtrace_t trace; vec3_t end; - + VectorAdd (pmove->origin, push, end); trace = pmove->PM_PlayerTrace (pmove->origin, end, PM_NORMAL, -1 ); - + VectorCopy (trace.endpos, pmove->origin); // So we can run impact function afterwards. @@ -2288,7 +2299,7 @@ pmtrace_t PM_PushEntity (vec3_t push) } return trace; -} +} /* ============ @@ -2328,7 +2339,7 @@ void PM_Physics_Toss() // Base velocity is not properly accounted for since this entity will move again after the bounce without // taking it into account VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity); - + PM_CheckVelocity(); VectorScale (pmove->velocity, pmove->frametime, move); VectorSubtract (pmove->velocity, pmove->basevelocity, pmove->velocity); @@ -2338,13 +2349,13 @@ void PM_Physics_Toss() PM_CheckVelocity(); if (trace.allsolid) - { + { // entity is trapped in another solid pmove->onground = trace.ent; VectorCopy (vec3_origin, pmove->velocity); return; } - + if (trace.fraction == 1) { PM_CheckWater(); @@ -2363,7 +2374,7 @@ void PM_Physics_Toss() // stop if on ground if (trace.plane.normal[2] > 0.7) - { + { float vel; vec3_t base; @@ -2391,7 +2402,7 @@ void PM_Physics_Toss() } VectorSubtract( pmove->velocity, base, pmove->velocity ) } - + // check for in water PM_CheckWater(); } @@ -2412,8 +2423,8 @@ void PM_NoClip() // Copy movement amounts fmove = pmove->cmd.forwardmove; smove = pmove->cmd.sidemove; - - VectorNormalize ( pmove->forward ); + + VectorNormalize ( pmove->forward ); VectorNormalize ( pmove->right ); for (i=0 ; i<3 ; i++) // Determine x and y parts of velocity @@ -2423,7 +2434,7 @@ void PM_NoClip() wishvel[2] += pmove->cmd.upmove; VectorMA (pmove->origin, pmove->frametime, wishvel, pmove->origin); - + // Zero out the velocity so that we don't accumulate a huge downward velocity from // gravity, etc. VectorClear( pmove->velocity ); @@ -2460,7 +2471,7 @@ void PM_PreventMegaBunnyJumping( void ) return; fraction = ( maxscaledspeed / spd ) * 0.65; //Returns the modifier for the velocity - + VectorScale( pmove->velocity, fraction, pmove->velocity ); //Crop it down!. } @@ -2485,7 +2496,7 @@ void PM_Jump (void) tfc = atoi( pmove->PM_Info_ValueForKey( pmove->physinfo, "tfc" ) ) == 1 ? true : false; // Spy that's feigning death cannot jump - if ( tfc && + if ( tfc && ( pmove->deadflag == ( DEAD_DISCARDBODY + 1 ) ) ) { return; @@ -2520,7 +2531,7 @@ void PM_Jump (void) // Don't play sound again for 1 second pmove->flSwimTime = 1000; switch ( pmove->RandomLong( 0, 3 ) ) - { + { case 0: pmove->PM_PlaySound( CHAN_BODY, "player/pl_wade1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); break; @@ -2586,7 +2597,7 @@ void PM_Jump (void) { pmove->velocity[i] = pmove->forward[i] * PLAYER_LONGJUMP_SPEED * 1.6; } - + pmove->velocity[2] = sqrt(2 * 800 * 56.0); } else @@ -2636,7 +2647,7 @@ void PM_CheckWaterJump (void) // Must be moving curspeed = VectorNormalize( flatvelocity ); - + // see if near an edge flatforward[0] = pmove->forward[0]; flatforward[1] = pmove->forward[1]; @@ -2651,7 +2662,7 @@ void PM_CheckWaterJump (void) vecStart[2] += WJ_HEIGHT; VectorMA ( vecStart, 24, flatforward, vecEnd ); - + // Trace, this trace should use the point sized collision hull savehull = pmove->usehull; pmove->usehull = 2; @@ -2689,7 +2700,7 @@ void PM_CheckFalling( void ) } else if ( pmove->flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED ) { - // NOTE: In the original game dll , there were no breaks after these cases, causing the first one to + // NOTE: In the original game dll , there were no breaks after these cases, causing the first one to // cascade into the second //switch ( RandomLong(0,1) ) //{ @@ -2723,9 +2734,9 @@ void PM_CheckFalling( void ) { // Play landing step right away pmove->flTimeStepSound = 0; - + PM_UpdateStepSound(); - + // play step sound for current texture PM_PlayStepSound( PM_MapTextureTypeStepType( pmove->chtexturetype ), fvol ); @@ -2739,8 +2750,8 @@ void PM_CheckFalling( void ) } } - if ( pmove->onground != -1 ) - { + if ( pmove->onground != -1 ) + { pmove->flFallVelocity = 0; } } @@ -2787,17 +2798,17 @@ float PM_CalcRoll (vec3_t angles, vec3_t velocity, float rollangle, float rollsp float side; float value; vec3_t forward, right, up; - + AngleVectors (angles, forward, right, up); - + side = DotProduct (velocity, right); - + sign = side < 0 ? -1 : 1; - + side = fabs(side); - + value = rollangle; - + if (side < rollspeed) { side = side * value / rollspeed; @@ -2806,7 +2817,7 @@ float PM_CalcRoll (vec3_t angles, vec3_t velocity, float rollangle, float rollsp { side = value; } - + return side * sign; } @@ -2819,7 +2830,7 @@ PM_DropPunchAngle void PM_DropPunchAngle ( vec3_t punchangle ) { float len; - + len = VectorNormalize ( punchangle ); len -= (10.0 + len * 0.5) * pmove->frametime; len = max( len, 0.0 ); @@ -2859,7 +2870,7 @@ void PM_CheckParamters( void ) } if ( pmove->flags & FL_FROZEN || - pmove->flags & FL_ONTRAIN || + pmove->flags & FL_ONTRAIN || pmove->dead ) { pmove->cmd.forwardmove = 0; @@ -2873,7 +2884,7 @@ void PM_CheckParamters( void ) // Take angles from command. if ( !pmove->dead ) { - VectorCopy ( pmove->cmd.viewangles, v_angle ); + VectorCopy ( pmove->cmd.viewangles, v_angle ); VectorAdd( v_angle, pmove->punchangle, v_angle ); // Set up view angles. @@ -2943,16 +2954,16 @@ void PM_PlayerMove ( qboolean server ) physent_t *pLadder = NULL; // Are we running server code? - pmove->server = server; + pmove->server = server; // Adjust speeds etc. PM_CheckParamters(); // Assume we don't touch anything - pmove->numtouch = 0; + pmove->numtouch = 0; // # of msec to apply movement - pmove->frametime = pmove->cmd.msec * 0.001; + pmove->frametime = pmove->cmd.msec * 0.001; PM_ReduceTimers(); @@ -3004,7 +3015,7 @@ void PM_PlayerMove ( qboolean server ) PM_UpdateStepSound(); PM_Duck(); - + // Don't run ladder code if dead or on a train if ( !pmove->dead && !(pmove->flags & FL_ONTRAIN) ) { @@ -3049,7 +3060,7 @@ void PM_PlayerMove ( qboolean server ) break; case MOVETYPE_FLY: - + PM_CheckWater(); // Was jump button pressed? @@ -3066,7 +3077,7 @@ void PM_PlayerMove ( qboolean server ) { pmove->oldbuttons &= ~IN_JUMP; } - + // Perform the move accounting for any base velocity. VectorAdd (pmove->velocity, pmove->basevelocity, pmove->velocity); PM_FlyMove (); @@ -3092,7 +3103,7 @@ void PM_PlayerMove ( qboolean server ) // If we are swimming in the water, see if we are nudging against a place we can jump up out // of, and, if so, start out jump. Otherwise, if we are not moving up, then reset jump timer to 0 - if ( pmove->waterlevel >= 2 ) + if ( pmove->waterlevel >= 2 ) { if ( pmove->waterlevel == 2 ) { @@ -3117,7 +3128,7 @@ void PM_PlayerMove ( qboolean server ) // Perform regular water movement PM_WaterMove(); - + VectorSubtract (pmove->velocity, pmove->basevelocity, pmove->velocity); // Get a final position @@ -3140,7 +3151,7 @@ void PM_PlayerMove ( qboolean server ) pmove->oldbuttons &= ~IN_JUMP; } - // Fricion is handled before we add in any base velocity. That way, if we are on a conveyor, + // Fricion is handled before we add in any base velocity. That way, if we are on a conveyor, // we don't slow when standing still, relative to the conveyor. if ( pmove->onground != -1 ) { @@ -3168,7 +3179,7 @@ void PM_PlayerMove ( qboolean server ) // Base velocity is set if you are on a moving object, like // a conveyor (or maybe another monster?) VectorSubtract (pmove->velocity, pmove->basevelocity, pmove->velocity ); - + // Make sure velocity is valid. PM_CheckVelocity(); @@ -3289,7 +3300,7 @@ void PM_CreateStuckTable( void ) for (i = 0 ; i < 3; i++) { z = zi[i]; - + for (x = -2.0f ; x <= 2.0f ; x += 2.0f) { for (y = -2.0f ; y <= 2.0f ; y += 2.0) @@ -3306,7 +3317,7 @@ void PM_CreateStuckTable( void ) /* -This modume implements the shared player physics code between any particular game and +This modume implements the shared player physics code between any particular game and the engine. The same PM_Move routine is built into the game .dll and the client .dll and is invoked by each side as appropriate. There should be no distinction, internally, between server and client. This will ensure that prediction behaves appropriately. @@ -3317,7 +3328,7 @@ void PM_Move ( struct playermove_s *ppmove, int server ) assert( pm_shared_initialized ); pmove = ppmove; - + PM_PlayerMove( ( server != 0 ) ? true : false ); if ( pmove->onground != -1 )