Dumps the current net message, prefixed by the length and view angles
====================
*/
-void CL_WriteDemoMessage (void)
+void CL_WriteDemoMessage (sizebuf_t *message)
{
int len;
int i;
if (cls.demopaused) // LordHavoc: pausedemo
return;
- len = LittleLong (net_message.cursize);
+ len = LittleLong (message->cursize);
FS_Write (cls.demofile, &len, 4);
for (i=0 ; i<3 ; i++)
{
f = LittleFloat (cl.viewangles[i]);
FS_Write (cls.demofile, &f, 4);
}
- FS_Write (cls.demofile, net_message.data, net_message.cursize);
+ FS_Write (cls.demofile, message->data, message->cursize);
}
/*
*/
void CL_Stop_f (void)
{
+ sizebuf_t buf;
+ unsigned char bufdata[64];
+
if (!cls.demorecording)
{
Con_Print("Not recording a demo.\n");
}
// write a disconnect message to the demo file
- SZ_Clear (&net_message);
- MSG_WriteByte (&net_message, svc_disconnect);
- CL_WriteDemoMessage ();
+ // LordHavoc: don't replace the net_message when doing this
+ buf.data = bufdata;
+ buf.maxsize = sizeof(bufdata);
+ SZ_Clear(&buf);
+ MSG_WriteByte(&buf, svc_disconnect);
+ CL_WriteDemoMessage(&buf);
// finish up
FS_Close (cls.demofile);
cvar_t freelook = {CVAR_SAVE, "freelook", "1","mouse controls pitch instead of forward/back"};
-#ifdef AUTODEMO_BROKEN
cvar_t cl_autodemo = {0, "cl_autodemo", "0", "records every game played, using the date/time and map name to name the demo file" };
cvar_t cl_autodemo_nameformat = {0, "cl_autodemo_nameformat", "%Y-%m-%d_%H-%M", "The format of the cl_autodemo filename, followed by the map name" };
-#endif
cvar_t r_draweffects = {0, "r_draweffects", "1","renders temporary sprite effects"};
Cmd_AddCommand ("playdemo", CL_PlayDemo_f, "watch a demo file");
Cmd_AddCommand ("timedemo", CL_TimeDemo_f, "play back a demo as fast as possible and save statistics to benchmark.log");
-#ifdef AUTODEMO_BROKEN
Cvar_RegisterVariable (&cl_autodemo);
Cvar_RegisterVariable (&cl_autodemo_nameformat);
-#endif
Cmd_AddCommand ("fog", CL_Fog_f, "set global fog parameters (density red green blue)");
// check memory integrity
Mem_CheckSentinelsGlobal();
+
+// if cl_autodemo is set, automatically start recording a demo if one isn't being recorded already
+ if (cl_autodemo.integer && cls.netcon && cls.protocol != PROTOCOL_QUAKEWORLD)
+ {
+ char demofile[MAX_OSPATH];
+ char levelname[MAX_QPATH];
+
+ if (cls.demorecording)
+ {
+ // finish the previous level's demo file
+ CL_Stop_f();
+ }
+
+ // start a new demo file
+ strlcpy(levelname, FS_FileWithoutPath(cl.model_name[1]), sizeof(levelname));
+ if (strrchr(levelname, '.'))
+ *(strrchr(levelname, '.')) = 0;
+ dpsnprintf (demofile, sizeof(demofile), "%s_%s.dem", Sys_TimeString (cl_autodemo_nameformat.string), levelname);
+
+ Con_Printf ("Auto-recording to %s.\n", demofile);
+
+ cls.demofile = FS_Open (demofile, "wb", false, false);
+ if (cls.demofile)
+ {
+ cls.forcetrack = -1;
+ FS_Printf (cls.demofile, "%i\n", cls.forcetrack);
+ cls.demorecording = true;
+ }
+ else
+ Con_Print ("ERROR: couldn't open.\n");
+ }
}
void CL_ValidateState(entity_state_t *s)
char *cmdlogname[32], *temp;
int cmdindex, cmdcount = 0;
- if (cls.demorecording)
- CL_WriteDemoMessage ();
+ // LordHavoc: moved demo message writing from before the packet parse to
+ // after the packet parse so that CL_Stop_f can be called by cl_autodemo
+ // code in CL_ParseServerinfo
+ //if (cls.demorecording)
+ // CL_WriteDemoMessage (&net_message);
cl.last_received_message = realtime;
EntityFrameQuake_ISeeDeadEntities();
parsingerror = false;
+
+ // LordHavoc: this was at the start of the function before cl_autodemo was
+ // implemented
+ if (cls.demorecording)
+ CL_WriteDemoMessage (&net_message);
}
void CL_Parse_DumpPacket(void)
//
void CL_StopPlayback(void);
void CL_ReadDemoMessage(void);
-void CL_WriteDemoMessage(void);
+void CL_WriteDemoMessage(sizebuf_t *mesage);
void CL_NextDemo(void);
void CL_Stop_f(void);