From 1747c07da63018527631b2dc666fdefffdd1d62f Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 8 Jun 2002 23:22:26 +0000 Subject: [PATCH] rename cl_demospeed to demo_speed and add demo_gzip (yeah, compressed demos) --- nq/include/client.h | 3 +++ nq/source/cl_demo.c | 49 ++++++++++++++++++++++++++++++++++---------- nq/source/host.c | 10 +++------ nq/source/sv_ded.c | 7 +++++++ qw/include/cl_demo.h | 6 +++++- qw/source/cl_demo.c | 27 ++++++++++++++++++++---- qw/source/cl_main.c | 8 ++------ 7 files changed, 81 insertions(+), 29 deletions(-) diff --git a/nq/include/client.h b/nq/include/client.h index d5e6891e8..745df441f 100644 --- a/nq/include/client.h +++ b/nq/include/client.h @@ -337,7 +337,10 @@ void CL_Stop_f (void); void CL_Record_f (void); void CL_PlayDemo_f (void); void CL_TimeDemo_f (void); +void CL_Demo_Init (void); +extern struct cvar_s *demo_gzip; +extern struct cvar_s *demo_speed; /* cl_parse.c diff --git a/nq/source/cl_demo.c b/nq/source/cl_demo.c index ecc0391d2..7d2c20af3 100644 --- a/nq/source/cl_demo.c +++ b/nq/source/cl_demo.c @@ -38,22 +38,27 @@ static const char rcsid[] = # include #endif -#include "QF/qendian.h" -#include "QF/va.h" -#include "host.h" +#include "QF/cmd.h" +#include "QF/console.h" +#include "QF/cvar.h" +#include "QF/keys.h" #include "QF/msg.h" +#include "QF/qendian.h" +#include "QF/sys.h" +#include "QF/va.h" + #include "client.h" #include "compat.h" -#include "QF/sys.h" -#include "QF/console.h" -#include "QF/cmd.h" -#include "QF/keys.h" +#include "host.h" char demoname[1024]; int timedemo_count; void CL_FinishTimeDemo (void); +cvar_t *demo_gzip; +cvar_t *demo_speed; + /* DEMO CODE @@ -256,19 +261,29 @@ CL_Record_f (void) // open the demo file // - COM_DefaultExtension (name, ".dem"); +#ifdef HAVE_ZLIB + if (demo_gzip->int_val) { + COM_DefaultExtension (name, ".dem.gz"); + cls.demofile = Qopen (name, va ("wbz%d", + bound (1, demo_gzip->int_val, 9))); + } else +#endif + { + COM_DefaultExtension (name, ".dem"); + cls.demofile = Qopen (name, "wb"); + } - Con_Printf ("recording to %s.\n", name); - cls.demofile = Qopen (name, "wb"); if (!cls.demofile) { Con_Printf ("ERROR: couldn't open.\n"); return; } + Con_Printf ("recording to %s.\n", name); + cls.demorecording = true; + cls.forcetrack = track; Qprintf (cls.demofile, "%i\n", cls.forcetrack); - cls.demorecording = true; } @@ -388,3 +403,15 @@ CL_TimeDemo_f (void) strncpy (demoname, Cmd_Argv (1), sizeof (demoname)); CL_StartTimeDemo (); } + +void +CL_Demo_Init (void) +{ + demo_gzip = Cvar_Get ("demo_gzip", "0", CVAR_ARCHIVE, NULL, + "Compress demos using gzip. 0 = none, 1 = least " + "compression, 9 = most compression. Compressed " + " demos (1-9) will have .gz appended to the name"); + demo_speed = Cvar_Get ("demo_speed", "1.0", CVAR_NONE, NULL, + "adjust demo playback speed. 1.0 = normal, " + "< 1 slow-mo, > 1 timelapse"); +} diff --git a/nq/source/host.c b/nq/source/host.c index 2574b819c..332b6925b 100644 --- a/nq/source/host.c +++ b/nq/source/host.c @@ -120,8 +120,6 @@ cvar_t *pausable; cvar_t *temp1; -cvar_t *cl_demospeed; - void @@ -261,10 +259,6 @@ Host_InitLocal (void) pausable = Cvar_Get ("pausable", "1", CVAR_NONE, NULL, "None"); temp1 = Cvar_Get ("temp1", "0", CVAR_NONE, NULL, "None"); - cl_demospeed = Cvar_Get ("cl_demospeed", "1.0", CVAR_NONE, NULL, - "adjust demo playback speed. 1.0 = normal, " - "< 1 slow-mo, > 1 timelapse"); - Host_FindMaxClients (); host_time = 1.0; // so a think at time 0 won't get called @@ -513,7 +507,7 @@ Host_FilterTime (float time) float timescale = 1.0; if (cls.demoplayback) { - timescale = max (0, cl_demospeed->value); + timescale = max (0, demo_speed->value); time *= timescale; } @@ -932,6 +926,8 @@ Host_Init (void) Key_Init (); Mod_Init (); + CL_Demo_Init (); + SV_Progs_Init (); SV_Init (); diff --git a/nq/source/sv_ded.c b/nq/source/sv_ded.c index 41060c68d..8f58c799e 100644 --- a/nq/source/sv_ded.c +++ b/nq/source/sv_ded.c @@ -51,6 +51,7 @@ float scr_centertime_off; cvar_t *cl_name; cvar_t *cl_writecfg; +cvar_t *demo_speed; cvar_t *chase_active; int fps_count; @@ -134,6 +135,12 @@ CL_NextDemo (void) { } +void +CL_Demo_Init (void) +{ + demo_speed = Cvar_Get ("demo_speed", "1", CVAR_NONE, NULL, ""); +} + int CL_ReadFromServer (void) { diff --git a/qw/include/cl_demo.h b/qw/include/cl_demo.h index b144368e6..c8f2d5391 100644 --- a/qw/include/cl_demo.h +++ b/qw/include/cl_demo.h @@ -43,8 +43,12 @@ void CL_ReRecord_f (void); void CL_PlayDemo_f (void); void CL_TimeDemo_f (void); -void CL_TimeFrames_Init (void); void CL_TimeFrames_Reset (void); void CL_TimeFrames_AddTimestamp (void); +void CL_Demo_Init (void); + +extern struct cvar_s *demo_speed; +extern struct cvar_s *demo_gzip; + #endif diff --git a/qw/source/cl_demo.c b/qw/source/cl_demo.c index 865ac3d25..272bc1670 100644 --- a/qw/source/cl_demo.c +++ b/qw/source/cl_demo.c @@ -79,6 +79,9 @@ void CL_FinishTimeDemo (void); void CL_TimeFrames_Reset (void); void CL_TimeFrames_DumpLog (void); +cvar_t *demo_speed; +cvar_t *demo_gzip; + /* DEMO CODE @@ -461,9 +464,17 @@ CL_Record (const char *argv1) } // open the demo file - COM_DefaultExtension (name, ".qwd"); - - cls.demofile = Qopen (name, "wb"); +#ifdef HAVE_ZLIB + if (demo_gzip->int_val) { + COM_DefaultExtension (name, ".qwd.gz"); + cls.demofile = Qopen (name, va ("wbz%d", + bound (1, demo_gzip->int_val, 9))); + } else +#endif + { + COM_DefaultExtension (name, ".qwd"); + cls.demofile = Qopen (name, "wb"); + } if (!cls.demofile) { Con_Printf ("ERROR: couldn't open.\n"); return; @@ -922,11 +933,19 @@ CL_TimeDemo_f (void) } void -CL_TimeFrames_Init (void) +CL_Demo_Init (void) { cl_timeframes_isactive = 0; cl_timeframes_index = 0; cl_timeframes_array = NULL; + + demo_gzip = Cvar_Get ("demo_gzip", "0", CVAR_ARCHIVE, NULL, + "Compress demos using gzip. 0 = none, 1 = least " + "compression, 9 = most compression. Compressed " + " demos (1-9) will have .gz appended to the name"); + demo_speed = Cvar_Get ("demo_speed", "1.0", CVAR_NONE, NULL, + "adjust demo playback speed. 1.0 = normal, " + "< 1 slow-mo, > 1 timelapse"); } void diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index d73fbd371..8c41a85c1 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -210,7 +210,6 @@ cvar_t *show_fps; cvar_t *show_ping; cvar_t *show_pl; cvar_t *show_time; -cvar_t *cl_demospeed; int fps_count; @@ -1281,9 +1280,6 @@ CL_Init_Cvars (void) "Shift view colors on damage"); cl_cshift_powerup = Cvar_Get ("cl_cshift_powerup", "1", CVAR_ARCHIVE, NULL, "Shift view colors for powerups"); - cl_demospeed = Cvar_Get ("cl_demospeed", "1.0", CVAR_NONE, NULL, - "adjust demo playback speed. 1.0 = normal, " - "< 1 slow-mo, > 1 timelapse"); cl_anglespeedkey = Cvar_Get ("cl_anglespeedkey", "1.5", CVAR_NONE, NULL, "turn `run' speed multiplier"); cl_backspeed = Cvar_Get ("cl_backspeed", "200", CVAR_ARCHIVE, NULL, @@ -1473,7 +1469,7 @@ Host_SimulationTime (float time) float timescale = 1.0; if (cls.demoplayback) { - timescale = max (0, cl_demospeed->value); + timescale = max (0, demo_speed->value); time *= timescale; } @@ -1762,7 +1758,7 @@ Host_Init (void) Key_Init (); Mod_Init (); - CL_TimeFrames_Init(); + CL_Demo_Init(); Con_Printf ("%4.1f megabyte heap.\n", cl_mem_size->value);