]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_demo.c
com_list: Move all functions to the header and inline them. Include where needed
[xonotic/darkplaces.git] / cl_demo.c
index 7c7874329c5bc0996dc964e0544f6232e8e42eb3..a3be2148d09709c6ab33208eec19313ea9e0f585 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -67,7 +67,7 @@ void CL_NextDemo (void)
        }
 
        dpsnprintf (str, sizeof(str), "playdemo %s\n", cls.demos[cls.demonum]);
-       Cbuf_InsertText(&cmd_client, str);
+       Cbuf_InsertText(cmd_client, str);
        cls.demonum++;
 }
 
@@ -98,8 +98,7 @@ void CL_StopPlayback (void)
 
        if (!cls.demostarting) // only quit if not starting another demo
                if (Sys_CheckParm("-demo") || Sys_CheckParm("-capturedemo"))
-                       Host_Quit_f(&cmd_client);
-
+                       host.state = host_shutdown;
 }
 
 /*
@@ -275,7 +274,7 @@ void CL_ReadDemoMessage(void)
                        CL_ParseServerMessage();
 
                        if (cls.signon != SIGNONS)
-                               Cbuf_Execute((&cmd_client)->cbuf); // immediately execute svc_stufftext if in the demo before connect!
+                               Cbuf_Execute((cmd_client)->cbuf); // immediately execute svc_stufftext if in the demo before connect!
 
                        // In case the demo contains a "svc_disconnect" message
                        if (!cls.demoplayback)
@@ -407,7 +406,7 @@ void CL_Record_f(cmd_state_t *cmd)
 ====================
 CL_PlayDemo_f
 
-play [demoname]
+playdemo [demoname]
 ====================
 */
 void CL_PlayDemo_f(cmd_state_t *cmd)
@@ -419,7 +418,7 @@ void CL_PlayDemo_f(cmd_state_t *cmd)
 
        if (Cmd_Argc(cmd) != 2)
        {
-               Con_Print("play <demoname> : plays a demo\n");
+               Con_Print("playdemo <demoname> : plays a demo\n");
                return;
        }
 
@@ -437,8 +436,10 @@ void CL_PlayDemo_f(cmd_state_t *cmd)
        cls.demostarting = true;
 
        // disconnect from server
-       CL_Disconnect ();
-       SV_Shutdown ();
+       if(cls.state == ca_connected)
+               CL_Disconnect();
+       if(sv.active)
+               SV_Shutdown();
 
        // update networking ports (this is mainly just needed at startup)
        NetConn_UpdateSockets();
@@ -530,7 +531,7 @@ static void CL_FinishTimeDemo (void)
                        if(atoi(sys.argv[i + 1]) > benchmark_runs)
                        {
                                // restart the benchmark
-                               Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", cls.demoname));
+                               Cbuf_AddText(cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", cls.demoname));
                                // cannot execute here
                        }
                        else
@@ -579,11 +580,11 @@ static void CL_FinishTimeDemo (void)
                                }
                                Z_Free(history);
                                history = NULL;
-                               Host_Quit_f(&cmd_client);
+                               host.state = host_shutdown;
                        }
                }
                else
-                       Host_Quit_f(&cmd_client);
+                       host.state = host_shutdown;
        }
 }
 
@@ -693,8 +694,7 @@ static void CL_Stopdemo_f(cmd_state_t *cmd)
 {
        if (!cls.demoplayback)
                return;
-       CL_Disconnect ();
-       SV_Shutdown ();
+       CL_Disconnect();
 }
 
 // LadyHavoc: pausedemo command