diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/game/client/playerandobjectenumerator.cpp | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/game/client/playerandobjectenumerator.cpp')
| -rw-r--r-- | mp/src/game/client/playerandobjectenumerator.cpp | 170 |
1 files changed, 85 insertions, 85 deletions
diff --git a/mp/src/game/client/playerandobjectenumerator.cpp b/mp/src/game/client/playerandobjectenumerator.cpp index ff993b31..4868b50a 100644 --- a/mp/src/game/client/playerandobjectenumerator.cpp +++ b/mp/src/game/client/playerandobjectenumerator.cpp @@ -1,86 +1,86 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#include "cbase.h"
-#include "playerandobjectenumerator.h"
-#include "c_ai_basenpc.h"
-
-#ifdef INVASION_CLIENT_DLL
-#include "tf_shareddefs.h"
-#endif
-
-// memdbgon must be the last include file in a .cpp file!!!
-#include "tier0/memdbgon.h"
-
-// Enumator class for ragdolls being affected by explosive forces
-CPlayerAndObjectEnumerator::CPlayerAndObjectEnumerator( float radius )
-{
- m_flRadiusSquared = radius * radius;
- m_Objects.RemoveAll();
- m_pLocal = C_BasePlayer::GetLocalPlayer();
-}
-
-int CPlayerAndObjectEnumerator::GetObjectCount()
-{
- return m_Objects.Size();
-}
-
-C_BaseEntity *CPlayerAndObjectEnumerator::GetObject( int index )
-{
- if ( index < 0 || index >= GetObjectCount() )
- return NULL;
-
- return m_Objects[ index ];
-}
-
-// Actual work code
-IterationRetval_t CPlayerAndObjectEnumerator::EnumElement( IHandleEntity *pHandleEntity )
-{
- if ( !m_pLocal )
- return ITERATION_STOP;
-
- C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( pHandleEntity->GetRefEHandle() );
- if ( pEnt == NULL )
- return ITERATION_CONTINUE;
-
- if ( pEnt == m_pLocal )
- return ITERATION_CONTINUE;
-
- if ( !pEnt->IsPlayer() &&
- !pEnt->IsNPC() )
- {
- return ITERATION_CONTINUE;
- }
-
- if ( pEnt->IsNPC() )
- {
- C_AI_BaseNPC *pNPC = (C_AI_BaseNPC *)pEnt;
-
- if ( !pNPC->ShouldAvoidObstacle() )
- return ITERATION_CONTINUE;
- }
-
- // Ignore vehicles, since they have vcollide collisions that's push me away
- if ( pEnt->GetCollisionGroup() == COLLISION_GROUP_VEHICLE )
- return ITERATION_CONTINUE;
-
-#ifdef INVASION_CLIENT_DLL
- // If it's solid to player movement, don't steer around it since we'll just bump into it
- if ( pEnt->GetCollisionGroup() == TFCOLLISION_GROUP_OBJECT_SOLIDTOPLAYERMOVEMENT )
- return ITERATION_CONTINUE;
-#endif
-
- Vector deltaPos = pEnt->GetAbsOrigin() - m_pLocal->GetAbsOrigin();
- if ( deltaPos.LengthSqr() > m_flRadiusSquared )
- return ITERATION_CONTINUE;
-
- CHandle< C_BaseEntity > h;
- h = pEnt;
- m_Objects.AddToTail( h );
-
- return ITERATION_CONTINUE;
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "playerandobjectenumerator.h" +#include "c_ai_basenpc.h" + +#ifdef INVASION_CLIENT_DLL +#include "tf_shareddefs.h" +#endif + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +// Enumator class for ragdolls being affected by explosive forces +CPlayerAndObjectEnumerator::CPlayerAndObjectEnumerator( float radius ) +{ + m_flRadiusSquared = radius * radius; + m_Objects.RemoveAll(); + m_pLocal = C_BasePlayer::GetLocalPlayer(); +} + +int CPlayerAndObjectEnumerator::GetObjectCount() +{ + return m_Objects.Size(); +} + +C_BaseEntity *CPlayerAndObjectEnumerator::GetObject( int index ) +{ + if ( index < 0 || index >= GetObjectCount() ) + return NULL; + + return m_Objects[ index ]; +} + +// Actual work code +IterationRetval_t CPlayerAndObjectEnumerator::EnumElement( IHandleEntity *pHandleEntity ) +{ + if ( !m_pLocal ) + return ITERATION_STOP; + + C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( pHandleEntity->GetRefEHandle() ); + if ( pEnt == NULL ) + return ITERATION_CONTINUE; + + if ( pEnt == m_pLocal ) + return ITERATION_CONTINUE; + + if ( !pEnt->IsPlayer() && + !pEnt->IsNPC() ) + { + return ITERATION_CONTINUE; + } + + if ( pEnt->IsNPC() ) + { + C_AI_BaseNPC *pNPC = (C_AI_BaseNPC *)pEnt; + + if ( !pNPC->ShouldAvoidObstacle() ) + return ITERATION_CONTINUE; + } + + // Ignore vehicles, since they have vcollide collisions that's push me away + if ( pEnt->GetCollisionGroup() == COLLISION_GROUP_VEHICLE ) + return ITERATION_CONTINUE; + +#ifdef INVASION_CLIENT_DLL + // If it's solid to player movement, don't steer around it since we'll just bump into it + if ( pEnt->GetCollisionGroup() == TFCOLLISION_GROUP_OBJECT_SOLIDTOPLAYERMOVEMENT ) + return ITERATION_CONTINUE; +#endif + + Vector deltaPos = pEnt->GetAbsOrigin() - m_pLocal->GetAbsOrigin(); + if ( deltaPos.LengthSqr() > m_flRadiusSquared ) + return ITERATION_CONTINUE; + + CHandle< C_BaseEntity > h; + h = pEnt; + m_Objects.AddToTail( h ); + + return ITERATION_CONTINUE; }
\ No newline at end of file |