2017-09-13 20:35:09 +00:00
|
|
|
#include <engine/console.h>
|
2017-09-12 12:58:44 +00:00
|
|
|
#include <engine/shared/packer.h>
|
|
|
|
#include <engine/shared/protocol.h>
|
|
|
|
#include <game/generated/protocol.h>
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
2017-09-13 20:35:09 +00:00
|
|
|
struct CConfiguration;
|
|
|
|
class CTuningParams;
|
2017-11-18 02:08:16 +00:00
|
|
|
class CUuidManager;
|
2017-09-13 20:35:09 +00:00
|
|
|
|
2017-09-12 12:58:44 +00:00
|
|
|
class CTeeHistorian
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef void (*WRITE_CALLBACK)(const void *pData, int DataSize, void *pUser);
|
|
|
|
|
|
|
|
struct CGameInfo
|
|
|
|
{
|
|
|
|
CUuid m_GameUuid;
|
|
|
|
const char *m_pServerVersion;
|
|
|
|
time_t m_StartTime;
|
|
|
|
|
|
|
|
const char *m_pServerName;
|
|
|
|
int m_ServerPort;
|
|
|
|
const char *m_pGameType;
|
|
|
|
|
|
|
|
const char *m_pMapName;
|
|
|
|
int m_MapSize;
|
|
|
|
int m_MapCrc;
|
2017-09-13 20:35:09 +00:00
|
|
|
|
|
|
|
CConfiguration *m_pConfig;
|
|
|
|
CTuningParams *m_pTuning;
|
2017-11-18 02:08:16 +00:00
|
|
|
CUuidManager *m_pUuids;
|
2017-09-12 12:58:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
CTeeHistorian();
|
|
|
|
|
|
|
|
void Reset(const CGameInfo *pGameInfo, WRITE_CALLBACK pfnWriteCallback, void *pUser);
|
|
|
|
void Finish();
|
|
|
|
|
|
|
|
bool Starting() const { return m_State == STATE_START; }
|
|
|
|
|
|
|
|
void BeginTick(int Tick);
|
|
|
|
|
|
|
|
void BeginPlayers();
|
|
|
|
void RecordPlayer(int ClientID, const CNetObj_CharacterCore *pChar);
|
|
|
|
void RecordDeadPlayer(int ClientID);
|
|
|
|
void EndPlayers();
|
|
|
|
|
|
|
|
void BeginInputs();
|
|
|
|
void RecordPlayerInput(int ClientID, const CNetObj_PlayerInput *pInput);
|
2017-09-13 20:35:09 +00:00
|
|
|
void RecordPlayerMessage(int ClientID, const void *pMsg, int MsgSize);
|
|
|
|
void RecordPlayerJoin(int ClientID);
|
|
|
|
void RecordPlayerDrop(int ClientID, const char *pReason);
|
|
|
|
void RecordConsoleCommand(int ClientID, int FlagMask, const char *pCmd, IConsole::IResult *pResult);
|
2017-11-18 02:08:16 +00:00
|
|
|
void RecordTestExtra();
|
2017-09-12 12:58:44 +00:00
|
|
|
void EndInputs();
|
|
|
|
|
|
|
|
void EndTick();
|
|
|
|
|
2017-09-18 16:26:37 +00:00
|
|
|
int m_Debug; // Possible values: 0, 1, 2.
|
2017-09-12 12:58:44 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void WriteHeader(const CGameInfo *pGameInfo);
|
2017-11-18 02:08:16 +00:00
|
|
|
void WriteExtra(CUuid Uuid, const void *pData, int DataSize);
|
2017-09-18 16:26:37 +00:00
|
|
|
void EnsureTickWrittenPlayerData(int ClientID);
|
|
|
|
void EnsureTickWritten();
|
2017-09-12 12:58:44 +00:00
|
|
|
void WriteTick();
|
|
|
|
void Write(const void *pData, int DataSize);
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
STATE_START,
|
|
|
|
STATE_BEFORE_TICK,
|
|
|
|
STATE_BEFORE_PLAYERS,
|
|
|
|
STATE_PLAYERS,
|
|
|
|
STATE_BEFORE_INPUTS,
|
|
|
|
STATE_INPUTS,
|
|
|
|
STATE_BEFORE_ENDTICK,
|
|
|
|
NUM_STATES,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CPlayer
|
|
|
|
{
|
|
|
|
bool m_Alive;
|
|
|
|
int m_X;
|
|
|
|
int m_Y;
|
|
|
|
|
|
|
|
CNetObj_PlayerInput m_Input;
|
|
|
|
bool m_InputExists;
|
|
|
|
};
|
|
|
|
|
|
|
|
WRITE_CALLBACK m_pfnWriteCallback;
|
|
|
|
void *m_pWriteCallbackUserdata;
|
|
|
|
|
|
|
|
int m_State;
|
|
|
|
|
|
|
|
int m_LastWrittenTick;
|
|
|
|
bool m_TickWritten;
|
|
|
|
int m_Tick;
|
|
|
|
int m_PrevMaxClientID;
|
|
|
|
int m_MaxClientID;
|
|
|
|
CPlayer m_aPrevPlayers[MAX_CLIENTS];
|
|
|
|
};
|