From 39ed87570bdb2f86969d4be821c94b722dc71179 Mon Sep 17 00:00:00 2001 From: Joe Ludwig Date: Wed, 26 Jun 2013 15:22:04 -0700 Subject: First version of the SOurce SDK 2013 --- mp/src/game/server/testfunctions.cpp | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 mp/src/game/server/testfunctions.cpp (limited to 'mp/src/game/server/testfunctions.cpp') 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 ); + + -- cgit v1.2.3