Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #include "cl_performancemanager.h"
  5. #include "cl_replaymanager.h"
  6. // memdbgon must be the last include file in a .cpp file!!!
  7. #include "tier0/memdbgon.h"
  8. //----------------------------------------------------------------------------------------
  9. #define PERFORMANCE_INDEX_VERSION 0
  10. //----------------------------------------------------------------------------------------
  11. CReplayPerformanceManager::CReplayPerformanceManager()
  12. {
  13. }
  14. CReplayPerformanceManager::~CReplayPerformanceManager()
  15. {
  16. }
  17. void CReplayPerformanceManager::Init()
  18. {
  19. g_pFullFileSystem->CreateDirHierarchy( Replay_va( "%s%s", CL_GetBasePath(), SUBDIR_PERFORMANCES ) );
  20. }
  21. void CReplayPerformanceManager::DeletePerformance( CReplayPerformance *pPerformance )
  22. {
  23. // Delete the performance file
  24. const char *pFullFilename = pPerformance->GetFullPerformanceFilename();
  25. g_pFullFileSystem->RemoveFile( pFullFilename );
  26. // Remove from replay list
  27. CReplay *pOwnerReplay = pPerformance->m_pReplay;
  28. pOwnerReplay->m_vecPerformances.FindAndRemove( pPerformance ); // This can fail if the replay doesn't own the performance yet - which is no problem.
  29. // Free
  30. delete pPerformance;
  31. CL_GetReplayManager()->FlagReplayForFlush( pOwnerReplay, true );
  32. }
  33. const char *CReplayPerformanceManager::GetRelativePath() const
  34. {
  35. return Replay_va( "%s%s%c", CL_GetRelativeBasePath(), SUBDIR_PERFORMANCES, CORRECT_PATH_SEPARATOR );
  36. }
  37. const char *CReplayPerformanceManager::GetFullPath() const
  38. {
  39. return Replay_va( "%s%c%s", g_pEngine->GetGameDir(), CORRECT_PATH_SEPARATOR, GetRelativePath() );
  40. }
  41. CReplayPerformance *CReplayPerformanceManager::CreatePerformance( CReplay *pReplay )
  42. {
  43. return new CReplayPerformance( pReplay );
  44. }
  45. const char *CReplayPerformanceManager::GeneratePerformanceFilename( CReplay *pReplay )
  46. {
  47. static char s_szBaseFilename[ MAX_OSPATH ];
  48. char szIdealBaseFilename[ MAX_OSPATH ];
  49. V_strcpy_safe( szIdealBaseFilename, Replay_va( "replay_%i_edit", (int)pReplay->GetHandle() ) );
  50. Replay_GetFirstAvailableFilename( s_szBaseFilename, sizeof( s_szBaseFilename ), szIdealBaseFilename, "." GENERIC_FILE_EXTENSION,
  51. CL_GetPerformanceManager()->GetRelativePath(), pReplay->GetPerformanceCount() );
  52. return s_szBaseFilename;
  53. }
  54. //----------------------------------------------------------------------------------------