forked from sears2424/Source-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplay.h
146 lines (121 loc) · 5.75 KB
/
replay.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=======================================================================================//
#ifndef REPLAY_H
#define REPLAY_H
#ifdef _WIN32
#pragma once
#endif
//----------------------------------------------------------------------------------------
#include "replay/iqueryablereplayitem.h"
#include "replay/replaytime.h"
#include "replay/basereplayserializeable.h"
#include "qlimits.h"
#include "utlstring.h"
#include "utlvector.h"
#include "replay/shared_defs.h"
//----------------------------------------------------------------------------------------
class IReplayDownloadEventHandler;
class CReplayScreenshot;
class CReplayPerformance;
//----------------------------------------------------------------------------------------
class CReplay : public CBaseReplaySerializeable,
public IQueryableReplayItem
{
typedef CBaseReplaySerializeable BaseClass;
public:
enum ReplayStatus_t
{
REPLAYSTATUS_INVALID,
REPLAYSTATUS_ERROR,
REPLAYSTATUS_DOWNLOADPHASE, // Multiple sub-states during download state
REPLAYSTATUS_READYTOCONVERT, // Download is complete, ready to convert
REPLAYSTATUS_RENDERING, // Currently rendering the file
REPLAYSTATUS_RENDERED,
REPLAYSTATUS_MAX
};
CReplay();
virtual ~CReplay() {}
//
// IReplaySerializeable
//
virtual const char *GetSubKeyTitle() const;
virtual const char *GetPath() const;
virtual void OnDelete();
virtual bool Read( KeyValues *pIn );
virtual void Write( KeyValues *pOut );
virtual void DumpGameSpecificData() const {}
virtual void Update() {}
// Hooks to allow replays to setup event listeners, etc.
virtual void OnBeginRecording() {}
virtual void OnEndRecording() {}
// Called when a replay is "completed"
virtual void OnComplete();
// Should we allow this replay to be deleted?
virtual bool ShouldAllowDelete() const { return true; }
void AutoNameTitleIfEmpty();
void AddScreenshot( int nWidth, int nHeight, const char *pBaseFilename );
bool HasReconstructedReplay() const;
bool IsSignificantBlock( int iBlockReconstruction ) const; // Does this replay care about the given block?
CReplayPerformance *AddNewPerformance( bool bGenTitle = true, bool bGenFilename = true );
void AddPerformance( KeyValues *pIn );
void AddPerformance( CReplayPerformance *pPerformance );
// Accessors:
inline int GetScreenshotCount() const { return m_vecScreenshots.Count(); }
inline const CReplayScreenshot *GetScreenshot( int i ) const { return m_vecScreenshots[ i ]; }
bool IsDownloaded() const;
inline int GetPerformanceCount() const { return m_vecPerformances.Count(); }
CReplayPerformance *GetPerformance( int i );
const CReplayPerformance *GetPerformance( int i ) const;
inline bool HasPerformance( CReplayPerformance *pPerformance ) { return m_vecPerformances.Find( pPerformance ) != m_vecPerformances.InvalidIndex(); }
bool FindPerformance( CReplayPerformance *pPerformance, int &iResult );
CReplayPerformance *GetPerformanceWithTitle( const wchar_t *pTitle );
inline const char *GetMapName() const { return m_szMapName; }
inline int GetSpawnTick() const { return m_nSpawnTick; }
inline int GetDeathTick() const { return m_nDeathTick; }
// IQueryableReplayItem implementation:
virtual const CReplayTime &GetItemDate() const;
virtual bool IsItemRendered() const;
virtual CReplay *GetItemReplay();
virtual ReplayHandle_t GetItemReplayHandle() const;
virtual QueryableReplayItemHandle_t GetItemHandle() const;
virtual const wchar_t *GetItemTitle() const;
virtual void SetItemTitle( const wchar_t *pTitle );
virtual float GetItemLength() const;
virtual void *GetUserData();
virtual void SetUserData( void* pUserData );
virtual bool IsItemAMovie() const;
// Non-persistent data
mutable IReplayDownloadEventHandler *m_pDownloadEventHandler; // Implemented by replay browser - the reason we've got one per replay rather than
// one per download group is because the browser needs to receive events per-thumbnail
bool m_bSaved; // True as soon as the replay is saved to disk for the first time
bool m_bRequestedByUser; // Did the user request to save this replay?
bool m_bComplete; // Indicates whether the replay is done recording - this should be false
// until the player dies, the round ends, or the level changes
void *m_pUserData;
float m_flNextUpdateTime;
bool m_bDirty;
// Persistent data
ReplayHandle_t m_hSession; // The recording session in which this replay was recorded
char m_szMapName[MAX_OSPATH];
ReplayStatus_t m_nStatus;
const char* m_pFileURL; // In the form <protocol>://<server address>:<port number>/path/file - points to the string in the download group
wchar_t m_wszTitle[MAX_REPLAY_TITLE_LENGTH];
CUtlString m_strKilledBy; // Name of player who killed, if any
int m_nDeathTime;
int m_nSpawnTick;
int m_nDeathTick;
float m_flLength; // The length of the entire replay, including the post-death time, in seconds
bool m_bRendered; // Has the replay been rendered yet?
int m_nPlayerSlot; // Player slot (+1), used to determine which player recorded the demo during playback
int m_nPostDeathRecordTime; // replay_postdeathrecordtime at the time of record
CUtlVector< CReplayScreenshot * > m_vecScreenshots;
CUtlVector< CReplayPerformance * > m_vecPerformances;
int m_iMaxSessionBlockRequired; // The maximum session block required to reconstruct a viewable .dem file from spawn tick until length
CReplayTime m_RecordTime; // Contains time/date when spawn tick was recorded
float m_flStartTime; // Start time (uses engine's host_time)
CUtlString m_strReconstructedFilename;
bool m_bSavedDuringThisSession;
};
//----------------------------------------------------------------------------------------
#endif // REPLAY_H