diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /replay/baserecordingsessionmanager.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'replay/baserecordingsessionmanager.h')
| -rw-r--r-- | replay/baserecordingsessionmanager.h | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/replay/baserecordingsessionmanager.h b/replay/baserecordingsessionmanager.h new file mode 100644 index 0000000..fa86e40 --- /dev/null +++ b/replay/baserecordingsessionmanager.h @@ -0,0 +1,103 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef BASERECORDINGSESSIONMANAGER_H +#define BASERECORDINGSESSIONMANAGER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "tier0/platform.h" +#include "utlstring.h" +#include "utllinkedlist.h" +#include "replay/replayhandle.h" +#include "replay/irecordingsessionmanager.h" +#include "genericpersistentmanager.h" + +//---------------------------------------------------------------------------------------- + +class CBaseRecordingSession; +class CBaseRecordingSessionBlock; +class KeyValues; +class IReplayContext; + +//---------------------------------------------------------------------------------------- + +// +// Manages and serializes all replay recording session data - instanced on both the client +// and server via CClientRecordingSessionManager and CServerRecordingSessionManager. +// +class CBaseRecordingSessionManager : public CGenericPersistentManager< CBaseRecordingSession >, + public IRecordingSessionManager +{ + typedef CGenericPersistentManager< CBaseRecordingSession > BaseClass; + +public: + CBaseRecordingSessionManager( IReplayContext *pContext ); + virtual ~CBaseRecordingSessionManager(); + + virtual bool Init(); + + virtual CBaseRecordingSession *OnSessionStart( int nCurrentRecordingStartTick, const char *pSessionName ); + virtual void OnSessionEnd(); + + void DeleteSession( ReplayHandle_t hSession, bool bForce ); + + const char *GetCurrentSessionName() const; + int GetCurrentSessionBlockIndex() const; + + CBaseRecordingSession *FindSessionByName( const char *pSessionName ); + + // This is here so that server-side cleanup can be done for a ditched session. See calling code for details. + void DoSessionCleanup(); + + // + // IRecordingSessionManager + // + virtual CBaseRecordingSession *FindSession( ReplayHandle_t hSession ); + virtual const CBaseRecordingSession *FindSession( ReplayHandle_t hSession ) const; + virtual void FlagSessionForFlush( CBaseRecordingSession *pSession, bool bForceImmediate ); + virtual int GetServerStartTickForSession( ReplayHandle_t hSession ); + + // Get the recording session in progress + CBaseRecordingSession *GetRecordingSessionInProgress() { return m_pRecordingSession; } + + bool LastSessionDitched() const { return m_bLastSessionDitched; } + +protected: + // + // CGenericPersistentManager + // + virtual const char *GetIndexFilename() const { return "sessions." GENERIC_FILE_EXTENSION; } + virtual const char *GetRelativeIndexPath() const; + virtual const char *GetDebugName() const { return "session manager"; } + virtual void Think(); + + // + // CBaseThinker + // + virtual float GetNextThinkTime() const; + + IReplayContext *m_pContext; + CBaseRecordingSession *m_pRecordingSession; // Currently recording session, or NULL if not recording + bool m_bLastSessionDitched; + + virtual bool CanDeleteSession( ReplayHandle_t hSession ) const { return true; } + virtual bool ShouldUnloadSessions() const { return false; } + + virtual void OnAllSessionsDeleted() {} + +private: + void DeleteSessionThink(); + void MarkSessionForDelete( ReplayHandle_t hSession ); + + CUtlLinkedList< ReplayHandle_t, int > m_lstSessionsToDelete; +}; + +//---------------------------------------------------------------------------------------- + + +#endif // BASERECORDINGSESSIONMANAGER_H |