ddnet/src/engine/ghost.h

62 lines
1.4 KiB
C
Raw Normal View History

2017-09-09 00:41:11 +00:00
#ifndef ENGINE_GHOST_H
#define ENGINE_GHOST_H
2020-06-18 16:29:27 +00:00
#include <engine/map.h>
2017-09-09 00:41:11 +00:00
#include <engine/shared/protocol.h>
#include "kernel.h"
class CGhostHeader
2017-09-09 00:41:11 +00:00
{
public:
2017-09-09 00:41:11 +00:00
unsigned char m_aMarker[8];
unsigned char m_Version;
char m_aOwner[MAX_NAME_LENGTH];
2020-06-26 13:17:38 +00:00
char m_aMap[64];
2017-09-09 00:41:11 +00:00
unsigned char m_aCrc[4];
unsigned char m_aNumTicks[4];
unsigned char m_aTime[4];
int GetTime() const
{
return (m_aTime[0] << 24) | (m_aTime[1] << 16) | (m_aTime[2] << 8) | (m_aTime[3]);
}
int GetTicks() const
{
return (m_aNumTicks[0] << 24) | (m_aNumTicks[1] << 16) | (m_aNumTicks[2] << 8) | (m_aNumTicks[3]);
}
2017-09-09 00:41:11 +00:00
};
class IGhostRecorder : public IInterface
{
MACRO_INTERFACE("ghostrecorder", 0)
public:
virtual ~IGhostRecorder() {}
virtual int Start(const char *pFilename, const char *pMap, unsigned MapCrc, const char *pName) = 0;
2017-09-09 00:41:11 +00:00
virtual int Stop(int Ticks, int Time) = 0;
virtual void WriteData(int Type, const void *pData, int Size) = 0;
2017-09-09 00:41:11 +00:00
virtual bool IsRecording() const = 0;
};
class IGhostLoader : public IInterface
{
MACRO_INTERFACE("ghostloader", 0)
public:
virtual ~IGhostLoader() {}
virtual int Load(const char *pFilename, const char *pMap, unsigned Crc) = 0;
2017-09-09 00:41:11 +00:00
virtual void Close() = 0;
virtual const CGhostHeader *GetHeader() const = 0;
virtual bool ReadNextType(int *pType) = 0;
virtual bool ReadData(int Type, void *pData, int Size) = 0;
2017-09-09 00:41:11 +00:00
virtual bool GetGhostInfo(const char *pFilename, CGhostHeader *pGhostHeader, const char *pMap, unsigned Crc) = 0;
2017-09-09 00:41:11 +00:00
};
#endif