diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /engine/DevShotGenerator.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'engine/DevShotGenerator.cpp')
| -rw-r--r-- | engine/DevShotGenerator.cpp | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/engine/DevShotGenerator.cpp b/engine/DevShotGenerator.cpp new file mode 100644 index 0000000..c6bf6f0 --- /dev/null +++ b/engine/DevShotGenerator.cpp @@ -0,0 +1,149 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include "DevShotGenerator.h" +#include "cmd.h" +#include "fmtstr.h" +#include "host.h" +#include "tier0/icommandline.h" +#include <tier0/dbg.h> + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +#define PAUSE_FRAMES_BETWEEN_MAPS 300 +#define PAUSE_TIME_BETWEEN_MAPS 2.0f + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void DevShotGenerator_Usage() +{ + // + Msg( "-makedevshots usage:\n" ); + Msg( " [ -usedevshotsfile filename ] -- get map list from specified file, default is to build for maps/*.bsp\n" ); + Msg( " [ -startmap mapname ] -- restart generation at specified map (after crash, implies resume)\n" ); + Msg( " [ -condebug ] -- prepend console.log entries with mapname or engine if not in a map\n" ); + Msg( " [ +map mapname ] -- generate devshots for specified map and exit after that map\n" ); +} + +void DevShotGenerator_Init() +{ + // check for devshot generation + if ( CommandLine()->FindParm("-makedevshots") ) + { + bool usemaplistfile = false; + if ( CommandLine()->FindParm("-usedevshotsfile") ) + { + usemaplistfile = true; + } + DevShotGenerator().EnableDevShotGeneration( usemaplistfile ); + } +} + +void DevShotGenerator_Shutdown() +{ + DevShotGenerator().Shutdown(); +} + +void DevShotGenerator_BuildMapList() +{ + DevShotGenerator().BuildMapList(); +} + +CDevShotGenerator g_DevShotGenerator; +CDevShotGenerator &DevShotGenerator() +{ + return g_DevShotGenerator; +} + +void CL_DevShots_NextMap() +{ + DevShotGenerator().NextMap(); +} + +static ConCommand devshots_nextmap( "devshots_nextmap", CL_DevShots_NextMap, "Used by the devshots system to go to the next map in the devshots maplist." ); + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CDevShotGenerator::CDevShotGenerator() +{ + m_bUsingMapList = false; + m_bDevShotsEnabled = false; + m_iCurrentMap = 0; +} + +void CDevShotGenerator::BuildMapList() +{ + if ( !m_bDevShotsEnabled ) + return; + + DevShotGenerator_Usage(); + + // Get the maplist file, if any + const char *pMapFile = NULL; + CommandLine()->CheckParm( "-usedevshotsfile", &pMapFile ); + + // Build the map list + if ( !BuildGeneralMapList( &m_Maps, CommandLine()->FindParm("-usedevshotsfile") != 0, pMapFile, "devshots", &m_iCurrentMap ) ) + { + m_bDevShotsEnabled = false; + } +} + +void CDevShotGenerator::NextMap() +{ + if ( !m_bDevShotsEnabled ) + return; + + //Msg("DEVSHOTS: Nextmap command received.\n"); + + if (m_Maps.IsValidIndex(m_iCurrentMap)) + { + //Msg("DEVSHOTS: Switching to %s (%d).\n", m_Maps[m_iCurrentMap].name, m_iCurrentMap ); + CFmtStr str("map %s\n", m_Maps[m_iCurrentMap].name); + Cbuf_AddText( str.Access() ); + + ++m_iCurrentMap; + } + else + { + //Msg("DEVSHOTS: Finished on map %d.\n", m_iCurrentMap); + + // no more levels, just quit + Cbuf_AddText( "quit\n" ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: initializes the object to enable dev shot generation +//----------------------------------------------------------------------------- +void CDevShotGenerator::EnableDevShotGeneration( bool usemaplistfile ) +{ + m_bUsingMapList = usemaplistfile; + m_bDevShotsEnabled = true; +} + +//----------------------------------------------------------------------------- +// Purpose: starts the first map +//----------------------------------------------------------------------------- +void CDevShotGenerator::StartDevShotGeneration() +{ + BuildMapList(); + + CFmtStr str("map %s\n", m_Maps[m_iCurrentMap].name); + Cbuf_AddText( str.Access() ); + ++m_iCurrentMap; +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CDevShotGenerator::Shutdown() +{ +} + |