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.

97 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #ifndef BASERECORDINGSESSION_H
  5. #define BASERECORDINGSESSION_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. //----------------------------------------------------------------------------------------
  10. #include "tier0/platform.h"
  11. #include "utlstring.h"
  12. #include "utllinkedlist.h"
  13. #include "replay/replayhandle.h"
  14. #include "replay/basereplayserializeable.h"
  15. #include "replay/irecordingsession.h"
  16. #include "UtlSortVector.h"
  17. //----------------------------------------------------------------------------------------
  18. class CBaseRecordingSessionBlock;
  19. class KeyValues;
  20. class IReplayContext;
  21. //----------------------------------------------------------------------------------------
  22. // A recording session (e.g. round), including a list of blocks
  23. class CBaseRecordingSession : public CBaseReplaySerializeable,
  24. public IRecordingSession
  25. {
  26. typedef CBaseReplaySerializeable BaseClass;
  27. public:
  28. CBaseRecordingSession( IReplayContext *pContext );
  29. ~CBaseRecordingSession();
  30. //
  31. // IRecordingSession
  32. //
  33. virtual void AddBlock( CBaseRecordingSessionBlock *pBlock );
  34. virtual bool Read( KeyValues *pIn );
  35. virtual void Write( KeyValues *pOut );
  36. virtual const char *GetSubKeyTitle() const;
  37. virtual const char *GetPath() const;
  38. virtual void OnDelete();
  39. virtual void OnUnload();
  40. const char *GetSessionInfoURL() const;
  41. virtual void PopulateWithRecordingData( int nCurrentRecordingStartTick );
  42. void OnStopRecording() { m_bRecording = false; }
  43. class CLessFunctor
  44. {
  45. public:
  46. bool Less( const CBaseRecordingSessionBlock *pSrc1, const CBaseRecordingSessionBlock *pSrc2, void *pContext );
  47. };
  48. typedef CUtlSortVector< CBaseRecordingSessionBlock *, CLessFunctor > BlockContainer_t;
  49. inline int GetNumBlocks() const { return m_vecBlocks.Count(); }
  50. void AddBlock( CBaseRecordingSessionBlock *pBlock, bool bFlagForFlush );
  51. int FindBlock( CBaseRecordingSessionBlock *pBlock ) const; // Returns -1 on fail
  52. const BlockContainer_t &GetBlocks() const { return m_vecBlocks; }
  53. // Determines whether or not a session gets nuked at the end of a round or not.
  54. virtual bool ShouldDitchSession() const;
  55. // Dynamically load blocks
  56. void LoadBlocksForSession();
  57. void DeleteBlocks();
  58. // Persistent:
  59. bool m_bRecording; // Is this session currently recording?
  60. CUtlString m_strName; // A unique session name, given by the server at the start of recording based on time/date
  61. CUtlString m_strBaseDownloadURL; // The download URL, with no filename, e.g., "http://someserver:80/somepath/"
  62. int m_nServerStartRecordTick; // The tick at which the server began recording the given session (based on g_ServerGlobalVariables.tickcount) -
  63. // which is the tick client spawn/death ticks are relative to
  64. float m_flStartTime;
  65. // Non-persistent:
  66. IReplayContext *m_pContext;
  67. bool m_bAutoDelete; // Set to true if a session is removed while it's recording - if flagged, session will auto-delete once recording ends
  68. bool m_bBlocksLoaded;
  69. protected:
  70. BlockContainer_t m_vecBlocks; // A list of session blocks for the given session - NOTE: Blocks should not be free'd
  71. };
  72. //----------------------------------------------------------------------------------------
  73. #endif // BASERECORDINGSESSION_H