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.

94 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #ifndef CL_RECORDINGSESSIONMANAGER_H
  5. #define CL_RECORDINGSESSIONMANAGER_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. //----------------------------------------------------------------------------------------
  10. #include "baserecordingsessionmanager.h"
  11. #include "igameevents.h"
  12. #include "replaysystem.h"
  13. #include "replay/shared_defs.h"
  14. //----------------------------------------------------------------------------------------
  15. //
  16. // Manages and serializes all replay recording session data on the client
  17. //
  18. class CClientRecordingSessionManager : public CBaseRecordingSessionManager,
  19. public IGameEventListener2
  20. {
  21. typedef CBaseRecordingSessionManager BaseClass;
  22. public:
  23. CClientRecordingSessionManager( IReplayContext *pContext );
  24. ~CClientRecordingSessionManager();
  25. virtual bool Init();
  26. void CleanupUnneededBlocks();
  27. virtual CBaseRecordingSession *OnSessionStart( int nCurrentRecordingStartTick, const char *pSessionName );
  28. virtual void OnSessionEnd();
  29. void ClearServerRecordingState() { m_ServerRecordingState.Clear(); }
  30. void OnReplayDeleted( CReplay *pReplay );
  31. void OnReplaysLoaded();
  32. //
  33. // CGenericPersistentManager
  34. //
  35. virtual CBaseRecordingSession *Create();
  36. struct ServerRecordingState_t
  37. {
  38. ServerRecordingState_t() { Clear(); }
  39. void Clear() { m_strSessionName = ""; m_nDumpInterval = m_nCurrentBlock = m_nStartTick = 0; }
  40. CUtlString m_strSessionName; // Name of current recording session
  41. int m_nDumpInterval; // The interval at which the server is dumping partial replays
  42. int m_nCurrentBlock; // Current session block being written to on the server (approximation - may be ahead but never behind)
  43. int m_nStartTick; // The tick on the server when the session began - used to calculate an adjusted spawn tick on the client
  44. bool IsValid()
  45. {
  46. return !m_strSessionName.IsEmpty() &&
  47. m_nDumpInterval >= MIN_SERVER_DUMP_INTERVAL &&
  48. m_nDumpInterval <= MAX_SERVER_DUMP_INTERVAL;
  49. }
  50. }
  51. m_ServerRecordingState;
  52. private:
  53. //
  54. // CGenericPersistentManager
  55. //
  56. virtual int GetVersion() const;
  57. virtual void Think();
  58. virtual IReplayContext *GetReplayContext() const;
  59. virtual void OnObjLoaded( CBaseRecordingSession *pSession );
  60. //
  61. // IRecordingSessionManager
  62. //
  63. virtual const char *GetNewSessionName() const;
  64. virtual void FireGameEvent( IGameEvent *pEvent );
  65. void AddEventsForListen();
  66. void DownloadThink();
  67. float m_flNextBlockUpdateTime;
  68. float m_flNextPossibleDownloadTime;
  69. int m_nNumSessionBlockDownloaders; // TODO: Manage the number of session block downloaders
  70. };
  71. //----------------------------------------------------------------------------------------
  72. #endif // CL_RECORDINGSESSIONMANAGER_H