mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge pull request #7572 from furo321/fix-server-demos
Stop all recording of server demos on shutdown.
This commit is contained in:
commit
f9fc85920f
|
@ -245,6 +245,7 @@ public:
|
|||
virtual void StartRecord(int ClientID) = 0;
|
||||
virtual void StopRecord(int ClientID) = 0;
|
||||
virtual bool IsRecording(int ClientID) = 0;
|
||||
virtual void StopDemos() = 0;
|
||||
|
||||
virtual void GetClientAddr(int ClientID, NETADDR *pAddr) const = 0;
|
||||
|
||||
|
|
|
@ -2581,23 +2581,6 @@ int CServer::LoadMap(const char *pMapName)
|
|||
if(!m_pMap->Load(aBuf))
|
||||
return 0;
|
||||
|
||||
// stop recording when we change map
|
||||
for(int i = 0; i < MAX_CLIENTS + 1; i++)
|
||||
{
|
||||
if(!m_aDemoRecorder[i].IsRecording())
|
||||
continue;
|
||||
|
||||
m_aDemoRecorder[i].Stop();
|
||||
|
||||
// remove tmp demos
|
||||
if(i < MAX_CLIENTS)
|
||||
{
|
||||
char aPath[256];
|
||||
str_format(aPath, sizeof(aPath), "demos/%s_%d_%d_tmp.demo", m_aCurrentMap, m_NetServer.Address().port, i);
|
||||
Storage()->RemoveFile(aPath, IStorage::TYPE_SAVE);
|
||||
}
|
||||
}
|
||||
|
||||
// reinit snapshot ids
|
||||
m_IDPool.TimeoutIDs();
|
||||
|
||||
|
@ -3451,6 +3434,25 @@ bool CServer::IsRecording(int ClientID)
|
|||
return m_aDemoRecorder[ClientID].IsRecording();
|
||||
}
|
||||
|
||||
void CServer::StopDemos()
|
||||
{
|
||||
for(int i = 0; i < MAX_CLIENTS + 1; i++)
|
||||
{
|
||||
if(!m_aDemoRecorder[i].IsRecording())
|
||||
continue;
|
||||
|
||||
m_aDemoRecorder[i].Stop();
|
||||
|
||||
// remove tmp demos
|
||||
if(i < MAX_CLIENTS)
|
||||
{
|
||||
char aPath[256];
|
||||
str_format(aPath, sizeof(aPath), "demos/%s_%d_%d_tmp.demo", m_aCurrentMap, m_NetServer.Address().port, i);
|
||||
Storage()->RemoveFile(aPath, IStorage::TYPE_SAVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CServer::ConRecord(IConsole::IResult *pResult, void *pUser)
|
||||
{
|
||||
CServer *pServer = (CServer *)pUser;
|
||||
|
|
|
@ -410,6 +410,7 @@ public:
|
|||
void StartRecord(int ClientID) override;
|
||||
void StopRecord(int ClientID) override;
|
||||
bool IsRecording(int ClientID) override;
|
||||
void StopDemos() override;
|
||||
|
||||
int Run();
|
||||
|
||||
|
|
|
@ -3950,6 +3950,9 @@ void CGameContext::OnShutdown(void *pPersistentData)
|
|||
aio_free(m_pTeeHistorianFile);
|
||||
}
|
||||
|
||||
// Stop any demos being recorded.
|
||||
Server()->StopDemos();
|
||||
|
||||
DeleteTempfile();
|
||||
ConfigManager()->ResetGameSettings();
|
||||
Collision()->Dest();
|
||||
|
|
Loading…
Reference in a new issue