]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
new option -capturedemo to capture a demo to an AVI file;
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index de12e31f8bd158d0680bbf3c70c4986aed9530ea..812a2cb63ac022ec015b0620f71fef30ed205fd1 100644 (file)
--- a/host.c
+++ b/host.c
@@ -222,7 +222,7 @@ void Host_SaveConfig_f(void)
 // dedicated servers initialize the host but don't parse and set the
 // config.cfg cvars
        // LordHavoc: don't save a config if it crashed in startup
-       if (host_framecount >= 3 && cls.state != ca_dedicated && !COM_CheckParm("-benchmark"))
+       if (host_framecount >= 3 && cls.state != ca_dedicated && !COM_CheckParm("-benchmark") && !COM_CheckParm("-capturedemo"))
        {
                f = FS_Open ("config.cfg", "wb", false, false);
                if (!f)
@@ -723,6 +723,14 @@ void Host_Main(void)
 
                        // apply slowmo scaling
                        clframetime *= cl.movevars_timescale;
+                       // scale playback speed of demos by slowmo cvar
+                       if (cls.demoplayback)
+                       {
+                               clframetime *= slowmo.value;
+                               // if demo playback is paused, don't advance time at all
+                               if (cls.demopaused)
+                                       clframetime = 0;
+                       }
 
                        // host_framerate overrides all else
                        if (host_framerate.value)
@@ -997,6 +1005,15 @@ static void Host_Init (void)
                Cbuf_Execute();
        }
 
+// COMMANDLINEOPTION: Client: -capturedemo <demoname> captures a playdemo and quits
+       i = COM_CheckParm("-capturedemo");
+       if (i && i + 1 < com_argc)
+       if (!sv.active && !cls.demoplayback && !cls.connect_trying)
+       {
+               Cbuf_AddText(va("playdemo %s\ncl_capturevideo 1\n", com_argv[i + 1]));
+               Cbuf_Execute();
+       }
+
        if (cls.state == ca_dedicated || COM_CheckParm("-listen"))
        if (!sv.active && !cls.demoplayback && !cls.connect_trying)
        {
@@ -1036,6 +1053,11 @@ void Host_Shutdown(void)
                Con_Print("recursive shutdown\n");
                return;
        }
+       if (setjmp(host_abortframe))
+       {
+               Con_Print("aborted the quitting frame?!?\n");
+               return;
+       }
        isdown = true;
 
        // be quiet while shutting down