]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
cl_demo: Move demo playback functionality to a separate function
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 14 May 2021 16:22:44 +0000 (16:22 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 14 May 2021 16:22:44 +0000 (16:22 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13137 d7cf8633-e32d-0410-b094-e92efae38249

cl_demo.c
client.h

index f8fbe5b5b3ff65862093762106da16ddda50763f..a962785fbf79e8f8fe178b562fce1b70c0c143b5 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -401,29 +401,15 @@ void CL_Record_f(cmd_state_t *cmd)
        cls.demo_lastcsprogscrc = -1;
 }
 
-
-/*
-====================
-CL_PlayDemo_f
-
-playdemo [demoname]
-====================
-*/
-void CL_PlayDemo_f(cmd_state_t *cmd)
+void CL_PlayDemo(const char *demo)
 {
-       char    name[MAX_QPATH];
+       char name[MAX_QPATH];
        int c;
        qbool neg = false;
        qfile_t *f;
 
-       if (Cmd_Argc(cmd) != 2)
-       {
-               Con_Print("playdemo <demoname> : plays a demo\n");
-               return;
-       }
-
        // open the demo file
-       strlcpy (name, Cmd_Argv(cmd, 1), sizeof (name));
+       strlcpy (name, demo, sizeof (name));
        FS_DefaultExtension (name, ".dem", sizeof (name));
        f = FS_OpenVirtualFile(name, false);
        if (!f)
@@ -466,6 +452,24 @@ void CL_PlayDemo_f(cmd_state_t *cmd)
        cls.demostarting = false;
 }
 
+/*
+====================
+CL_PlayDemo_f
+
+playdemo [demoname]
+====================
+*/
+void CL_PlayDemo_f(cmd_state_t *cmd)
+{
+       if (Cmd_Argc(cmd) != 2)
+       {
+               Con_Print("playdemo <demoname> : plays a demo\n");
+               return;
+       }
+
+       CL_PlayDemo(Cmd_Argv(cmd, 1));
+}
+
 typedef struct
 {
        int frames;
@@ -605,7 +609,7 @@ void CL_TimeDemo_f(cmd_state_t *cmd)
 
        srand(0); // predictable random sequence for benchmarking
 
-       CL_PlayDemo_f (cmd);
+       CL_PlayDemo(Cmd_Argv(cmd, 1));
 
 // cls.td_starttime will be grabbed at the second frame of the demo, so
 // all the loading time doesn't get counted
index 5335bb0a4cd958eb4fab19bdfd75fb85fcebb987..8e6d0f50dba4625435d23164ce20accc2242c33d 100644 (file)
--- a/client.h
+++ b/client.h
@@ -577,7 +577,7 @@ typedef struct client_static_s
        int demonum;
        // list of demos in loop
        char demos[MAX_DEMOS][MAX_DEMONAME];
-       // the actively playing demo (set by CL_PlayDemo_f)
+       // the actively playing demo (set by CL_PlayDemo)
        char demoname[MAX_QPATH];
 
 // demo recording info must be here, because record is started before
@@ -1299,6 +1299,7 @@ void CL_WriteDemoMessage(sizebuf_t *mesage);
 void CL_CutDemo(unsigned char **buf, fs_offset_t *filesize);
 void CL_PasteDemo(unsigned char **buf, fs_offset_t *filesize);
 
+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);