From 3bf9df6b2785fa6d951086978a3e66f49427166a Mon Sep 17 00:00:00 2001 From: FluorescentCIAAfricanAmerican <0934gj3049fk@protonmail.com> Date: Wed, 22 Apr 2020 12:56:21 -0400 Subject: 1 --- engine/testscriptmgr.cpp | 423 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 423 insertions(+) create mode 100644 engine/testscriptmgr.cpp (limited to 'engine/testscriptmgr.cpp') diff --git a/engine/testscriptmgr.cpp b/engine/testscriptmgr.cpp new file mode 100644 index 0000000..c94ed1b --- /dev/null +++ b/engine/testscriptmgr.cpp @@ -0,0 +1,423 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//===========================================================================// + + +#include "tier0/platform.h" +#include "sys.h" +#include "testscriptmgr.h" +#include "tier0/dbg.h" +#include "filesystem_engine.h" +#include "tier1/strtools.h" +#include "cmd.h" +#include "convar.h" +#include "vstdlib/random.h" +#include +#if defined( _X360 ) +#include "xbox/xbox_win32stubs.h" +#endif + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +CTestScriptMgr g_TestScriptMgr; + +ConVar testscript_debug( "testscript_debug", "0", 0, "Debug test scripts." ); + +#ifdef _DEBUG +// --------------------------------------------------------------------------------------------------- // +// Global console commands the test script manager implements. +// --------------------------------------------------------------------------------------------------- // +CON_COMMAND_EXTERN( Test_Wait, Test_Wait, "" ) +{ + if ( args.ArgC() < 2 ) + { + Error( "Test_Wait: requires seconds parameter." ); + return; + } + + float flSeconds = atof( args[ 1 ] ); + GetTestScriptMgr()->SetWaitTime( flSeconds ); +} + +CON_COMMAND_EXTERN( Test_RunFrame, Test_RunFrame, "" ) +{ + GetTestScriptMgr()->SetWaitCheckPoint( "frame_end" ); +} + +CON_COMMAND_EXTERN( Test_WaitForCheckPoint, Test_WaitForCheckPoint, "" ) +{ + if ( args.ArgC() < 2 ) + { + Error( "Test_WaitForCheckPoint [once]: requires checkpoint name." ); + return; + } + + bool bOnce = ( args.ArgC() >= 3 && Q_stricmp( args[2], "once" ) == 0 ); + GetTestScriptMgr()->SetWaitCheckPoint( args[ 1 ], bOnce ); +} + +CON_COMMAND_EXTERN( Test_StartLoop, Test_StartLoop, "Test_StartLoop - Denote the start of a loop. Really just defines a named point you can jump to." ) +{ + if ( args.ArgC() < 2 ) + { + Error( "Test_StartLoop: requires a loop name." ); + return; + } + + GetTestScriptMgr()->StartLoop( args[ 1 ] ); +} + +CON_COMMAND_EXTERN( Test_LoopCount, Test_LoopCount, "Test_LoopCount - loop back to the specified loop start point the specified # of times." ) +{ + if ( args.ArgC() < 3 ) + { + Error( "Test_LoopCount: requires a loop name and number of times to loop." ); + return; + } + + GetTestScriptMgr()->LoopCount( args[ 1 ], atoi( args[ 2 ] ) ); +} + +CON_COMMAND_EXTERN( Test_Loop, Test_Loop, "Test_Loop - loop back to the specified loop start point unconditionally." ) +{ + if ( args.ArgC() < 2 ) + { + Error( "Test_Loop: requires a loop name." ); + return; + } + + GetTestScriptMgr()->LoopCount( args[ 1 ], -1 ); +} + +CON_COMMAND_EXTERN( Test_LoopForNumSeconds, Test_LoopForNumSeconds, "Test_LoopForNumSeconds