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/server/test_stressentities.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/server/test_stressentities.cpp')
| -rw-r--r-- | mp/src/game/server/test_stressentities.cpp | 304 |
1 files changed, 152 insertions, 152 deletions
diff --git a/mp/src/game/server/test_stressentities.cpp b/mp/src/game/server/test_stressentities.cpp index 9bcf2ed0..b98e18df 100644 --- a/mp/src/game/server/test_stressentities.cpp +++ b/mp/src/game/server/test_stressentities.cpp @@ -1,152 +1,152 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#include "cbase.h"
-#include "test_stressentities.h"
-#include "vstdlib/random.h"
-#include "world.h"
-
-// memdbgon must be the last include file in a .cpp file!!!
-#include "tier0/memdbgon.h"
-
-CStressEntityReg *CStressEntityReg::s_pHead = NULL;
-
-
-// CStressEntityReg::s_pHead in array form for convenient access.
-CUtlVector<CStressEntityReg*> g_StressEntityRegs;
-
-CUtlVector<EHANDLE> g_StressEntities;
-
-
-CBaseEntity* MoveToRandomSpot( CBaseEntity *pEnt )
-{
- if ( pEnt )
- {
- CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer();
- if ( pLocalPlayer )
- {
- Vector vForward;
- pLocalPlayer->EyeVectors(&vForward );
-
- UTIL_SetOrigin( pEnt, GetRandomSpot() );
- }
- }
-
- return pEnt;
-}
-
-
-Vector GetRandomSpot()
-{
- CWorld *pEnt = GetWorldEntity();
- if ( pEnt )
- {
- Vector vMin, vMax;
- pEnt->GetWorldBounds( vMin, vMax );
- return Vector(
- RandomFloat( vMin.x, vMax.x ),
- RandomFloat( vMin.y, vMax.y ),
- RandomFloat( vMin.z, vMax.z ) );
- }
- else
- {
- return Vector( 0, 0, 0 );
- }
-}
-
-
-void Test_InitRandomEntitySpawner( const CCommand &args )
-{
- // Put the list of registered functions into array form for convenience.
- g_StressEntityRegs.Purge();
- for ( CStressEntityReg *pCur=CStressEntityReg::GetListHead(); pCur; pCur=pCur->GetNext() )
- g_StressEntityRegs.AddToTail( pCur );
-
- // Create slots for all the entities..
- int nSlots = 100;
- if ( args.ArgC() >= 2 )
- nSlots = atoi( args[ 1 ] );
-
- g_StressEntities.Purge();
- g_StressEntities.SetSize( nSlots );
-
- Msg( "Test_InitRandomEntitySpawner: created %d slots.\n", nSlots );
-}
-
-
-void Test_SpawnRandomEntities( const CCommand &args )
-{
- if ( args.ArgC() < 3 )
- {
- Error( "Test_SpawnRandomEntities <min # entities> <max # entities> missing arguments." );
- }
-
- if ( g_StressEntities.Count() == 0 )
- {
- Error( "Test_SpawnRandomEntities: not initialized (call Test_InitRandomEntitySpawner frst)." );
- }
-
- int nMin = atoi( args[ 1 ] );
- int nMax = atoi( args[ 2 ] );
- int count = RandomInt( nMin, nMax );
-
- for ( int i=0; i < count; i++ )
- {
- int iSlot = RandomInt( 0, g_StressEntities.Count() - 1 );
-
- // Remove any old entity in this slot.
- if ( g_StressEntities[iSlot].Get() )
- UTIL_RemoveImmediate( g_StressEntities[iSlot] );
-
- // Create a new one in this slot.
- int iType = RandomInt( 0, g_StressEntityRegs.Count() - 1 );
- g_StressEntities[iSlot] = g_StressEntityRegs[iType]->GetFn()();
- }
-}
-
-
-void Test_RandomizeInPVS( const CCommand &args )
-{
- if ( args.ArgC() < 2 )
- {
- Error( "Test_RandomizeInPVS <percentage chance to change>" );
- }
-
- int percent = atoi( args[ 1 ] );
- for ( int i=0; i < g_StressEntities.Count(); i++ )
- {
- CBaseEntity *pEnt = g_StressEntities[i];
-
- if ( pEnt )
- {
- if ( RandomInt( 0, 100 ) < percent )
- {
- if ( pEnt->IsEffectActive( EF_NODRAW ) )
- pEnt->RemoveEffects( EF_NODRAW );
- else
- pEnt->AddEffects( EF_NODRAW );
- }
- }
- }
-}
-
-
-void Test_RemoveAllRandomEntities()
-{
- for ( int i=0; i < g_StressEntities.Count(); i++ )
- {
- if ( g_StressEntities[i].Get() )
- UTIL_Remove( g_StressEntities[i] );
- }
-}
-
-
-ConCommand cc_Test_InitRandomEntitySpawner( "Test_InitRandomEntitySpawner", Test_InitRandomEntitySpawner, 0, FCVAR_CHEAT );
-ConCommand cc_Test_SpawnRandomEntities( "Test_SpawnRandomEntities", Test_SpawnRandomEntities, 0, FCVAR_CHEAT );
-ConCommand cc_Test_RandomizeInPVS( "Test_RandomizeInPVS", Test_RandomizeInPVS, 0, FCVAR_CHEAT );
-ConCommand cc_Test_RemoveAllRandomEntities( "Test_RemoveAllRandomEntities", Test_RemoveAllRandomEntities, 0, FCVAR_CHEAT );
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "test_stressentities.h" +#include "vstdlib/random.h" +#include "world.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +CStressEntityReg *CStressEntityReg::s_pHead = NULL; + + +// CStressEntityReg::s_pHead in array form for convenient access. +CUtlVector<CStressEntityReg*> g_StressEntityRegs; + +CUtlVector<EHANDLE> g_StressEntities; + + +CBaseEntity* MoveToRandomSpot( CBaseEntity *pEnt ) +{ + if ( pEnt ) + { + CBasePlayer *pLocalPlayer = UTIL_GetLocalPlayer(); + if ( pLocalPlayer ) + { + Vector vForward; + pLocalPlayer->EyeVectors(&vForward ); + + UTIL_SetOrigin( pEnt, GetRandomSpot() ); + } + } + + return pEnt; +} + + +Vector GetRandomSpot() +{ + CWorld *pEnt = GetWorldEntity(); + if ( pEnt ) + { + Vector vMin, vMax; + pEnt->GetWorldBounds( vMin, vMax ); + return Vector( + RandomFloat( vMin.x, vMax.x ), + RandomFloat( vMin.y, vMax.y ), + RandomFloat( vMin.z, vMax.z ) ); + } + else + { + return Vector( 0, 0, 0 ); + } +} + + +void Test_InitRandomEntitySpawner( const CCommand &args ) +{ + // Put the list of registered functions into array form for convenience. + g_StressEntityRegs.Purge(); + for ( CStressEntityReg *pCur=CStressEntityReg::GetListHead(); pCur; pCur=pCur->GetNext() ) + g_StressEntityRegs.AddToTail( pCur ); + + // Create slots for all the entities.. + int nSlots = 100; + if ( args.ArgC() >= 2 ) + nSlots = atoi( args[ 1 ] ); + + g_StressEntities.Purge(); + g_StressEntities.SetSize( nSlots ); + + Msg( "Test_InitRandomEntitySpawner: created %d slots.\n", nSlots ); +} + + +void Test_SpawnRandomEntities( const CCommand &args ) +{ + if ( args.ArgC() < 3 ) + { + Error( "Test_SpawnRandomEntities <min # entities> <max # entities> missing arguments." ); + } + + if ( g_StressEntities.Count() == 0 ) + { + Error( "Test_SpawnRandomEntities: not initialized (call Test_InitRandomEntitySpawner frst)." ); + } + + int nMin = atoi( args[ 1 ] ); + int nMax = atoi( args[ 2 ] ); + int count = RandomInt( nMin, nMax ); + + for ( int i=0; i < count; i++ ) + { + int iSlot = RandomInt( 0, g_StressEntities.Count() - 1 ); + + // Remove any old entity in this slot. + if ( g_StressEntities[iSlot].Get() ) + UTIL_RemoveImmediate( g_StressEntities[iSlot] ); + + // Create a new one in this slot. + int iType = RandomInt( 0, g_StressEntityRegs.Count() - 1 ); + g_StressEntities[iSlot] = g_StressEntityRegs[iType]->GetFn()(); + } +} + + +void Test_RandomizeInPVS( const CCommand &args ) +{ + if ( args.ArgC() < 2 ) + { + Error( "Test_RandomizeInPVS <percentage chance to change>" ); + } + + int percent = atoi( args[ 1 ] ); + for ( int i=0; i < g_StressEntities.Count(); i++ ) + { + CBaseEntity *pEnt = g_StressEntities[i]; + + if ( pEnt ) + { + if ( RandomInt( 0, 100 ) < percent ) + { + if ( pEnt->IsEffectActive( EF_NODRAW ) ) + pEnt->RemoveEffects( EF_NODRAW ); + else + pEnt->AddEffects( EF_NODRAW ); + } + } + } +} + + +void Test_RemoveAllRandomEntities() +{ + for ( int i=0; i < g_StressEntities.Count(); i++ ) + { + if ( g_StressEntities[i].Get() ) + UTIL_Remove( g_StressEntities[i] ); + } +} + + +ConCommand cc_Test_InitRandomEntitySpawner( "Test_InitRandomEntitySpawner", Test_InitRandomEntitySpawner, 0, FCVAR_CHEAT ); +ConCommand cc_Test_SpawnRandomEntities( "Test_SpawnRandomEntities", Test_SpawnRandomEntities, 0, FCVAR_CHEAT ); +ConCommand cc_Test_RandomizeInPVS( "Test_RandomizeInPVS", Test_RandomizeInPVS, 0, FCVAR_CHEAT ); +ConCommand cc_Test_RemoveAllRandomEntities( "Test_RemoveAllRandomEntities", Test_RemoveAllRandomEntities, 0, FCVAR_CHEAT ); + |