]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Add "renamedemo" command to set a different name for currently recording demo.
authorDes <xon@damianv.com.ar>
Fri, 9 Aug 2024 16:30:57 +0000 (13:30 -0300)
committerDes <xon@damianv.com.ar>
Fri, 9 Aug 2024 16:30:57 +0000 (13:30 -0300)
cl_demo.c
client.h

index a2ee5f9257c5e7ea839aa10c16e8be91773c46b9..38e9c1219a674a67f6e096716bd7f73dd2dd15f6 100644 (file)
--- 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 <demoname>
+====================
+*/
+void CL_RenameDemo_f(cmd_state_t *cmd)
+{
+       int c;
+       char name[MAX_OSPATH];
+
+       c = Cmd_Argc(cmd);
+       if (c != 2)
+       {
+               Con_Print("renamedemo <demoname>\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];
@@ -737,6 +771,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)");
index 3cfaf5bfc14fc1861196d66aaf008b2bbc4b4dc0..87aeaafbe67e7958e315f7bde602d4b33baf47a1 100644 (file)
--- 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);