diff --git a/src/engine/client.h b/src/engine/client.h index 100ed408b..df69fbb54 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -76,7 +76,7 @@ public: virtual void Disconnect() = 0; virtual void Quit() = 0; virtual const char *DemoPlayer_Play(const char *pFilename, int StorageType) = 0; - virtual void DemoRecorder_Start(const char *pFilename) = 0; + virtual void DemoRecorder_Start(const char *pFilename, bool WithTimestamp) = 0; virtual void DemoRecorder_Stop() = 0; // networking diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 3db258132..b9ab18afa 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1926,14 +1926,21 @@ void CClient::Con_Play(IConsole::IResult *pResult, void *pUserData) pSelf->DemoPlayer_Play(pResult->GetString(0), IStorage::TYPE_ALL); } -void CClient::DemoRecorder_Start(const char *pFilename) +void CClient::DemoRecorder_Start(const char *pFilename, bool WithTimestamp) { if(State() != IClient::STATE_ONLINE) m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demorec/record", "client is not online"); else { - char aFilename[512]; - str_format(aFilename, sizeof(aFilename), "demos/%s.demo", pFilename); + char aFilename[128]; + if(WithTimestamp) + { + char aDate[20]; + str_timestamp(aDate, sizeof(aDate)); + str_format(aFilename, sizeof(aFilename), "demos/%s_%s.demo", pFilename, aDate); + } + else + str_format(aFilename, sizeof(aFilename), "demos/%s.demo", pFilename); m_DemoRecorder.Start(Storage(), m_pConsole, aFilename, GameClient()->NetVersion(), m_aCurrentMap, m_CurrentMapCrc, "client"); } } @@ -1946,7 +1953,10 @@ void CClient::DemoRecorder_Stop() void CClient::Con_Record(IConsole::IResult *pResult, void *pUserData) { CClient *pSelf = (CClient *)pUserData; - pSelf->DemoRecorder_Start(pResult->GetString(0)); + if(pResult->NumArguments()) + pSelf->DemoRecorder_Start(pResult->GetString(0), false); + else + pSelf->DemoRecorder_Start("demo", true); } void CClient::Con_StopRecord(IConsole::IResult *pResult, void *pUserData) @@ -1965,7 +1975,7 @@ void CClient::RegisterCommands() m_pConsole->Register("bans", "", CFGFLAG_SERVER, 0, 0, "Show banlist"); m_pConsole->Register("status", "", CFGFLAG_SERVER, 0, 0, "List players"); m_pConsole->Register("shutdown", "", CFGFLAG_SERVER, 0, 0, "Shut down"); - m_pConsole->Register("record", "s", CFGFLAG_SERVER, 0, 0, "Record to a file"); + m_pConsole->Register("record", "?s", CFGFLAG_SERVER, 0, 0, "Record to a file"); m_pConsole->Register("stoprecord", "", CFGFLAG_SERVER, 0, 0, "Stop recording"); m_pConsole->Register("reload", "", CFGFLAG_SERVER, 0, 0, "Reload the map"); @@ -1979,7 +1989,7 @@ void CClient::RegisterCommands() m_pConsole->Register("rcon", "r", CFGFLAG_CLIENT, Con_Rcon, this, "Send specified command to rcon"); m_pConsole->Register("rcon_auth", "s", CFGFLAG_CLIENT, Con_RconAuth, this, "Authenticate to rcon"); m_pConsole->Register("play", "r", CFGFLAG_CLIENT, Con_Play, this, "Play the file specified"); - m_pConsole->Register("record", "s", CFGFLAG_CLIENT, Con_Record, this, "Record to the file"); + m_pConsole->Register("record", "?s", CFGFLAG_CLIENT, Con_Record, this, "Record to the file"); m_pConsole->Register("stoprecord", "", CFGFLAG_CLIENT, Con_StopRecord, this, "Stop recording"); m_pConsole->Register("add_favorite", "s", CFGFLAG_CLIENT, Con_AddFavorite, this, "Add a server as a favorite"); diff --git a/src/engine/client/client.h b/src/engine/client/client.h index b6a82199c..8cfd8c579 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -284,7 +284,7 @@ public: void RegisterCommands(); const char *DemoPlayer_Play(const char *pFilename, int StorageType); - void DemoRecorder_Start(const char *pFilename); + void DemoRecorder_Start(const char *pFilename, bool WithTimestamp); void DemoRecorder_Stop(); virtual class CEngine *Engine() { return &m_Engine; } diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 16efe84d0..d73fe4dff 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1405,9 +1405,18 @@ void CServer::ConShutdown(IConsole::IResult *pResult, void *pUser) void CServer::ConRecord(IConsole::IResult *pResult, void *pUser) { - char aFilename[512]; - str_format(aFilename, sizeof(aFilename), "demos/%s.demo", pResult->GetString(0)); - ((CServer *)pUser)->m_DemoRecorder.Start(((CServer *)pUser)->Storage(), ((CServer *)pUser)->Console(), aFilename, ((CServer *)pUser)->GameServer()->NetVersion(), ((CServer *)pUser)->m_aCurrentMap, ((CServer *)pUser)->m_CurrentMapCrc, "server"); + CServer* pServer = (CServer *)pUser; + char aFilename[128]; + + if(pResult->NumArguments()) + str_format(aFilename, sizeof(aFilename), "demos/%s.demo", pResult->GetString(0)); + else + { + char aDate[20]; + str_timestamp(aDate, sizeof(aDate)); + str_format(aFilename, sizeof(aFilename), "demos/demo_%s.demo", aDate); + } + pServer->m_DemoRecorder.Start(pServer->Storage(), pServer->Console(), aFilename, pServer->GameServer()->NetVersion(), pServer->m_aCurrentMap, pServer->m_CurrentMapCrc, "server"); } void CServer::ConStopRecord(IConsole::IResult *pResult, void *pUser) @@ -1445,7 +1454,7 @@ void CServer::RegisterCommands() Console()->Register("status", "", CFGFLAG_SERVER, ConStatus, this, ""); Console()->Register("shutdown", "", CFGFLAG_SERVER, ConShutdown, this, ""); - Console()->Register("record", "s", CFGFLAG_SERVER|CFGFLAG_STORE, ConRecord, this, ""); + Console()->Register("record", "?s", CFGFLAG_SERVER|CFGFLAG_STORE, ConRecord, this, ""); Console()->Register("stoprecord", "", CFGFLAG_SERVER, ConStopRecord, this, ""); Console()->Register("reload", "", CFGFLAG_SERVER, ConMapReload, this, ""); diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 14a19f124..187a061e1 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -99,14 +99,7 @@ void CMenus::RenderGame(CUIRect MainView) if(DoButton_Menu(&s_DemoButton, Localize(Recording ? "Stop record" : "Record demo"), 0, &Button)) // Localize("Stop record");Localize("Record demo"); { if(!Recording) - { - char aFilename[128]; - char aDate[20]; - - str_timestamp(aDate, sizeof(aDate)); - str_format(aFilename, sizeof(aFilename), "demo_%s.png", aDate); - Client()->DemoRecorder_Start(aFilename); - } + Client()->DemoRecorder_Start("demo", true); else Client()->DemoRecorder_Stop(); }