Used to insert csprogs.dat files as a download to the beginning of a demo file.
====================
*/
-void CL_CutDemo (void **buf, fs_offset_t *filesize)
+void CL_CutDemo (unsigned char **buf, fs_offset_t *filesize)
{
*buf = NULL;
*filesize = 0;
Used to insert csprogs.dat files as a download to the beginning of a demo file.
====================
*/
-void CL_PasteDemo (void **buf, fs_offset_t *filesize)
+void CL_PasteDemo (unsigned char **buf, fs_offset_t *filesize)
{
fs_offset_t startoffset = 0;
if(startoffset < *filesize)
++startoffset;
- FS_Write(cls.demofile, (char*)*buf + startoffset, *filesize - startoffset);
+ FS_Write(cls.demofile, *buf + startoffset, *filesize - startoffset);
Mem_Free(*buf);
*buf = NULL;
FS_Printf(cls.demofile, "%i\n", cls.forcetrack);
cls.demorecording = true;
+ cls.demo_lastcsprogssize = -1;
+ cls.demo_lastcsprogscrc = -1;
}
// demo recording info must be here, because record is started before
// entering a map (and clearing client_state_t)
qboolean demorecording;
+ fs_offset_t demo_lastcsprogssize;
+ int demo_lastcsprogscrc;
qboolean demoplayback;
qboolean timedemo;
// -1 = use normal cd track
void CL_ReadDemoMessage(void);
void CL_WriteDemoMessage(sizebuf_t *mesage);
-void CL_CutDemo(void **buf, fs_offset_t *filesize);
-void CL_PasteDemo(void **buf, fs_offset_t *filesize);
+void CL_CutDemo(unsigned char **buf, fs_offset_t *filesize);
+void CL_PasteDemo(unsigned char **buf, fs_offset_t *filesize);
void CL_NextDemo(void);
void CL_Stop_f(void);
// returns true if the packet is valid, false if end of file is reached
// used for dumping the CSQC download into demo files
-qboolean MakeDownloadPacket(const char *filename, void *data, unsigned long len, int crc, int cnt, sizebuf_t *buf, int protocol)
+qboolean MakeDownloadPacket(const char *filename, unsigned char *data, unsigned long len, int crc, int cnt, sizebuf_t *buf, int protocol)
{
int packetsize = buf->maxsize - 7; // byte short long
int npackets = (len + packetsize - 1) / (packetsize);
MSG_WriteByte(buf, svc_downloaddata);
MSG_WriteLong(buf, thispacketoffset);
MSG_WriteShort(buf, thispacketsize);
- SZ_Write(buf, (char*)data + thispacketoffset, thispacketsize);
+ SZ_Write(buf, data + thispacketoffset, thispacketsize);
return true;
}
if(cls.demorecording)
{
- int i;
- char buf[NET_MAXMESSAGE];
- sizebuf_t sb;
- void *demobuf; fs_offset_t demofilesize;
-
- sb.data = (void *) buf;
- sb.maxsize = sizeof(buf);
- i = 0;
-
- CL_CutDemo(&demobuf, &demofilesize);
- while(MakeDownloadPacket(csprogsfn, csprogsdata, csprogsdatasize, csprogsdatacrc, i++, &sb, cls.protocol))
- CL_WriteDemoMessage(&sb);
- CL_PasteDemo(&demobuf, &demofilesize);
+ if(cls.demo_lastcsprogssize != csprogsdatasize || cls.demo_lastcsprogscrc != csprogsdatacrc)
+ {
+ int i;
+ char buf[NET_MAXMESSAGE];
+ sizebuf_t sb;
+ unsigned char *demobuf; fs_offset_t demofilesize;
+
+ sb.data = (void *) buf;
+ sb.maxsize = sizeof(buf);
+ i = 0;
+
+ CL_CutDemo(&demobuf, &demofilesize);
+ while(MakeDownloadPacket(csprogsfn, csprogsdata, csprogsdatasize, csprogsdatacrc, i++, &sb, cls.protocol))
+ CL_WriteDemoMessage(&sb);
+ CL_PasteDemo(&demobuf, &demofilesize);
+
+ cls.demo_lastcsprogssize = csprogsdatasize;
+ cls.demo_lastcsprogscrc = csprogsdatacrc;
+ }
}
Mem_Free(csprogsdata);
extern cvar_t csqc_progcrc;
extern cvar_t csqc_progsize;
-qboolean MakeDownloadPacket(const char *filename, void *data, unsigned long len, int crc, int cnt, sizebuf_t *buf, int protocol);
+qboolean MakeDownloadPacket(const char *filename, unsigned char *data, unsigned long len, int crc, int cnt, sizebuf_t *buf, int protocol);
#endif