DDraceNetwork Documentation
Loading...
Searching...
No Matches
ghost.h
Go to the documentation of this file.
1/* (c) Rajh, Redix and Sushi. */
2
3#ifndef GAME_CLIENT_COMPONENTS_GHOST_H
4#define GAME_CLIENT_COMPONENTS_GHOST_H
5
6#include <generated/protocol.h>
7
10#include <game/client/render.h>
11
13
14enum
15{
20};
21
29
44
46{
47 int m_Tick;
48};
49
50class CGhost : public CComponent
51{
52private:
53 enum
54 {
56 };
57
59 {
62
63 std::vector<CGhostCharacter *> m_vpChunks;
64
65 public:
68 CGhostPath(const CGhostPath &Other) = delete;
70
71 CGhostPath(CGhostPath &&Other) noexcept;
73
74 void Reset(int ChunkSize = 25 * 60); // one minute with default snap rate
75 void SetSize(int Items);
76 int Size() const { return m_NumItems; }
77
78 void Add(const CGhostCharacter &Char);
80 };
81
83 {
84 public:
85 std::shared_ptr<CManagedTeeRenderInfo> m_pManagedTeeRenderInfo;
91
93
94 bool Empty() const { return m_Path.Size() == 0; }
95 void Reset()
96 {
98 m_Path.Reset();
99 m_StartTick = -1;
100 m_PlaybackPos = -1;
101 }
102 };
103
104 static const char *ms_pGhostDir;
105
108
111
113
117 bool m_Recording = false;
118 bool m_Rendering = false;
120
121 static void SetGhostSkinData(CGhostSkin *pSkin, const char *pSkinName, int UseCustomColor, int ColorBody, int ColorFeet);
124
125 void GetPath(char *pBuf, int Size, const char *pPlayerName, int Time = -1) const;
126
128 int GetSlot() const;
129
130 void CheckStart();
131 void CheckStartLocal(bool Predicted);
132 void TryRenderStart(int Tick, bool ServerControl);
133
134 void StartRecord(int Tick);
135 void StopRecord(int Time = -1);
136 void StartRender(int Tick);
137 void StopRender();
138
140
141 static void ConGPlay(IConsole::IResult *pResult, void *pUserData);
142
143public:
145
146 int Sizeof() const override { return sizeof(*this); }
147
148 void OnRender() override;
149 void OnConsoleInit() override;
150 void OnReset() override;
151 void OnMessage(int MsgType, void *pRawMsg) override;
152 void OnMapLoad() override;
153 void OnShutdown() override;
154 void OnNewSnapshot() override;
155
157
158 int FreeSlots() const;
159 int Load(const char *pFilename);
160 void Unload(int Slot);
161 void UnloadAll();
162
164
165 const char *GetGhostDir() const { return ms_pGhostDir; }
166
167 class IGhostLoader *GhostLoader() const { return m_pGhostLoader; }
169};
170
171#endif
Definition component.h:165
Definition ghost.h:83
std::shared_ptr< CManagedTeeRenderInfo > m_pManagedTeeRenderInfo
Definition ghost.h:85
void Reset()
Definition ghost.h:95
char m_aPlayer[MAX_NAME_LENGTH]
Definition ghost.h:89
CGhostPath m_Path
Definition ghost.h:87
int m_PlaybackPos
Definition ghost.h:90
CGhostItem()
Definition ghost.h:92
CGhostSkin m_Skin
Definition ghost.h:86
bool Empty() const
Definition ghost.h:94
int m_StartTick
Definition ghost.h:88
Definition ghost.h:59
std::vector< CGhostCharacter * > m_vpChunks
Definition ghost.h:63
CGhostPath(const CGhostPath &Other)=delete
CGhostPath & operator=(const CGhostPath &Other)=delete
~CGhostPath()
Definition ghost.h:67
CGhostCharacter * Get(int Index)
Definition ghost.cpp:115
void SetSize(int Items)
Definition ghost.cpp:94
int m_NumItems
Definition ghost.h:61
int Size() const
Definition ghost.h:76
int m_ChunkSize
Definition ghost.h:60
void Add(const CGhostCharacter &Char)
Definition ghost.cpp:109
CGhostPath()
Definition ghost.h:66
void Reset(int ChunkSize=25 *60)
Definition ghost.cpp:85
Definition ghost.h:51
int FreeSlots() const
Definition ghost.cpp:176
void OnConsoleInit() override
Definition ghost.cpp:579
int Load(const char *pFilename)
Definition ghost.cpp:455
int GetSlot() const
Definition ghost.cpp:168
class IGhostRecorder * m_pGhostRecorder
Definition ghost.h:107
void AddInfos(const CNetObj_Character *pChar, const CNetObj_DDNetCharacter *pDDnetChar)
Definition ghost.cpp:145
CGhostItem m_aActiveGhosts[MAX_ACTIVE_GHOSTS]
Definition ghost.h:109
void StopRecord(int Time=-1)
Definition ghost.cpp:400
int m_StartRenderTick
Definition ghost.h:115
void StopRender()
Definition ghost.cpp:449
void OnNewPredictedSnapshot()
Definition ghost.cpp:291
int Sizeof() const override
Definition ghost.h:146
void UpdateTeeRenderInfo(CGhostItem &Ghost)
Definition ghost.cpp:371
void Unload(int Slot)
Definition ghost.cpp:542
bool m_Rendering
Definition ghost.h:118
bool m_RenderingStartedByServer
Definition ghost.h:119
void TryRenderStart(int Tick, bool ServerControl)
Definition ghost.cpp:260
void OnMapLoad() override
Definition ghost.cpp:643
class IGhostRecorder * GhostRecorder() const
Definition ghost.h:168
@ MAX_ACTIVE_GHOSTS
Definition ghost.h:55
void StartRender(int Tick)
Definition ghost.cpp:441
const char * GetGhostDir() const
Definition ghost.h:165
void OnMessage(int MsgType, void *pRawMsg) override
Definition ghost.cpp:587
void GetPath(char *pBuf, int Size, const char *pPlayerName, int Time=-1) const
Definition ghost.cpp:125
char m_aTmpFilename[IO_MAX_PATH_LENGTH]
Definition ghost.h:112
int m_NewRenderTick
Definition ghost.h:114
void CheckStart()
Definition ghost.cpp:185
void UnloadAll()
Definition ghost.cpp:547
void OnShutdown() override
Definition ghost.cpp:638
static void SetGhostSkinData(CGhostSkin *pSkin, const char *pSkinName, int UseCustomColor, int ColorBody, int ColorFeet)
Definition ghost.cpp:21
static void ConGPlay(IConsole::IResult *pResult, void *pUserData)
Definition ghost.cpp:573
int m_LastDeathTick
Definition ghost.h:116
void CheckStartLocal(bool Predicted)
Definition ghost.cpp:211
CGhostItem m_CurGhost
Definition ghost.h:110
static void GetGhostCharacter(CGhostCharacter *pGhostChar, const CNetObj_Character *pChar, const CNetObj_DDNetCharacter *pDDnetChar)
Definition ghost.cpp:29
void OnNewSnapshot() override
Definition ghost.cpp:272
void OnReset() override
Definition ghost.cpp:631
bool m_AllowRestart
Definition ghost.h:144
void SaveGhost(CMenus::CGhostItem *pItem)
Definition ghost.cpp:553
static const char * ms_pGhostDir
Definition ghost.h:104
class IGhostLoader * m_pGhostLoader
Definition ghost.h:106
static void GetNetObjCharacter(CNetObj_Character *pChar, const CGhostCharacter *pGhostChar)
Definition ghost.cpp:50
class IGhostLoader * GhostLoader() const
Definition ghost.h:167
bool m_Recording
Definition ghost.h:117
void OnRender() override
Definition ghost.cpp:305
void StartRecord(int Tick)
Definition ghost.cpp:388
Definition console.h:47
Definition ghost.h:32
Definition ghost.h:19
Definition vmath.h:15
@ MAX_NAME_LENGTH
Definition protocol.h:98
@ GHOSTDATA_TYPE_START_TICK
Definition ghost.h:19
@ GHOSTDATA_TYPE_CHARACTER_NO_TICK
Definition ghost.h:17
@ GHOSTDATA_TYPE_CHARACTER
Definition ghost.h:18
@ GHOSTDATA_TYPE_SKIN
Definition ghost.h:16
Definition ghost.h:31
int m_HookState
Definition ghost.h:39
int m_HookY
Definition ghost.h:41
int m_VelX
Definition ghost.h:34
int m_HookX
Definition ghost.h:40
int m_VelY
Definition ghost.h:35
int m_Angle
Definition ghost.h:36
int m_Direction
Definition ghost.h:37
int m_X
Definition ghost.h:32
int m_Weapon
Definition ghost.h:38
int m_AttackTick
Definition ghost.h:42
int m_Y
Definition ghost.h:33
Definition ghost.h:46
int m_Tick
Definition ghost.h:47
Definition ghost.h:23
int m_ColorBody
Definition ghost.h:26
int m_UseCustomColor
Definition ghost.h:25
int m_aSkin[6]
Definition ghost.h:24
int m_ColorFeet
Definition ghost.h:27
Definition menus.h:723
Definition protocol.h:497
Definition protocol.h:545
constexpr auto IO_MAX_PATH_LENGTH
Definition types.h:49