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 /replay/cl_performancemanager.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'replay/cl_performancemanager.cpp')
| -rw-r--r-- | replay/cl_performancemanager.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/replay/cl_performancemanager.cpp b/replay/cl_performancemanager.cpp new file mode 100644 index 0000000..6b867ca --- /dev/null +++ b/replay/cl_performancemanager.cpp @@ -0,0 +1,71 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#include "cl_performancemanager.h" +#include "cl_replaymanager.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +//---------------------------------------------------------------------------------------- + +#define PERFORMANCE_INDEX_VERSION 0 + +//---------------------------------------------------------------------------------------- + +CReplayPerformanceManager::CReplayPerformanceManager() +{ +} + +CReplayPerformanceManager::~CReplayPerformanceManager() +{ +} + +void CReplayPerformanceManager::Init() +{ + g_pFullFileSystem->CreateDirHierarchy( Replay_va( "%s%s", CL_GetBasePath(), SUBDIR_PERFORMANCES ) ); +} + +void CReplayPerformanceManager::DeletePerformance( CReplayPerformance *pPerformance ) +{ + // Delete the performance file + const char *pFullFilename = pPerformance->GetFullPerformanceFilename(); + g_pFullFileSystem->RemoveFile( pFullFilename ); + + // Remove from replay list + CReplay *pOwnerReplay = pPerformance->m_pReplay; + pOwnerReplay->m_vecPerformances.FindAndRemove( pPerformance ); // This can fail if the replay doesn't own the performance yet - which is no problem. + + // Free + delete pPerformance; + + CL_GetReplayManager()->FlagReplayForFlush( pOwnerReplay, true ); +} + +const char *CReplayPerformanceManager::GetRelativePath() const +{ + return Replay_va( "%s%s%c", CL_GetRelativeBasePath(), SUBDIR_PERFORMANCES, CORRECT_PATH_SEPARATOR ); +} + +const char *CReplayPerformanceManager::GetFullPath() const +{ + return Replay_va( "%s%c%s", g_pEngine->GetGameDir(), CORRECT_PATH_SEPARATOR, GetRelativePath() ); +} + +CReplayPerformance *CReplayPerformanceManager::CreatePerformance( CReplay *pReplay ) +{ + return new CReplayPerformance( pReplay ); +} + +const char *CReplayPerformanceManager::GeneratePerformanceFilename( CReplay *pReplay ) +{ + static char s_szBaseFilename[ MAX_OSPATH ]; + char szIdealBaseFilename[ MAX_OSPATH ]; + V_strcpy_safe( szIdealBaseFilename, Replay_va( "replay_%i_edit", (int)pReplay->GetHandle() ) ); + Replay_GetFirstAvailableFilename( s_szBaseFilename, sizeof( s_szBaseFilename ), szIdealBaseFilename, "." GENERIC_FILE_EXTENSION, + CL_GetPerformanceManager()->GetRelativePath(), pReplay->GetPerformanceCount() ); + return s_szBaseFilename; +} + +//---------------------------------------------------------------------------------------- |