forked from nillerusr/source-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcl_replaymanager.h
128 lines (100 loc) · 4.31 KB
/
cl_replaymanager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=======================================================================================//
#ifndef CL_REPLAYMANAGER_H
#define CL_REPLAYMANAGER_H
#ifdef _WIN32
#pragma once
#endif
//----------------------------------------------------------------------------------------
#include "genericpersistentmanager.h"
#include "replay/ireplaymanager.h"
#include "cl_replaycontext.h"
#include "replay/replay.h"
//----------------------------------------------------------------------------------------
class IReplayFactory;
//----------------------------------------------------------------------------------------
//
// Manages and serializes all replays on the client.
//
class CReplayManager : public CGenericPersistentManager< CReplay >,
public IReplayManager
{
typedef CGenericPersistentManager< CReplay > BaseClass;
public:
CReplayManager();
~CReplayManager();
virtual bool Init( CreateInterfaceFn fnCreateFactory );
void Shutdown();
void OnSessionStart();
void OnSessionEnd();
int GetNumReplaysDependentOnSession( ReplayHandle_t hSession );
// IReplayManager
virtual CReplay *GetReplay( ReplayHandle_t hReplay );
virtual void FlagReplayForFlush( CReplay *pReplay, bool bForceImmediate );
virtual int GetUnrenderedReplayCount();
virtual void DeleteReplay( ReplayHandle_t hReplay, bool bNotifyUI );
virtual CReplay *GetPlayingReplay();
virtual CReplay *GetReplayForCurrentLife();
virtual void GetReplays( CUtlLinkedList< CReplay *, int > &lstReplays );
virtual void GetReplaysAsQueryableItems( CUtlLinkedList< IQueryableReplayItem *, int > &lstReplays );
virtual int GetReplayCount() const { return Count(); }
virtual float GetDownloadProgress( const CReplay *pReplay );
virtual const char *GetReplaysDir() const;
void CommitPendingReplayAndBeginDownload();
void CompletePendingReplay();
void AddEventsForListen();
void ClearPendingReplay();
void SanityCheckReplay( CReplay *pReplay );
void SaveDanglingReplay();
void OnClientSideDisconnect();
inline ObjContainer_t &Replays() { return m_vecObjs; }
bool Commit( CReplay *pNewReplay );
void UpdateCurrentReplayDataFromServer();
void OnReplayRecordingCvarChanged();
void AttemptToSetupNewReplay();
CReplay *m_pReplayThisLife; // Valid only between replay completion (ie player death) and player respawn, otherwise NULL
//
// CGenericPersistentManager
//
virtual const char *GetRelativeIndexPath() const;
private:
//
// CGenericPersistentManager
//
virtual const char *GetDebugName() const { return "replay manager"; }
virtual const char *GetIndexFilename() const { return "replays." GENERIC_FILE_EXTENSION; }
virtual CReplay *Create();
virtual int GetVersion() const;
virtual void Think();
virtual IReplayContext *GetReplayContext() const;
virtual bool ShouldLoadObj( const CReplay *pReplay ) const;
virtual void OnObjLoaded( CReplay *pReplay );
//
// CBaseThinker
//
virtual float GetNextThinkTime() const;
void DebugThink();
void InitReplay( CReplay *pReplay );
IReplayFactory *GetReplayFactory( CreateInterfaceFn fnCreateFactory );
void CleanupReplay( CReplay *&pReplay );
void FreeLifeIfNotSaved( CReplay *&pReplay );
CReplay *CreatePendingReplay();
CReplay *m_pPendingReplay; // This is the replay we're currently recording - one which will
// either be committed (via Commit()) or not, depending on whether
// the player chooses to save the replay.
CReplay *m_pReplayLastLife; // The previous life (ie between the player's previous spawn and the current spawn), if any (otherwise NULL)
float m_flPlayerSpawnCreateReplayFailTime;
IReplayFactory *m_pReplayFactory;
};
//----------------------------------------------------------------------------------------
inline CReplay *GetReplay( ReplayHandle_t hReplay )
{
extern CClientReplayContext *g_pClientReplayContextInternal;
return g_pClientReplayContextInternal->m_pReplayManager->GetReplay( hReplay );
}
//----------------------------------------------------------------------------------------
#define FOR_EACH_REPLAY( _i ) FOR_EACH_OBJ( CL_GetReplayManager(), _i )
#define GET_REPLAY_AT( _i ) CL_GetReplayManager()->m_vecObjs[ _i ]
//----------------------------------------------------------------------------------------
#endif // CL_REPLAYMANAGER_H