]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Autodemo : stopped auto demos from trampling manual ones
authorReki <spiper212@gmail.com>
Tue, 25 May 2021 19:12:42 +0000 (15:12 -0400)
committerReki <spiper212@gmail.com>
Tue, 25 May 2021 19:12:42 +0000 (15:12 -0400)
cl_demo.c
cl_parse.c
client.h

index a3be2148d09709c6ab33208eec19313ea9e0f585..8f65fd21a7db33dfb3ea79b732e0e0181f4fe3ec 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -395,7 +395,8 @@ void CL_Record_f(cmd_state_t *cmd)
 
        cls.forcetrack = track;
        FS_Printf(cls.demofile, "%i\n", cls.forcetrack);
-
+       
+       cls.demorecording_isauto = false;
        cls.demorecording = true;
        cls.demo_lastcsprogssize = -1;
        cls.demo_lastcsprogscrc = -1;
index 5707a3230c7ae3391afeab94aa7d07d85d7fe1a2..2703c677fbe83c673231d151666ae52444cea504 100644 (file)
@@ -1910,42 +1910,58 @@ static void CL_ParseServerInfo (void)
 
                // check memory integrity
                Mem_CheckSentinelsGlobal();
-
+       
+       // Reki 5-25-21: the comment below this is a lie in default DP
        // if cl_autodemo is set, automatically start recording a demo if one isn't being recorded already
                if (cl_autodemo.integer && cls.netcon && cls.protocol != PROTOCOL_QUAKEWORLD)
                {
-                       char demofile[MAX_OSPATH];
-
+                       int record_autodemo = false;
+                       
                        if (cls.demorecording)
                        {
-                               // finish the previous level's demo file
-                               CL_Stop_f(cmd_client);
+                               if (cls.demorecording_isauto)
+                               {
+                                       // Reki 5-25-21: we only do this if it's an autodemo
+                                       // finish the previous level's demo file
+                                       CL_Stop_f(cmd_client);
+                                       record_autodemo = true;
+                               }
+                       }
+                       else
+                       {
+                               record_autodemo = true;
                        }
+                       
+                       if (record_autodemo)
+                       {
+                               char demofile[MAX_OSPATH];
 
-                       // start a new demo file
-                       dpsnprintf (demofile, sizeof(demofile), "%s_%s.dem", Sys_TimeString (cl_autodemo_nameformat.string), cl.worldbasename);
+                               // start a new demo file
+                               dpsnprintf (demofile, sizeof(demofile), "%s_%s.dem", Sys_TimeString (cl_autodemo_nameformat.string), cl.worldbasename);
 
-                       Con_Printf ("Auto-recording to %s.\n", demofile);
+                               Con_Printf ("Auto-recording to %s.\n", demofile);
 
-                       // Reset bit 0 for every new demo
-                       Cvar_SetValueQuick(&cl_autodemo_delete,
-                               (cl_autodemo_delete.integer & ~0x1)
-                               |
-                               ((cl_autodemo_delete.integer & 0x2) ? 0x1 : 0)
-                       );
+                               // Reset bit 0 for every new demo
+                               Cvar_SetValueQuick(&cl_autodemo_delete,
+                                       (cl_autodemo_delete.integer & ~0x1)
+                                       |
+                                       ((cl_autodemo_delete.integer & 0x2) ? 0x1 : 0)
+                               );
 
-                       cls.demofile = FS_OpenRealFile(demofile, "wb", false);
-                       if (cls.demofile)
-                       {
-                               cls.forcetrack = -1;
-                               FS_Printf (cls.demofile, "%i\n", cls.forcetrack);
-                               cls.demorecording = true;
-                               strlcpy(cls.demoname, demofile, sizeof(cls.demoname));
-                               cls.demo_lastcsprogssize = -1;
-                               cls.demo_lastcsprogscrc = -1;
+                               cls.demofile = FS_OpenRealFile(demofile, "wb", false);
+                               if (cls.demofile)
+                               {
+                                       cls.forcetrack = -1;
+                                       FS_Printf (cls.demofile, "%i\n", cls.forcetrack);
+                                       cls.demorecording = true;
+                                       cls.demorecording_isauto = true;
+                                       strlcpy(cls.demoname, demofile, sizeof(cls.demoname));
+                                       cls.demo_lastcsprogssize = -1;
+                                       cls.demo_lastcsprogscrc = -1;
+                               }
+                               else
+                                       Con_Print(CON_ERROR "ERROR: couldn't open.\n");
                        }
-                       else
-                               Con_Print(CON_ERROR "ERROR: couldn't open.\n");
                }
        }
        cl.islocalgame = NetConn_IsLocalGame();
index b4e8eb7a3b7df2a167045cd0b21784d5770d89ce..c0e5cd82517a36ce7120581f8e1d6832cb56b68e 100644 (file)
--- a/client.h
+++ b/client.h
@@ -583,6 +583,7 @@ typedef struct client_static_s
 // demo recording info must be here, because record is started before
 // entering a map (and clearing client_state_t)
        qbool demorecording;
+       qbool demorecording_isauto;
        fs_offset_t demo_lastcsprogssize;
        int demo_lastcsprogscrc;
        qbool demoplayback;