rename cl_demospeed to demo_speed and add demo_gzip (yeah, compressed demos)

This commit is contained in:
Bill Currie 2002-06-08 23:22:26 +00:00
parent 23246ba4fd
commit 1747c07da6
7 changed files with 81 additions and 29 deletions

View File

@ -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

View File

@ -38,22 +38,27 @@ static const char rcsid[] =
# include <strings.h>
#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");
}

View File

@ -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 ();

View File

@ -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)
{

View File

@ -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

View File

@ -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

View File

@ -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);