]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
(Round 2) Break up host_cmd.c
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 22 Jun 2020 15:31:55 +0000 (15:31 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 22 Jun 2020 15:31:55 +0000 (15:31 +0000)
This time, demo code. Some parts of demo code were littered in cl_main.c
as well, and have been moved.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12719 d7cf8633-e32d-0410-b094-e92efae38249

cl_demo.c
cl_main.c
client.h
host_cmd.c

index 137c1577196138a7a0ef17f61e4cf70a6c15d2ea..1d14f718c1bfc11c981ed0ddc25b3ea24a268b11 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -619,3 +619,106 @@ void CL_TimeDemo_f(cmd_state_t *cmd)
        cls.demonum = -1;               // stop demo loop
 }
 
+/*
+===============================================================================
+
+DEMO LOOP CONTROL
+
+===============================================================================
+*/
+
+
+/*
+==================
+CL_Startdemos_f
+==================
+*/
+static void CL_Startdemos_f(cmd_state_t *cmd)
+{
+       int             i, c;
+
+       if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-capturedemo"))
+               return;
+
+       c = Cmd_Argc(cmd) - 1;
+       if (c > MAX_DEMOS)
+       {
+               Con_Printf("Max %i demos in demoloop\n", MAX_DEMOS);
+               c = MAX_DEMOS;
+       }
+       Con_DPrintf("%i demo(s) in loop\n", c);
+
+       for (i=1 ; i<c+1 ; i++)
+               strlcpy (cls.demos[i-1], Cmd_Argv(cmd, i), sizeof (cls.demos[i-1]));
+
+       // LadyHavoc: clear the remaining slots
+       for (;i <= MAX_DEMOS;i++)
+               cls.demos[i-1][0] = 0;
+
+       if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
+       {
+               cls.demonum = 0;
+               CL_NextDemo ();
+       }
+       else
+               cls.demonum = -1;
+}
+
+
+/*
+==================
+CL_Demos_f
+
+Return to looping demos
+==================
+*/
+static void CL_Demos_f(cmd_state_t *cmd)
+{
+       if (cls.state == ca_dedicated)
+               return;
+       if (cls.demonum == -1)
+               cls.demonum = 1;
+       CL_Disconnect_f (cmd);
+       CL_NextDemo ();
+}
+
+/*
+==================
+CL_Stopdemo_f
+
+Return to looping demos
+==================
+*/
+static void CL_Stopdemo_f(cmd_state_t *cmd)
+{
+       if (!cls.demoplayback)
+               return;
+       CL_Disconnect ();
+       SV_Shutdown ();
+}
+
+// LadyHavoc: pausedemo command
+static void CL_PauseDemo_f(cmd_state_t *cmd)
+{
+       cls.demopaused = !cls.demopaused;
+       if (cls.demopaused)
+               Con_Print("Demo paused\n");
+       else
+               Con_Print("Demo unpaused\n");
+}
+
+void CL_Demo_Init(void)
+{
+       Cmd_AddCommand(CMD_CLIENT, "record", CL_Record_f, "record a demo");
+       Cmd_AddCommand(CMD_CLIENT, "stop", CL_Stop_f, "stop recording or playing a demo");
+       Cmd_AddCommand(CMD_CLIENT, "playdemo", CL_PlayDemo_f, "watch a demo file");
+       Cmd_AddCommand(CMD_CLIENT, "timedemo", CL_TimeDemo_f, "play back a demo as fast as possible and save statistics to benchmark.log");
+       Cmd_AddCommand(CMD_CLIENT, "startdemos", CL_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)");
+       Cmd_AddCommand(CMD_CLIENT, "demos", CL_Demos_f, "restart looping demos defined by the last startdemos command");
+       Cmd_AddCommand(CMD_CLIENT, "stopdemo", CL_Stopdemo_f, "stop playing or recording demo (like stop command) and return to looping demos");
+       // LadyHavoc: added pausedemo
+       Cmd_AddCommand(CMD_CLIENT, "pausedemo", CL_PauseDemo_f, "pause demo playback (can also safely pause demo recording if using QUAKE, QUAKEDP or NEHAHRAMOVIE protocol, useful for making movies)");
+       Cvar_RegisterVariable (&cl_autodemo);
+       Cvar_RegisterVariable (&cl_autodemo_nameformat);
+       Cvar_RegisterVariable (&cl_autodemo_delete);
+}
\ No newline at end of file
index e62ae26f8b8b84237d34e7c010c376e5c5afc6ee..93974404f0e8fab841478e52f17cdecefd20321b 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -1955,16 +1955,6 @@ void CL_UpdateWorld(void)
        r_refdef.scene.time = cl.time;
 }
 
-// LadyHavoc: pausedemo command
-static void CL_PauseDemo_f(cmd_state_t *cmd)
-{
-       cls.demopaused = !cls.demopaused;
-       if (cls.demopaused)
-               Con_Print("Demo paused\n");
-       else
-               Con_Print("Demo unpaused\n");
-}
-
 /*
 ======================
 CL_Fog_f
@@ -2709,28 +2699,19 @@ void CL_Init (void)
                Cvar_RegisterVariable (&cl_itembobspeed);
                Cvar_RegisterVariable (&cl_itembobheight);
 
+               CL_Demo_Init();
+
                Cmd_AddCommand(CMD_CLIENT, "entities", CL_PrintEntities_f, "print information on network entities known to client");
                Cmd_AddCommand(CMD_CLIENT, "disconnect", CL_Disconnect_f, "disconnect from server (or disconnect all clients if running a server)");
-               Cmd_AddCommand(CMD_CLIENT, "record", CL_Record_f, "record a demo");
-               Cmd_AddCommand(CMD_CLIENT, "stop", CL_Stop_f, "stop recording or playing a demo");
-               Cmd_AddCommand(CMD_CLIENT, "playdemo", CL_PlayDemo_f, "watch a demo file");
-               Cmd_AddCommand(CMD_CLIENT, "timedemo", CL_TimeDemo_f, "play back a demo as fast as possible and save statistics to benchmark.log");
 
                // Support Client-side Model Index List
                Cmd_AddCommand(CMD_CLIENT, "cl_modelindexlist", CL_ModelIndexList_f, "list information on all models in the client modelindex");
                // Support Client-side Sound Index List
                Cmd_AddCommand(CMD_CLIENT, "cl_soundindexlist", CL_SoundIndexList_f, "list all sounds in the client soundindex");
 
-               Cvar_RegisterVariable (&cl_autodemo);
-               Cvar_RegisterVariable (&cl_autodemo_nameformat);
-               Cvar_RegisterVariable (&cl_autodemo_delete);
-
                Cmd_AddCommand(CMD_CLIENT, "fog", CL_Fog_f, "set global fog parameters (density red green blue [alpha [mindist [maxdist [top [fadedepth]]]]])");
                Cmd_AddCommand(CMD_CLIENT, "fog_heighttexture", CL_Fog_HeightTexture_f, "set global fog parameters (density red green blue alpha mindist maxdist top depth textures/mapname/fogheight.tga)");
 
-               // LadyHavoc: added pausedemo
-               Cmd_AddCommand(CMD_CLIENT, "pausedemo", CL_PauseDemo_f, "pause demo playback (can also safely pause demo recording if using QUAKE, QUAKEDP or NEHAHRAMOVIE protocol, useful for making movies)");
-
                Cmd_AddCommand(CMD_CLIENT, "cl_areastats", CL_AreaStats_f, "prints statistics on entity culling during collision traces");
 
                Cvar_RegisterVariable(&r_draweffects);
index ff96e4fe672d8f3308e7a17ad05af53c00c5137b..f505f216cb7e6a0fd49b68be9ab446cb95ae0bee 100644 (file)
--- a/client.h
+++ b/client.h
@@ -1608,6 +1608,8 @@ void CL_Record_f(cmd_state_t *cmd);
 void CL_PlayDemo_f(cmd_state_t *cmd);
 void CL_TimeDemo_f(cmd_state_t *cmd);
 
+void CL_Demo_Init(void);
+
 //
 // cl_parse.c
 //
index 5689d11792306cd284e65c9271653a4a2c5d30bf..7e4cebfad887f3f33c2040552cf4b7eef8d8c6fc 100644 (file)
@@ -603,84 +603,6 @@ static void CL_PModel_f(cmd_state_t *cmd)
 
 //===========================================================================
 
-/*
-===============================================================================
-
-DEMO LOOP CONTROL
-
-===============================================================================
-*/
-
-
-/*
-==================
-CL_Startdemos_f
-==================
-*/
-static void CL_Startdemos_f(cmd_state_t *cmd)
-{
-       int             i, c;
-
-       if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-capturedemo"))
-               return;
-
-       c = Cmd_Argc(cmd) - 1;
-       if (c > MAX_DEMOS)
-       {
-               Con_Printf("Max %i demos in demoloop\n", MAX_DEMOS);
-               c = MAX_DEMOS;
-       }
-       Con_DPrintf("%i demo(s) in loop\n", c);
-
-       for (i=1 ; i<c+1 ; i++)
-               strlcpy (cls.demos[i-1], Cmd_Argv(cmd, i), sizeof (cls.demos[i-1]));
-
-       // LadyHavoc: clear the remaining slots
-       for (;i <= MAX_DEMOS;i++)
-               cls.demos[i-1][0] = 0;
-
-       if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
-       {
-               cls.demonum = 0;
-               CL_NextDemo ();
-       }
-       else
-               cls.demonum = -1;
-}
-
-
-/*
-==================
-CL_Demos_f
-
-Return to looping demos
-==================
-*/
-static void CL_Demos_f(cmd_state_t *cmd)
-{
-       if (cls.state == ca_dedicated)
-               return;
-       if (cls.demonum == -1)
-               cls.demonum = 1;
-       CL_Disconnect_f (cmd);
-       CL_NextDemo ();
-}
-
-/*
-==================
-CL_Stopdemo_f
-
-Return to looping demos
-==================
-*/
-static void CL_Stopdemo_f(cmd_state_t *cmd)
-{
-       if (!cls.demoplayback)
-               return;
-       CL_Disconnect ();
-       SV_Shutdown ();
-}
-
 static void CL_SendCvar_f(cmd_state_t *cmd)
 {
        int             i;
@@ -1103,9 +1025,6 @@ void Host_InitCommands (void)
 
        Cmd_AddCommand(CMD_CLIENT, "connect", CL_Connect_f, "connect to a server by IP address or hostname");
        Cmd_AddCommand(CMD_CLIENT | CMD_CLIENT_FROM_SERVER, "reconnect", CL_Reconnect_f, "reconnect to the last server you were on, or resets a quakeworld connection (do not use if currently playing on a netquake server)");
-       Cmd_AddCommand(CMD_CLIENT, "startdemos", CL_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)");
-       Cmd_AddCommand(CMD_CLIENT, "demos", CL_Demos_f, "restart looping demos defined by the last startdemos command");
-       Cmd_AddCommand(CMD_CLIENT, "stopdemo", CL_Stopdemo_f, "stop playing or recording demo (like stop command) and return to looping demos");
        Cmd_AddCommand(CMD_CLIENT, "sendcvar", CL_SendCvar_f, "sends the value of a cvar to the server as a sentcvar command, for use by QuakeC");
        Cmd_AddCommand(CMD_CLIENT, "rcon", CL_Rcon_f, "sends a command to the server console (if your rcon_password matches the server's rcon_password), or to the address specified by rcon_address when not connected (again rcon_password must match the server's); note: if rcon_secure is set, client and server clocks must be synced e.g. via NTP");
        Cmd_AddCommand(CMD_CLIENT, "srcon", CL_Rcon_f, "sends a command to the server console (if your rcon_password matches the server's rcon_password), or to the address specified by rcon_address when not connected (again rcon_password must match the server's); this always works as if rcon_secure is set; note: client and server clocks must be synced e.g. via NTP");