]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix Sajt's errors (in Visual Studio, I assume) in a better way - by changing the...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 24 Aug 2008 10:44:50 +0000 (10:44 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 24 Aug 2008 10:44:50 +0000 (10:44 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8472 d7cf8633-e32d-0410-b094-e92efae38249

cl_demo.c
client.h
csprogs.c
csprogs.h

index bffb265676e8535b83e0c93ee2cb7dfdc5f8b2ea..5be4e8080d8ad24998f38ff50f7db9bc1918de1c 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -127,7 +127,7 @@ Dumps the current demo to a buffer, and resets the demo to its starting point.
 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;
@@ -150,7 +150,7 @@ Adds the cut stuff back to the demo. Also frees the buffer.
 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;
 
@@ -163,7 +163,7 @@ void CL_PasteDemo (void **buf, fs_offset_t *filesize)
        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;
@@ -377,6 +377,8 @@ void CL_Record_f (void)
        FS_Printf(cls.demofile, "%i\n", cls.forcetrack);
 
        cls.demorecording = true;
+       cls.demo_lastcsprogssize = -1;
+       cls.demo_lastcsprogscrc = -1;
 }
 
 
index 6d032f342599cd9e2da1939ba8aea7563997b77f..d5da4864e119468300dae4dbf94d952f90f34468 100644 (file)
--- a/client.h
+++ b/client.h
@@ -523,6 +523,8 @@ typedef struct client_static_s
 // 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
@@ -1214,8 +1216,8 @@ void CL_StopPlayback(void);
 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);
index 4b421f3c17e6b3f4732ab3800e9a815a8e84e033..299e914f39f77301b9ef1d836471e689e4f5d280 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -666,7 +666,7 @@ void Cmd_ClearCsqcFuncs (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);
@@ -691,7 +691,7 @@ qboolean MakeDownloadPacket(const char *filename, void *data, unsigned long len,
                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;
        }
@@ -810,19 +810,25 @@ void CL_VM_Init (void)
 
        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);
 
index 25fabd91e9949ab803e731d66dac51dafcc91ac2..24856dd740a8d9652e129065bcaec1a85d4198dd 100644 (file)
--- a/csprogs.h
+++ b/csprogs.h
@@ -53,6 +53,6 @@ extern cvar_t csqc_progname;  //[515]: csqc crc check and right csprogs name acco
 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