summaryrefslogtreecommitdiff
path: root/replay/cl_performancemanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'replay/cl_performancemanager.cpp')
-rw-r--r--replay/cl_performancemanager.cpp71
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;
+}
+
+//----------------------------------------------------------------------------------------