Merge pull request #7572 from furo321/fix-server-demos

Stop all recording of server demos on shutdown.
This commit is contained in:
Robert Müller 2023-12-02 11:29:13 +00:00 committed by GitHub
commit f9fc85920f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 17 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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();

View file

@ -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();