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.

96 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #include "replay/performance.h"
  5. #include "replay/iclientreplaycontext.h"
  6. #include "replay/ireplayperformancemanager.h"
  7. #include "replay/replayutils.h"
  8. #include "KeyValues.h"
  9. #include "fmtstr.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. //----------------------------------------------------------------------------------------
  13. extern IClientReplayContext *g_pClientReplayContext;
  14. //----------------------------------------------------------------------------------------
  15. CReplayPerformance::CReplayPerformance( CReplay *pReplay )
  16. : m_pReplay( pReplay ),
  17. m_nTickIn( -1 ),
  18. m_nTickOut( -1 )
  19. {
  20. Assert( pReplay );
  21. m_szBaseFilename[ 0 ] = '\0';
  22. m_wszTitle[0] = L'\0';
  23. }
  24. CReplayPerformance::CReplayPerformance( const CReplayPerformance *pPerformance )
  25. {
  26. Copy( pPerformance );
  27. }
  28. void CReplayPerformance::Read( KeyValues *pIn )
  29. {
  30. SetFilename( pIn->GetString( "filename" ) );
  31. m_nTickIn = pIn->GetInt( "tick_in", -1 );
  32. m_nTickOut = pIn->GetInt( "tick_out", -1 );
  33. V_wcsncpy( m_wszTitle, pIn->GetWString( "title" ), sizeof( m_wszTitle ) );
  34. }
  35. void CReplayPerformance::Write( KeyValues *pOut )
  36. {
  37. pOut->SetString( "filename", m_szBaseFilename );
  38. pOut->SetInt( "tick_in", m_nTickIn );
  39. pOut->SetInt( "tick_out", m_nTickOut );
  40. pOut->SetWString( "title", m_wszTitle );
  41. }
  42. void CReplayPerformance::Copy( const CReplayPerformance *pSrc )
  43. {
  44. V_wcsncpy( m_wszTitle, pSrc->m_wszTitle, sizeof( m_wszTitle ) );
  45. V_strcpy( m_szBaseFilename, pSrc->m_szBaseFilename );
  46. m_pReplay = pSrc->m_pReplay;
  47. CopyTicks( pSrc );
  48. }
  49. void CReplayPerformance::CopyTicks( const CReplayPerformance *pSrc )
  50. {
  51. m_nTickIn = pSrc->m_nTickIn;
  52. m_nTickOut = pSrc->m_nTickOut;
  53. }
  54. void CReplayPerformance::SetFilename( const char *pFilename )
  55. {
  56. V_strcpy( m_szBaseFilename, pFilename );
  57. }
  58. const char *CReplayPerformance::GetFullPerformanceFilename()
  59. {
  60. return Replay_va( "%s%s", g_pClientReplayContext->GetPerformanceManager()->GetFullPath(), m_szBaseFilename );
  61. }
  62. void CReplayPerformance::AutoNameIfHasNoTitle( const char *pMapName )
  63. {
  64. if ( !m_wszTitle[ 0 ] )
  65. {
  66. Replay_GetAutoName( m_wszTitle, sizeof( m_wszTitle ), pMapName );
  67. }
  68. }
  69. void CReplayPerformance::SetTitle( const wchar_t *pTitle )
  70. {
  71. V_wcsncpy( m_wszTitle, pTitle, sizeof( m_wszTitle ) );
  72. }
  73. CReplayPerformance *CReplayPerformance::MakeCopy() const
  74. {
  75. return new CReplayPerformance( this );
  76. }
  77. //----------------------------------------------------------------------------------------