mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Assert that demo recording/playback are properly started/stopped
Add assertions to check that demo recording/playback is not started when already running. Add assertions to check that demo recording/playback is stopped before the respective demo recorder/player is destroyed.
This commit is contained in:
parent
543e63ee71
commit
a0b708a0b2
|
@ -94,7 +94,7 @@ public:
|
|||
TICK_NEXT, // go to the next tick
|
||||
};
|
||||
|
||||
~IDemoPlayer() {}
|
||||
virtual ~IDemoPlayer() {}
|
||||
virtual void SetSpeed(float Speed) = 0;
|
||||
virtual void SetSpeedIndex(int SpeedIndex) = 0;
|
||||
virtual void AdjustSpeedIndex(int Offset) = 0;
|
||||
|
@ -115,7 +115,7 @@ class IDemoRecorder : public IInterface
|
|||
{
|
||||
MACRO_INTERFACE("demorecorder", 0)
|
||||
public:
|
||||
~IDemoRecorder() {}
|
||||
virtual ~IDemoRecorder() {}
|
||||
virtual bool IsRecording() const = 0;
|
||||
virtual int Stop() = 0;
|
||||
virtual int Length() const = 0;
|
||||
|
|
|
@ -43,9 +43,16 @@ CDemoRecorder::CDemoRecorder(class CSnapshotDelta *pSnapshotDelta, bool NoMapDat
|
|||
m_NoMapData = NoMapData;
|
||||
}
|
||||
|
||||
CDemoRecorder::~CDemoRecorder()
|
||||
{
|
||||
dbg_assert(m_File == 0, "Demo recorder was not stopped");
|
||||
}
|
||||
|
||||
// Record
|
||||
int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, const char *pNetVersion, const char *pMap, SHA256_DIGEST *pSha256, unsigned Crc, const char *pType, unsigned MapSize, unsigned char *pMapData, IOHANDLE MapFile, DEMOFUNC_FILTER pfnFilter, void *pUser)
|
||||
{
|
||||
dbg_assert(m_File == 0, "Demo recorder already recording");
|
||||
|
||||
m_pfnFilter = pfnFilter;
|
||||
m_pUser = pUser;
|
||||
|
||||
|
@ -64,12 +71,6 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con
|
|||
return -1;
|
||||
}
|
||||
|
||||
if(m_File)
|
||||
{
|
||||
io_close(DemoFile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CloseMapFile = false;
|
||||
|
||||
if(MapFile)
|
||||
|
@ -407,6 +408,11 @@ CDemoPlayer::CDemoPlayer(class CSnapshotDelta *pSnapshotDelta)
|
|||
Construct(pSnapshotDelta);
|
||||
}
|
||||
|
||||
CDemoPlayer::~CDemoPlayer()
|
||||
{
|
||||
dbg_assert(m_File == 0, "Demo player not stopped");
|
||||
}
|
||||
|
||||
void CDemoPlayer::Construct(class CSnapshotDelta *pSnapshotDelta)
|
||||
{
|
||||
m_File = 0;
|
||||
|
@ -718,6 +724,8 @@ void CDemoPlayer::Unpause()
|
|||
|
||||
int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, int StorageType)
|
||||
{
|
||||
dbg_assert(m_File == 0, "Demo player already playing");
|
||||
|
||||
m_pConsole = pConsole;
|
||||
m_File = pStorage->OpenFile(pFilename, IOFLAG_READ, StorageType);
|
||||
if(!m_File)
|
||||
|
|
|
@ -37,6 +37,7 @@ class CDemoRecorder : public IDemoRecorder
|
|||
public:
|
||||
CDemoRecorder(class CSnapshotDelta *pSnapshotDelta, bool NoMapData = false);
|
||||
CDemoRecorder() {}
|
||||
~CDemoRecorder() override;
|
||||
|
||||
int Start(class IStorage *pStorage, class IConsole *pConsole, const char *pFilename, const char *pNetversion, const char *pMap, SHA256_DIGEST *pSha256, unsigned MapCrc, const char *pType, unsigned MapSize, unsigned char *pMapData, IOHANDLE MapFile = nullptr, DEMOFUNC_FILTER pfnFilter = nullptr, void *pUser = nullptr);
|
||||
int Stop() override;
|
||||
|
@ -126,6 +127,7 @@ private:
|
|||
public:
|
||||
CDemoPlayer(class CSnapshotDelta *pSnapshotDelta);
|
||||
CDemoPlayer(class CSnapshotDelta *pSnapshotDelta, TUpdateIntraTimesFunc &&UpdateIntraTimesFunc);
|
||||
~CDemoPlayer() override;
|
||||
|
||||
void Construct(class CSnapshotDelta *pSnapshotDelta);
|
||||
|
||||
|
|
Loading…
Reference in a new issue