23#ifdef CONFIG_VIDEO_CAPTURE
24extern cvar_t cl_capturevideo;
25extern cvar_t cl_capturevideo_demo_stop;
54 if (
cls.demonum == -1)
60 if (!
cls.demos[
cls.demonum][0])
62 Con_Print(
"No demos listed with startdemos\n");
83#ifdef CONFIG_VIDEO_CAPTURE
84 if (cl_capturevideo_demo_stop.
integer)
88 if (!
cls.demoplayback)
92 cls.demoplayback =
false;
98 if (!
cls.demostarting)
121 for (i=0 ; i<3 ; i++)
148 Sys_Error(
"failed to reopen the demo file");
168 while(startoffset < *filesize && ((
char *)(*
buf))[startoffset] !=
'\n')
170 if(startoffset < *filesize)
173 FS_Write(
cls.demofile, *
buf + startoffset, *filesize - startoffset);
192 if (!
cls.demoplayback)
208 cls.td_onesecondframes++;
212 if (
cls.td_frames == 0)
214 cls.td_starttime =
host.realtime;
215 cls.td_onesecondnexttime =
cl.time + 1;
216 cls.td_onesecondrealtime =
host.realtime;
217 cls.td_onesecondframes = 0;
218 cls.td_onesecondminfps = 0;
219 cls.td_onesecondmaxfps = 0;
220 cls.td_onesecondavgfps = 0;
221 cls.td_onesecondavgcount = 0;
223 if (
cl.time >=
cls.td_onesecondnexttime)
225 double fps =
cls.td_onesecondframes / (
host.realtime -
cls.td_onesecondrealtime);
226 if (
cls.td_onesecondavgcount == 0)
228 cls.td_onesecondminfps = fps;
229 cls.td_onesecondmaxfps = fps;
231 cls.td_onesecondrealtime =
host.realtime;
232 cls.td_onesecondminfps =
min(
cls.td_onesecondminfps, fps);
233 cls.td_onesecondmaxfps =
max(
cls.td_onesecondmaxfps, fps);
234 cls.td_onesecondavgfps += fps;
235 cls.td_onesecondavgcount++;
236 cls.td_onesecondframes = 0;
237 cls.td_onesecondnexttime++;
240 else if (
cl.time <
cl.mtime[0])
251 if (
cls.signon == 1 &&
cl.loadcsqc)
270 for (i = 0;i < 3;i++)
285 if (!
cls.demoplayback)
310 unsigned char bufdata[64];
312 if (!
cls.demorecording)
321 buf.maxsize =
sizeof(bufdata);
330 Con_Print(
"Completed and deleted demo\n");
336 cls.demorecording =
false;
354 if (c != 2 && c != 3 && c != 4)
356 Con_Print(
"record <demoname> [<map> [cd track]]\n");
362 Con_Print(
"Relative pathnames are not allowed.\n");
368 Con_Print(
"Can not record - already connected to server\nClient demo recording must be started before connecting\n");
405 cls.forcetrack = track;
408 cls.demorecording =
true;
409 cls.demo_lastcsprogssize = -1;
410 cls.demo_lastcsprogscrc = -1;
431 cls.demostarting =
true;
445 cls.demoplayback =
true;
453 cls.forcetrack =
cls.forcetrack * 10 + (c -
'0');
456 cls.forcetrack = -
cls.forcetrack;
458 cls.demostarting =
false;
472 Con_Print(
"playdemo <demoname> : plays a demo\n");
508 double time, totalfpsavg;
509 double fpsmin, fpsavg, fpsmax;
510 static int benchmark_runs = 0;
513 cls.timedemo =
host.restless =
false;
515 frames =
cls.td_frames;
517 totalfpsavg =
time > 0 ? frames /
time : 0;
518 fpsmin =
cls.td_onesecondminfps;
519 fpsavg =
cls.td_onesecondavgcount ?
cls.td_onesecondavgfps /
cls.td_onesecondavgcount : 0;
520 fpsmax =
cls.td_onesecondmaxfps;
522 Con_Printf(
"%i frames %5.7f seconds %5.7f fps, one-second fps min/avg/max: %.0f %.0f %.0f (%i seconds)\n", frames,
time, totalfpsavg, fpsmin, fpsavg, fpsmax,
cls.td_onesecondavgcount);
524 Log_Printf(
"benchmark.log",
"date %s | enginedate %s | demo %s | commandline %s | run %d | result %i frames %5.7f seconds %5.7f fps, one-second fps min/avg/max: %.0f %.0f %.0f (%i seconds)\n", vabuf,
engineversion,
cls.demoname,
cmdline.string, benchmark_runs + 1, frames,
time, totalfpsavg, fpsmin, fpsavg, fpsmax,
cls.td_onesecondavgcount);
529 if(i && i + 1 <
sys.argc)
535 history[benchmark_runs - 1].frames = frames;
537 history[benchmark_runs - 1].totalfpsavg = totalfpsavg;
538 history[benchmark_runs - 1].fpsmin = fpsmin;
539 history[benchmark_runs - 1].fpsavg = fpsavg;
540 history[benchmark_runs - 1].fpsmax = fpsmax;
542 if(atoi(
sys.argv[i + 1]) > benchmark_runs)
552 if(benchmark_runs >
first)
555 for(i = first; i < benchmark_runs; ++i) if((i == first) || (history[i].f < f)) f = history[i].f
558 for(i = first; i < benchmark_runs; ++i) if((i == first) || (history[i].f > f)) f = history[i].f
561 doublecmp_offset = (char *)&history->f - (char *)history; \
562 qsort(history + first, benchmark_runs - first, sizeof(*history), doublecmp_withoffset); \
563 if((first + benchmark_runs) & 1) \
564 f = history[(first + benchmark_runs - 1) / 2].f; \
566 f = (history[(first + benchmark_runs - 2) / 2].f + history[(first + benchmark_runs) / 2].f) / 2
574 Con_Printf(
"MIN: %i frames %5.7f seconds %5.7f fps, one-second fps min/avg/max: %.0f %.0f %.0f (%i seconds)\n", frames,
time, totalfpsavg, fpsmin, fpsavg, fpsmax,
cls.td_onesecondavgcount);
582 Con_Printf(
"MED: %i frames %5.7f seconds %5.7f fps, one-second fps min/avg/max: %.0f %.0f %.0f (%i seconds)\n", frames,
time, totalfpsavg, fpsmin, fpsavg, fpsmax,
cls.td_onesecondavgcount);
590 Con_Printf(
"MAX: %i frames %5.7f seconds %5.7f fps, one-second fps min/avg/max: %.0f %.0f %.0f (%i seconds)\n", frames,
time, totalfpsavg, fpsmin, fpsavg, fpsmax,
cls.td_onesecondavgcount);
616 Con_Print(
"timedemo <demoname> : gets demo speeds\n");
632 cls.timedemo =
host.restless =
true;
669 for (i=1 ; i<c+1 ; i++)
674 cls.demos[i-1][0] = 0;
676 if (!
sv.active &&
cls.demonum != -1 && !
cls.demoplayback)
707 if (
cls.demonum == -1)
722 if (!
cls.demoplayback)
730 cls.demopaused = !
cls.demopaused;
747 Cmd_AddCommand(
CF_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)");
void CL_PlayDemo_f(cmd_state_t *cmd)
void CL_Stop_f(cmd_state_t *cmd)
static void CL_Demos_f(cmd_state_t *cmd)
static int doublecmp_withoffset(const void *a_, const void *b_)
static void CL_PauseDemo_f(cmd_state_t *cmd)
static void CL_Stopdemo_f(cmd_state_t *cmd)
static void CL_Startdemos_f(cmd_state_t *cmd)
void CL_PasteDemo(unsigned char **buf, fs_offset_t *filesize)
void CL_ReadDemoMessage(void)
static void CL_FinishTimeDemo(void)
static size_t doublecmp_offset
void CL_TimeDemo_f(cmd_state_t *cmd)
void CL_Record_f(cmd_state_t *cmd)
void CL_CutDemo(unsigned char **buf, fs_offset_t *filesize)
void CL_StopPlayback(void)
void CL_PlayDemo(const char *demo)
void CL_WriteDemoMessage(sizebuf_t *message)
void CL_DisconnectEx(qbool kicked, const char *fmt,...)
cvar_t cl_autodemo_delete
cvar_t cl_autodemo_nameformat
void CL_ParseServerMessage(void)
unsigned int scr_con_current
void Cbuf_InsertText(cmd_state_t *cmd, const char *text)
void Cbuf_AddText(cmd_state_t *cmd, const char *text)
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
void Cmd_ExecuteString(cmd_state_t *cmd, const char *text, size_t textlen, cmd_source_t src, qbool lockmutex)
Parses a single line of text into arguments and tries to execute it.
cmd_state_t * cmd_local
command interpreter for local commands injected by SVQC, CSQC, MQC, server or client engine code uses...
void Cbuf_Execute(cmd_buf_t *cbuf)
@ src_local
from the command buffer
static int Cmd_Argc(cmd_state_t *cmd)
static const char * Cmd_Argv(cmd_state_t *cmd, int arg)
Cmd_Argv(cmd, ) will return an empty string (not a NULL) if arg > argc, so string operations are alwa...
#define CF_CLIENT
cvar/command that only the client can change/execute
void MSG_BeginReading(sizebuf_t *sb)
void MSG_WriteByte(sizebuf_t *sb, int c)
void SZ_Clear(sizebuf_t *buf)
char * va(char *buf, size_t buflen, const char *format,...)
int dpsnprintf(char *buffer, size_t buffersize, const char *format,...)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
@ PROTOCOL_QUAKE
quake (aka netquake/normalquake/nq) protocol
#define dp_strlcpy(dst, src, dsize)
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
void Log_Printf(const char *logfilename, const char *fmt,...)
void Cvar_SetQuick(cvar_t *var, const char *value)
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
void Cvar_Callback(cvar_t *var)
char engineversion[128]
version string for the corner of the console, crash messages, status command, etc
fs_offset_t FS_Read(qfile_t *file, void *buffer, size_t buffersize)
qfile_t * FS_OpenVirtualFile(const char *filepath, qbool quiet)
fs_offset_t FS_Write(qfile_t *file, const void *data, size_t datasize)
void FS_DefaultExtension(char *path, const char *extension, size_t size_path)
unsigned char * FS_LoadFile(const char *path, mempool_t *pool, qbool quiet, fs_offset_t *filesizepointer)
int FS_Seek(qfile_t *file, fs_offset_t offset, int whence)
qfile_t * FS_OpenRealFile(const char *filepath, const char *mode, qbool quiet)
void FS_RemoveOnClose(qfile_t *file)
int FS_Close(qfile_t *file)
int FS_Printf(qfile_t *file, const char *format,...)
int FS_Getc(qfile_t *file)
GLenum GLuint GLenum GLsizei const GLchar * buf
@ host_shutdown
states >= host_shutdown cause graceful shutdown, see Sys_HandleCrash() comments
#define VectorCopy(in, out)
void NetConn_UpdateSockets(void)
#define MAX_INPUTLINE
maximum size of console commandline, QuakeC strings, and many other text processing buffers
#define MAX_OSPATH
max length of a filesystem pathname
#define MAX_QPATH
max length of a quake game pathname
#define MAX_DEMOS
max demos provided to demos command
#define DEMOMSG_CLIENT_TO_SERVER
command interpreter state - the tokenizing and execution of commands, as well as pointers to which cv...
size_t Sys_TimeString(char buf[], size_t bufsize, const char *timeformat)
void Sys_Error(const char *error,...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN
Causes the entire program to exit ASAP.
int Sys_CheckParm(const char *parm)