diff --git a/code/botlib/be_aas_move.c b/code/botlib/be_aas_move.c index 8ff56aa99b..b373d9f8fb 100644 --- a/code/botlib/be_aas_move.c +++ b/code/botlib/be_aas_move.c @@ -840,9 +840,9 @@ int AAS_ClientMovementPrediction(struct aas_clientmove_s *move, if (swimming) delta = 0; // never take falling damage if completely underwater /* - if (ent->waterlevel == 3) return; - if (ent->waterlevel == 2) delta *= 0.25; - if (ent->waterlevel == 1) delta *= 0.5; + if (ent->waterlevel == WATERLEVEL_SUBMERGED) return; + if (ent->waterlevel == WATERLEVEL_HALFWAY) delta *= 0.25; + if (ent->waterlevel == WATERLEVEL_FEET) delta *= 0.5; */ if (delta > 40) { diff --git a/code/cgame/cg_event.c b/code/cgame/cg_event.c index 131be74217..1189f607ae 100644 --- a/code/cgame/cg_event.c +++ b/code/cgame/cg_event.c @@ -441,7 +441,7 @@ int CG_WaterLevel(centity_t *cent) { // // get waterlevel, accounting for ducking // - waterlevel = 0; + waterlevel = WATERLEVEL_NONE; point[0] = cent->lerpOrigin[0]; point[1] = cent->lerpOrigin[1]; @@ -451,17 +451,17 @@ int CG_WaterLevel(centity_t *cent) { if (contents & MASK_WATER) { sample2 = viewheight - MINS_Z; sample1 = sample2 / 2; - waterlevel = 1; + waterlevel = WATERLEVEL_FEET; point[2] = cent->lerpOrigin[2] + MINS_Z + sample1; contents = CG_PointContents(point, -1); if (contents & MASK_WATER) { - waterlevel = 2; + waterlevel = WATERLEVEL_HALFWAY; point[2] = cent->lerpOrigin[2] + MINS_Z + sample2; contents = CG_PointContents(point, -1); if (contents & MASK_WATER) { - waterlevel = 3; + waterlevel = WATERLEVEL_SUBMERGED; } } } @@ -494,7 +494,7 @@ void CG_PainEvent( centity_t *cent, int health ) { snd = "*pain100_1.wav"; } // play a gurp sound instead of a normal pain sound - if (CG_WaterLevel(cent) == 3) { + if (CG_WaterLevel(cent) == WATERLEVEL_SUBMERGED) { if (rand()&1) { trap_S_StartSound(NULL, cent->currentState.number, CHAN_VOICE, CG_CustomSound(cent->currentState.number, "sound/player/gurp1.wav")); } else { @@ -1169,7 +1169,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { case EV_DEATH3: DEBUGNAME("EV_DEATHx"); - if (CG_WaterLevel(cent) == 3) { + if (CG_WaterLevel(cent) == WATERLEVEL_SUBMERGED) { trap_S_StartSound(NULL, es->number, CHAN_VOICE, CG_CustomSound(es->number, "*drown.wav")); } else { trap_S_StartSound(NULL, es->number, CHAN_VOICE, CG_CustomSound(es->number, va("*death%i.wav", event - EV_DEATH1 + 1))); diff --git a/code/game/bg_pmove.c b/code/game/bg_pmove.c index c754174339..f97f22d6c0 100644 --- a/code/game/bg_pmove.c +++ b/code/game/bg_pmove.c @@ -192,7 +192,7 @@ static void PM_Friction( void ) { drop = 0; // apply ground friction - if ( pm->waterlevel <= 1 ) { + if ( pm->waterlevel <= WATERLEVEL_FEET ) { if ( pml.walking && !(pml.groundTrace.surfaceFlags & SURF_SLICK) ) { // if getting knocked back, no friction if ( ! (pm->ps->pm_flags & PMF_TIME_KNOCKBACK) ) { @@ -406,7 +406,7 @@ static qboolean PM_CheckWaterJump( void ) { } // check for water jump - if ( pm->waterlevel != 2 ) { + if ( pm->waterlevel != WATERLEVEL_HALFWAY ) { return qfalse; } @@ -699,7 +699,7 @@ static void PM_WalkMove( void ) { float accelerate; float vel; - if ( pm->waterlevel > 2 && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) { + if ( pm->waterlevel > WATERLEVEL_HALFWAY && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) { // begin swimming PM_WaterMove(); return; @@ -708,7 +708,7 @@ static void PM_WalkMove( void ) { if ( PM_CheckJump () ) { // jumped away - if ( pm->waterlevel > 1 ) { + if ( pm->waterlevel > WATERLEVEL_FEET ) { PM_WaterMove(); } else { PM_AirMove(); @@ -960,15 +960,15 @@ static void PM_CrashLand( void ) { } // never take falling damage if completely underwater - if ( pm->waterlevel == 3 ) { + if ( pm->waterlevel == WATERLEVEL_SUBMERGED ) { return; } // reduce falling damage if there is standing water - if ( pm->waterlevel == 2 ) { + if ( pm->waterlevel == WATERLEVEL_HALFWAY ) { delta *= 0.25; } - if ( pm->waterlevel == 1 ) { + if ( pm->waterlevel == WATERLEVEL_FEET ) { delta *= 0.5; } @@ -1210,7 +1210,7 @@ static void PM_SetWaterLevel( void ) { // // get waterlevel, accounting for ducking // - pm->waterlevel = 0; + pm->waterlevel = WATERLEVEL_NONE; pm->watertype = 0; point[0] = pm->ps->origin[0]; @@ -1223,15 +1223,15 @@ static void PM_SetWaterLevel( void ) { sample1 = sample2 / 2; pm->watertype = cont; - pm->waterlevel = 1; + pm->waterlevel = WATERLEVEL_FEET; point[2] = pm->ps->origin[2] + MINS_Z + sample1; cont = pm->pointcontents (point, pm->ps->clientNum ); if ( cont & MASK_WATER ) { - pm->waterlevel = 2; + pm->waterlevel = WATERLEVEL_HALFWAY; point[2] = pm->ps->origin[2] + MINS_Z + sample2; cont = pm->pointcontents (point, pm->ps->clientNum ); if ( cont & MASK_WATER ){ - pm->waterlevel = 3; + pm->waterlevel = WATERLEVEL_SUBMERGED; } } } @@ -1336,7 +1336,7 @@ static void PM_Footsteps( void ) { PM_ContinueLegsAnim( LEGS_IDLECR ); } // airborne leaves position in cycle intact, but doesn't advance - if ( pm->waterlevel > 1 ) { + if ( pm->waterlevel > WATERLEVEL_FEET ) { PM_ContinueLegsAnim( LEGS_SWIM ); } return; @@ -1404,18 +1404,18 @@ static void PM_Footsteps( void ) { // if we just crossed a cycle boundary, play an appropriate footstep event if ( ( ( old + 64 ) ^ ( pm->ps->bobCycle + 64 ) ) & 128 ) { - if ( pm->waterlevel == 0 ) { + if ( pm->waterlevel == WATERLEVEL_NONE ) { // on ground will only play sounds if running if ( footstep && !pm->noFootsteps ) { PM_AddEvent( PM_FootstepForSurface() ); } - } else if ( pm->waterlevel == 1 ) { + } else if ( pm->waterlevel == WATERLEVEL_FEET ) { // splashing PM_AddEvent( EV_FOOTSPLASH ); - } else if ( pm->waterlevel == 2 ) { + } else if ( pm->waterlevel == WATERLEVEL_HALFWAY ) { // wading / swimming at surface PM_AddEvent( EV_SWIM ); - } else if ( pm->waterlevel == 3 ) { + } else if ( pm->waterlevel == WATERLEVEL_SUBMERGED ) { // no sound when completely underwater } @@ -1447,14 +1447,14 @@ static void PM_WaterEvents( void ) { // FIXME? // // check for head just going under water // - if (pml.previous_waterlevel != 3 && pm->waterlevel == 3) { + if (pml.previous_waterlevel != WATERLEVEL_SUBMERGED && pm->waterlevel == WATERLEVEL_SUBMERGED) { 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 == WATERLEVEL_SUBMERGED && pm->waterlevel != WATERLEVEL_SUBMERGED) { PM_AddEvent( EV_WATER_CLEAR ); } } @@ -1842,7 +1842,7 @@ void PmoveSingle (pmove_t *pmove) { // clear results pm->numtouch = 0; pm->watertype = 0; - pm->waterlevel = 0; + pm->waterlevel = WATERLEVEL_NONE; if ( pm->ps->stats[STAT_HEALTH] <= 0 ) { pm->tracemask &= ~CONTENTS_BODY; // corpses can fly through bodies @@ -1981,7 +1981,7 @@ void PmoveSingle (pmove_t *pmove) { PM_AirMove(); } else if (pm->ps->pm_flags & PMF_TIME_WATERJUMP) { PM_WaterJumpMove(); - } else if ( pm->waterlevel > 1 ) { + } else if ( pm->waterlevel > WATERLEVEL_FEET ) { // swimming PM_WaterMove(); } else if ( pml.walking ) { diff --git a/code/game/bg_public.h b/code/game/bg_public.h index 7d203fb08e..ba34d32e19 100644 --- a/code/game/bg_public.h +++ b/code/game/bg_public.h @@ -161,6 +161,12 @@ typedef enum { #define PMF_ALL_TIMES (PMF_TIME_WATERJUMP|PMF_TIME_LAND|PMF_TIME_KNOCKBACK) +// pmove->waterlevel +#define WATERLEVEL_NONE 0 // no water at all +#define WATERLEVEL_FEET 1 // just the feet are under water +#define WATERLEVEL_HALFWAY 2 // wading / swimming at surface +#define WATERLEVEL_SUBMERGED 3 // fully underwater (max possible waterlevel) + #define MAXTOUCH 32 typedef struct { // state (in / out) diff --git a/code/game/g_active.c b/code/game/g_active.c index 8c9a784863..fa8805d0bc 100644 --- a/code/game/g_active.c +++ b/code/game/g_active.c @@ -112,7 +112,7 @@ void P_WorldEffects( gentity_t *ent ) { // // check for drowning // - if ( waterlevel == 3 ) { + if ( waterlevel == WATERLEVEL_SUBMERGED ) { // envirosuit give air if ( envirosuit ) { ent->client->airOutTime = level.time + 10000; diff --git a/code/game/g_client.c b/code/game/g_client.c index c6a0e87484..0656d52394 100644 --- a/code/game/g_client.c +++ b/code/game/g_client.c @@ -1155,7 +1155,7 @@ void ClientSpawn(gentity_t *ent) { ent->r.contents = CONTENTS_BODY; ent->clipmask = MASK_PLAYERSOLID; ent->die = player_die; - ent->waterlevel = 0; + ent->waterlevel = WATERLEVEL_NONE; ent->watertype = 0; ent->flags = 0;