From 90a46021b3d3abf8077b34c0af0a587ff579c5c1 Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 27 Oct 2011 19:59:02 +0000 Subject: [PATCH] -demo and -capturedemo: don't quit if loading another demo, only quit when no more demos are started git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11483 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_demo.c | 34 +++++++++++++++++++++------------- client.h | 1 + 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/cl_demo.c b/cl_demo.c index 6c2b36d4..6a0f194c 100644 --- a/cl_demo.c +++ b/cl_demo.c @@ -88,8 +88,9 @@ void CL_StopPlayback (void) if (cls.timedemo) CL_FinishTimeDemo (); - if (COM_CheckParm("-demo") || COM_CheckParm("-capturedemo")) - Host_Quit_f(); + if (!cls.demostarting) // only quit if not starting another demo + if (COM_CheckParm("-demo") || COM_CheckParm("-capturedemo")) + Host_Quit_f(); } @@ -98,7 +99,7 @@ void CL_StopPlayback (void) CL_WriteDemoMessage Dumps the current net message, prefixed by the length and view angles -==================== +#==================== */ void CL_WriteDemoMessage (sizebuf_t *message) { @@ -406,6 +407,7 @@ void CL_PlayDemo_f (void) char name[MAX_QPATH]; int c; qboolean neg = false; + qfile_t *f; if (Cmd_Argc() != 2) { @@ -413,6 +415,19 @@ void CL_PlayDemo_f (void) return; } + // open the demo file + strlcpy (name, Cmd_Argv(1), sizeof (name)); + FS_DefaultExtension (name, ".dem", sizeof (name)); + f = FS_OpenVirtualFile(name, false); + if (!f) + { + Con_Printf("ERROR: couldn't open %s.\n", name); + cls.demonum = -1; // stop demo loop + return; + } + + cls.demostarting = true; + // disconnect from server CL_Disconnect (); Host_ShutdownServer (); @@ -420,19 +435,10 @@ void CL_PlayDemo_f (void) // update networking ports (this is mainly just needed at startup) NetConn_UpdateSockets(); - // open the demo file - strlcpy (name, Cmd_Argv(1), sizeof (name)); - FS_DefaultExtension (name, ".dem", sizeof (name)); cls.protocol = PROTOCOL_QUAKE; Con_Printf("Playing demo %s.\n", name); - cls.demofile = FS_OpenVirtualFile(name, false); - if (!cls.demofile) - { - Con_Print("ERROR: couldn't open.\n"); - cls.demonum = -1; // stop demo loop - return; - } + cls.demofile = f; strlcpy(cls.demoname, name, sizeof(cls.demoname)); cls.demoplayback = true; @@ -447,6 +453,8 @@ void CL_PlayDemo_f (void) if (neg) cls.forcetrack = -cls.forcetrack; + + cls.demostarting = false; } /* diff --git a/client.h b/client.h index cd780e62..a7555e86 100644 --- a/client.h +++ b/client.h @@ -632,6 +632,7 @@ typedef struct client_static_s fs_offset_t demo_lastcsprogssize; int demo_lastcsprogscrc; qboolean demoplayback; + qboolean demostarting; // set if currently starting a demo, to stop -demo from quitting when switching to another demo qboolean timedemo; // -1 = use normal cd track int forcetrack; -- 2.39.2