aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/server/testfunctions.cpp
diff options
context:
space:
mode:
authorJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
committerJoe Ludwig <[email protected]>2013-06-26 15:22:04 -0700
commit39ed87570bdb2f86969d4be821c94b722dc71179 (patch)
treeabc53757f75f40c80278e87650ea92808274aa59 /mp/src/game/server/testfunctions.cpp
downloadsource-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz
source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/game/server/testfunctions.cpp')
-rw-r--r--mp/src/game/server/testfunctions.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/mp/src/game/server/testfunctions.cpp b/mp/src/game/server/testfunctions.cpp
new file mode 100644
index 00000000..c949a1da
--- /dev/null
+++ b/mp/src/game/server/testfunctions.cpp
@@ -0,0 +1,62 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#include "cbase.h"
+#include "convar.h"
+#include "tier0/dbg.h"
+#include "player.h"
+#include "world.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+void Test_CreateEntity( const CCommand &args )
+{
+ if ( args.ArgC() < 2 )
+ {
+ Error( "Test_CreateEntity: requires entity classname argument." );
+ }
+
+ const char *pClassName = args[ 1 ];
+
+ if ( !CreateEntityByName( pClassName ) )
+ {
+ Error( "Test_CreateEntity( %s ) failed.", pClassName );
+ }
+}
+
+
+void Test_RandomPlayerPosition()
+{
+ CBasePlayer *pPlayer = UTIL_GetLocalPlayer();
+ CWorld *pWorld = GetWorldEntity();
+ if ( !pPlayer )
+ {
+ Error( "Test_RandomPlayerPosition: no local player entity." );
+ }
+ else if ( !pWorld )
+ {
+ Error( "Test_RandomPlayerPosition: no world entity." );
+ }
+
+
+
+ Vector vMin, vMax;
+ pWorld->GetWorldBounds( vMin, vMax );
+
+ Vector vecOrigin;
+ vecOrigin.x = RandomFloat( vMin.x, vMax.x );
+ vecOrigin.y = RandomFloat( vMin.y, vMax.y );
+ vecOrigin.z = RandomFloat( vMin.z, vMax.z );
+ pPlayer->ForceOrigin( vecOrigin );
+}
+
+
+ConCommand cc_Test_CreateEntity( "Test_CreateEntity", Test_CreateEntity, 0, FCVAR_CHEAT );
+ConCommand cc_Test_RandomPlayerPosition( "Test_RandomPlayerPosition", Test_RandomPlayerPosition, 0, FCVAR_CHEAT );
+
+