//===== Copyright © 1996-2005, 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 "host.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" #define TESTSCRIPT_COLOR Color( 0, 255, 255 ) CTestScriptMgr g_TestScriptMgr; ConVar testscript_debug( "testscript_debug", "0", 0, "Debug test scripts." ); ConVar testscript_running( "testscript_running", "0", 0, "Set to true when test scripts are running" ); // --------------------------------------------------------------------------------------------------- // // Global console commands the test script manager implements. // --------------------------------------------------------------------------------------------------- // CON_COMMAND_EXTERN_F( Test_Wait, Test_Wait, "", FCVAR_CHEAT ) { if ( !CommandLine()->FindParm("-insecure") ) { Warning( "Tests require that you launch the game with -insecure flag." ); return; } if ( args.ArgC() < 2 ) { Warning( "Test_Wait: requires seconds parameter." ); return; } float flSeconds = atof( args[ 1 ] ); GetTestScriptMgr()->SetWaitTime( flSeconds ); } CON_COMMAND_EXTERN_F( Test_RunFrame, Test_RunFrame, "", FCVAR_CHEAT ) { if ( !CommandLine()->FindParm( "-insecure" ) ) { Warning( "Tests require that you launch the game with -insecure flag." ); return; } GetTestScriptMgr()->SetWaitCheckPoint( "frame_end" ); } CON_COMMAND_EXTERN_F( Test_WaitForCheckPoint, Test_WaitForCheckPoint, "", FCVAR_CHEAT ) { if ( !CommandLine()->FindParm( "-insecure" ) ) { Warning( "Tests require that you launch the game with -insecure flag." ); return; } if ( args.ArgC() < 2 ) { Warning( "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_F( Test_StartLoop, Test_StartLoop, "Test_StartLoop - Denote the start of a loop. Really just defines a named point you can jump to.", FCVAR_CHEAT ) { if ( !CommandLine()->FindParm( "-insecure" ) ) { Warning( "Tests require that you launch the game with -insecure flag." ); return; } if ( args.ArgC() < 2 ) { Warning( "Test_StartLoop: requires a loop name." ); return; } GetTestScriptMgr()->StartLoop( args[ 1 ] ); } CON_COMMAND_EXTERN_F( Test_LoopCount, Test_LoopCount, "Test_LoopCount - loop back to the specified loop start point the specified # of times.", FCVAR_CHEAT ) { if ( !CommandLine()->FindParm( "-insecure" ) ) { Warning( "Tests require that you launch the game with -insecure flag." ); return; } if ( args.ArgC() < 3 ) { Warning( "Test_LoopCount: requires a loop name and number of times to loop." ); return; } GetTestScriptMgr()->LoopCount( args[ 1 ], atoi( args[ 2 ] ) ); } CON_COMMAND_EXTERN_F( Test_Loop, Test_Loop, "Test_Loop - loop back to the specified loop start point unconditionally.", FCVAR_CHEAT ) { if ( !CommandLine()->FindParm( "-insecure" ) ) { Warning( "Tests require that you launch the game with -insecure flag." ); return; } if ( args.ArgC() < 2 ) { Warning( "Test_Loop: requires a loop name." ); return; } GetTestScriptMgr()->LoopCount( args[ 1 ], -1 ); } CON_COMMAND_EXTERN_F( Test_LoopForNumSeconds, Test_LoopForNumSeconds, "Test_LoopForNumSeconds