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.

134 lines
3.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #ifndef SV_REPLAYCONTEXT_H
  5. #define SV_REPLAYCONTEXT_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. //----------------------------------------------------------------------------------------
  10. #include "shared_replaycontext.h"
  11. #include "replay/iserverreplaycontext.h"
  12. #include "sv_recordingsessionmanager.h"
  13. #include "sv_recordingsessionblockmanager.h"
  14. #include "errorsystem.h"
  15. //----------------------------------------------------------------------------------------
  16. class CSessionRecorder;
  17. class CBaseRecordingSessionBlock;
  18. class IRecordingSessionManager;
  19. class IThreadPool;
  20. class CFileserverCleaner;
  21. //----------------------------------------------------------------------------------------
  22. class CServerReplayContext : public IServerReplayContext,
  23. public IErrorReporter
  24. {
  25. public:
  26. LINK_TO_SHARED_REPLAYCONTEXT_IMP();
  27. CServerReplayContext();
  28. ~CServerReplayContext();
  29. virtual bool Init( CreateInterfaceFn fnFactory );
  30. virtual void Shutdown();
  31. virtual void Think(); // Called by engine
  32. virtual void OnPublishFailed();
  33. void DoSanityCheckNow();
  34. void UpdateFileserverIPFromHostname( const char *pHostname );
  35. void UpdateFileserverProxyIPFromHostname( const char *pHostname );
  36. //
  37. // IErrorReporter
  38. //
  39. virtual void ReportErrorsToUser( wchar_t *pErrorText );
  40. //
  41. // IServerReplayContext
  42. //
  43. virtual void FlagForConVarSanityCheck();
  44. virtual IGameEvent *CreateReplaySessionInfoEvent();
  45. virtual IReplaySessionRecorder *GetSessionRecorder();
  46. virtual const char *GetLocalFileServerPath() const;
  47. virtual void CreateSessionOnClient( int nClientSlot );
  48. const char *GetServerSubDirName() const;
  49. CSessionRecorder *m_pSessionRecorder;
  50. CFileserverCleaner *m_pFileserverCleaner;
  51. char m_szFileserverIP[16]; // Fileserver's IP, cached any time "replay_fileserver_offload_hostname" is modified.
  52. char m_szFileserverProxyIP[16]; // Proxy's IP, cached any time "replay_fileserver_offload_proxy_host" is modified.
  53. private:
  54. void CleanTmpDir();
  55. void ConVarSanityThink();
  56. float m_flConVarSanityCheckTime;
  57. bool m_bShouldAbortRecording;
  58. };
  59. //----------------------------------------------------------------------------------------
  60. extern CServerReplayContext *g_pServerReplayContext;
  61. //----------------------------------------------------------------------------------------
  62. inline CServerRecordingSessionManager *SV_GetRecordingSessionManager()
  63. {
  64. return static_cast< CServerRecordingSessionManager * >( g_pServerReplayContext->GetRecordingSessionManager() );
  65. }
  66. inline CServerRecordingSessionBlockManager *SV_GetRecordingSessionBlockManager()
  67. {
  68. return static_cast< CServerRecordingSessionBlockManager * >( g_pServerReplayContext->GetRecordingSessionBlockManager() );
  69. }
  70. inline CSessionRecorder *SV_GetSessionRecorder()
  71. {
  72. return g_pServerReplayContext->m_pSessionRecorder;
  73. }
  74. inline CFileserverCleaner *SV_GetFileserverCleaner()
  75. {
  76. return g_pServerReplayContext->m_pFileserverCleaner;
  77. }
  78. inline const char *SV_GetBasePath()
  79. {
  80. return g_pServerReplayContext->m_pShared->m_strBasePath;
  81. }
  82. inline IThreadPool *SV_GetThreadPool()
  83. {
  84. return g_pServerReplayContext->m_pShared->m_pThreadPool;
  85. }
  86. inline char const *SV_GetFileserverIP()
  87. {
  88. return g_pServerReplayContext->m_szFileserverIP;
  89. }
  90. inline char const *SV_GetFileserverProxyIP()
  91. {
  92. return g_pServerReplayContext->m_szFileserverProxyIP;
  93. }
  94. CServerRecordingSession *SV_GetRecordingSessionInProgress();
  95. const char *SV_GetTmpDir(); // Get "replay/server/tmp/"
  96. bool SV_IsOffloadingEnabled();
  97. class CJob;
  98. bool SV_RunJobToCompletion( CJob *pJob ); // NOTE: Adds to thread pool first
  99. //----------------------------------------------------------------------------------------
  100. #endif // SV_REPLAYCONTEXT_H