From: Des Date: Fri, 9 Aug 2024 16:30:57 +0000 (-0300) Subject: Add "renamedemo" command to set a different name for currently recording demo. X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2e4d116fb2ce145d64251d40da0cb71520da79dd;p=xonotic%2Fdarkplaces.git Add "renamedemo" command to set a different name for currently recording demo. --- diff --git a/cl_demo.c b/cl_demo.c index 0f42a7d0..1e1c8935 100644 --- a/cl_demo.c +++ b/cl_demo.c @@ -410,6 +410,40 @@ void CL_Record_f(cmd_state_t *cmd) cls.demo_lastcsprogscrc = -1; } +/* +==================== +CL_RenameDemo_f + +renamedemo +==================== +*/ +void CL_RenameDemo_f(cmd_state_t *cmd) +{ + int c; + char name[MAX_OSPATH]; + + c = Cmd_Argc(cmd); + if (c != 2) + { + Con_Print("renamedemo \n"); + return; + } + if (!cls.demorecording) + { + Con_Print("Not recording a demo.\n"); + return; + } + if (strstr(Cmd_Argv(cmd, 1), "..")) + { + Con_Print("Relative pathnames are not allowed.\n"); + return; + } + // get the demo name + dp_strlcpy (name, Cmd_Argv(cmd, 1), sizeof (name)); + FS_DefaultExtension (name, ".dem", sizeof (name)); + FS_RenameOnClose(cls.demofile, name); +} + void CL_PlayDemo(const char *demo) { char name[MAX_QPATH]; @@ -738,6 +772,7 @@ void CL_Demo_Init(void) { Cmd_AddCommand(CF_CLIENT, "record", CL_Record_f, "record a demo"); Cmd_AddCommand(CF_CLIENT, "stop", CL_Stop_f, "stop recording or playing a demo"); + Cmd_AddCommand(CF_CLIENT, "renamedemo", CL_RenameDemo_f, "rename currently recording demo on finish"); Cmd_AddCommand(CF_CLIENT, "playdemo", CL_PlayDemo_f, "watch a demo file"); Cmd_AddCommand(CF_CLIENT, "timedemo", CL_TimeDemo_f, "play back a demo as fast as possible and save statistics to benchmark.log"); Cmd_AddCommand(CF_CLIENT, "startdemos", CL_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)"); diff --git a/client.h b/client.h index 3cfaf5bf..87aeaafb 100644 --- a/client.h +++ b/client.h @@ -1311,6 +1311,7 @@ void CL_PlayDemo(const char *demo); void CL_NextDemo(void); void CL_Stop_f(cmd_state_t *cmd); void CL_Record_f(cmd_state_t *cmd); +void CL_RenameDemo_f(cmd_state_t *cmd); void CL_PlayDemo_f(cmd_state_t *cmd); void CL_TimeDemo_f(cmd_state_t *cmd);