Skip to content

Commit

Permalink
Merge pull request #380 from fortressforever/remove-ternary-expressions
Browse files Browse the repository at this point in the history
Remove ternary expressions in FF code
  • Loading branch information
AdamWillden committed Oct 31, 2020
2 parents 7b18980 + 843f890 commit 6d4fe49
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cl_dll/ff/ff_fx_railbeam.cpp
Expand Up @@ -75,7 +75,7 @@ void CFFFXRailBeam::Draw(double frametime)
//-----------------------------------------------------------------------------
bool CFFFXRailBeam::IsActive()
{
return (m_flStartTime + FIRE_TIME > gpGlobals->curtime) ? true : false;
return m_flStartTime + FIRE_TIME > gpGlobals->curtime;
}

//-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion dlls/ff/ff_bot_temp.cpp
Expand Up @@ -716,7 +716,7 @@ void Bot_UpdateDirection( CFFBot *pBot )
angle.y += 360;

pBot->m_flNextTurnTime = gpGlobals->curtime + 2.0;
pBot->m_bLastTurnToRight = random->RandomInt( 0, 1 ) == 0 ? true : false;
pBot->m_bLastTurnToRight = random->RandomInt( 0, 1 ) == 0;

pBot->m_ForwardAngle = angle;
pBot->m_LastAngles = angle;
Expand Down
2 changes: 1 addition & 1 deletion dlls/ff/ff_client.cpp
Expand Up @@ -169,7 +169,7 @@ void GameStartFrame( void )
if ( g_fGameOver )
return;

gpGlobals->teamplay = teamplay.GetInt() ? true : false;
gpGlobals->teamplay = !!teamplay.GetInt();
#ifdef _DEBUG
Bot_RunAll();
#endif
Expand Down
4 changes: 2 additions & 2 deletions dlls/ff/ff_lualib_globals.cpp
Expand Up @@ -180,7 +180,7 @@ namespace FFLib
bool IsGrenade(CBaseEntity* pEntity)
{
// Yeah, the simple life, man
return ( pEntity->GetFlags() & FL_GRENADE ) ? true : false;
return !!( pEntity->GetFlags() & FL_GRENADE );
/*
return (IsOfClass(pEntity, CLASS_GREN) ||
IsOfClass(pEntity, CLASS_GREN_EMP) ||
Expand Down Expand Up @@ -668,7 +668,7 @@ namespace FFLib

bool IsPlayer( CBaseEntity *pEntity )
{
return GetPlayer( pEntity ) == NULL ? false : true;
return GetPlayer( pEntity ) != NULL;
}

CFFInfoScript* GetInfoScriptByName(const char* entityName)
Expand Down
2 changes: 1 addition & 1 deletion dlls/ff/ff_player.cpp
Expand Up @@ -3119,7 +3119,7 @@ void CFFPlayer::FindRadioTaggedPlayers( void )
// We're left w/ a player who's within range
// Add player to a list and send off to client

m_hRadioTagData->Set( pPlayer->entindex(), true, pPlayer->GetClassSlot(), pPlayer->GetTeamNumber(), ( pPlayer->GetFlags() & FL_DUCKING ) ? true : false, vecPlayerOrigin );
m_hRadioTagData->Set( pPlayer->entindex(), true, pPlayer->GetClassSlot(), pPlayer->GetTeamNumber(), !!( pPlayer->GetFlags() & FL_DUCKING ), vecPlayerOrigin );

Omnibot::Notify_RadioTagUpdate(this, pPlayer);
}
Expand Down
36 changes: 18 additions & 18 deletions dlls/ff/ff_player.h
Expand Up @@ -513,7 +513,7 @@ class CFFPlayer : public CBasePlayer, public IFFPlayerAnimStateHelpers
}
bool LuaIsPlayerFrozen()
{
return ( GetFlags() & FL_FROZEN ) ? true : false;
return !!( GetFlags() & FL_FROZEN );
}
void LuaLockPlayerInPlace( bool _lock )
{
Expand Down Expand Up @@ -922,23 +922,23 @@ class CFFPlayer : public CBasePlayer, public IFFPlayerAnimStateHelpers

public:
// Some luabind functions
bool IsInAttack1( void ) const { return ( m_nButtons & IN_ATTACK ) ? true : false; }
bool IsInAttack2( void ) const { return ( m_nButtons & IN_ATTACK2 ) ? true : false; }
bool IsInUse( void ) const { return ( m_nButtons & IN_USE ) ? true : false; }
bool IsInJump( void ) const { return ( m_nButtons & IN_JUMP ) ? true : false; }
bool IsInForward( void ) const { return ( m_nButtons & IN_FORWARD ) ? true : false; }
bool IsInBack( void ) const { return ( m_nButtons & IN_BACK ) ? true : false; }
bool IsInMoveLeft( void ) const { return ( m_nButtons & IN_MOVELEFT ) ? true : false; }
bool IsInMoveRight( void ) const { return ( m_nButtons & IN_MOVERIGHT ) ? true : false; }
bool IsInLeft( void ) const { return ( m_nButtons & IN_LEFT ) ? true : false; }
bool IsInRight( void ) const { return ( m_nButtons & IN_RIGHT ) ? true : false; }
bool IsInRun( void ) const { return ( m_nButtons & IN_RUN ) ? true : false; }
bool IsInReload( void ) const { return ( m_nButtons & IN_RELOAD ) ? true : false; }
bool IsInSpeed( void ) const { return ( m_nButtons & IN_SPEED ) ? true : false; }
bool IsInWalk( void ) const { return ( m_nButtons & IN_WALK ) ? true : false; }
bool IsInZoom( void ) const { return ( m_nButtons & IN_ZOOM ) ? true : false; }
bool IsDucking( void ) const { return ( GetFlags() & FL_DUCKING ) ? true : false; }
bool IsOnGround( void ) const { return ( GetFlags() & FL_ONGROUND ) ? true : false; }
bool IsInAttack1( void ) const { return !!( m_nButtons & IN_ATTACK ); }
bool IsInAttack2( void ) const { return !!( m_nButtons & IN_ATTACK2 ); }
bool IsInUse( void ) const { return !!( m_nButtons & IN_USE ); }
bool IsInJump( void ) const { return !!( m_nButtons & IN_JUMP ); }
bool IsInForward( void ) const { return !!( m_nButtons & IN_FORWARD ); }
bool IsInBack( void ) const { return !!( m_nButtons & IN_BACK ); }
bool IsInMoveLeft( void ) const { return !!( m_nButtons & IN_MOVELEFT ); }
bool IsInMoveRight( void ) const { return !!( m_nButtons & IN_MOVERIGHT ); }
bool IsInLeft( void ) const { return !!( m_nButtons & IN_LEFT ); }
bool IsInRight( void ) const { return !!( m_nButtons & IN_RIGHT ); }
bool IsInRun( void ) const { return !!( m_nButtons & IN_RUN ); }
bool IsInReload( void ) const { return !!( m_nButtons & IN_RELOAD ); }
bool IsInSpeed( void ) const { return !!( m_nButtons & IN_SPEED ); }
bool IsInWalk( void ) const { return !!( m_nButtons & IN_WALK ); }
bool IsInZoom( void ) const { return !!( m_nButtons & IN_ZOOM ); }
bool IsDucking( void ) const { return !!( GetFlags() & FL_DUCKING ); }
bool IsOnGround( void ) const { return !!( GetFlags() & FL_ONGROUND ); }
bool IsInAir( void ) const { return !IsOnGround(); }
bool IsInAir( float flUnitsAboveGround ) const;

Expand Down
8 changes: 4 additions & 4 deletions dlls/ff/ff_vehicle_jeep.cpp
Expand Up @@ -610,7 +610,7 @@ bool CPropJeep::CheckWater( void )
// Check to see if we hit water.
if ( pWheel->GetContactPoint( &m_WaterData.m_vecWheelContactPoints[iWheel], NULL ) )
{
m_WaterData.m_bWheelInWater[iWheel] = ( UTIL_PointContents( m_WaterData.m_vecWheelContactPoints[iWheel] ) & MASK_WATER ) ? true : false;
m_WaterData.m_bWheelInWater[iWheel] = !!( UTIL_PointContents( m_WaterData.m_vecWheelContactPoints[iWheel] ) & MASK_WATER );
if ( m_WaterData.m_bWheelInWater[iWheel] )
{
bInWater = true;
Expand All @@ -624,7 +624,7 @@ bool CPropJeep::CheckWater( void )
QAngle vecEngineAngles;
GetAttachment( iEngine, vecEnginePoint, vecEngineAngles );

m_WaterData.m_bBodyInWater = ( UTIL_PointContents( vecEnginePoint ) & MASK_WATER ) ? true : false;
m_WaterData.m_bBodyInWater = !!( UTIL_PointContents( vecEnginePoint ) & MASK_WATER );
if ( m_WaterData.m_bBodyInWater )
{
if ( m_bHasPoop )
Expand Down Expand Up @@ -678,7 +678,7 @@ void CPropJeep::CheckWaterLevel( void )
vecUp.z = clamp( vecUp.z, 0.0f, vecUp.z );
vecAttachPoint.z += r_JeepViewZHeight.GetFloat() * vecUp.z;

bool bEyes = ( UTIL_PointContents( vecAttachPoint ) & MASK_WATER ) ? true : false;
bool bEyes = !!( UTIL_PointContents( vecAttachPoint ) & MASK_WATER );
if ( bEyes )
{
pPlayer->SetWaterLevel( WL_Eyes );
Expand All @@ -695,7 +695,7 @@ void CPropJeep::CheckWaterLevel( void )
// Check feet. (vehicle_feet_passenger0 point)
iAttachment = LookupAttachment( "vehicle_feet_passenger0" );
GetAttachment( iAttachment, vecAttachPoint, vecAttachAngles );
bool bFeet = ( UTIL_PointContents( vecAttachPoint ) & MASK_WATER ) ? true : false;
bool bFeet = !!( UTIL_PointContents( vecAttachPoint ) & MASK_WATER );
if ( bFeet )
{
pPlayer->SetWaterLevel( WL_Feet );
Expand Down
2 changes: 1 addition & 1 deletion game_shared/ff/ff_gamerules.cpp
Expand Up @@ -709,7 +709,7 @@ ConVar mp_friendlyfire_armorstrip( "mp_friendlyfire_armorstrip",
CUtlVector< int > iChangeClassValidClasses;

bool bUseTeam = ( ( iTeam >= TEAM_BLUE ) && ( iTeam <= TEAM_GREEN ) );
bool bUsePlayer = pFFPlayer ? true : false;
bool bUsePlayer = !!pFFPlayer;

// Eh? Which one do we use?
if( bUseTeam && bUsePlayer )
Expand Down
2 changes: 1 addition & 1 deletion game_shared/ff/ff_grenade_nail.cpp
Expand Up @@ -386,7 +386,7 @@ void CFFGrenadeNail::Precache()
AngleVectors( vecAngles, &vecNailDir );
VectorNormalizeFast( vecNailDir );
ShootNail( GetAbsOrigin() + ( 8.0f * vecNailDir ), vecAngles, ( i == 0 ) ? true : false );
ShootNail( GetAbsOrigin() + ( 8.0f * vecNailDir ), vecAngles, i == 0 );
// Update next position
vecAngles.y += (iNailSpreadInterval + iNailOffset);
Expand Down
2 changes: 1 addition & 1 deletion game_shared/ff/ff_utils.cpp
Expand Up @@ -713,7 +713,7 @@ bool FF_IsGrenade( CBaseEntity *pEntity )
if( !pEntity )
return false;

return ( pEntity->GetFlags() & FL_GRENADE ) ? true : false;
return !!( pEntity->GetFlags() & FL_GRENADE );
}

#ifdef GAME_DLL
Expand Down
2 changes: 1 addition & 1 deletion game_shared/ff/ff_weapon_parse.cpp
Expand Up @@ -37,7 +37,7 @@ void CFFWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName )

m_flCycleTime = pKeyValuesData->GetFloat( "CycleTime", 0.15f );
m_iCycleDecrement = pKeyValuesData->GetInt( "CycleDecrement", 0.15f );
m_bReloadClip = pKeyValuesData->GetInt( "ReloadClip", 0.0f ) ? true : false;
m_bReloadClip = !!pKeyValuesData->GetInt( "ReloadClip", 0.0f );

m_iDamage = pKeyValuesData->GetInt( "Damage", 42 ); // Douglas Adams 1952 - 2001
m_iDamageRadius = pKeyValuesData->GetInt( "DamageRadius", m_iDamage );
Expand Down

0 comments on commit 6d4fe49

Please sign in to comment.