size_t inflated_size;
out = FS_Inflate(cls.qw_downloadmemory, cls.qw_downloadmemorycursize, &inflated_size, tempmempool);
Mem_Free(cls.qw_downloadmemory);
- Con_Printf("Inflated download: new size: %u (%g%%)\n", (unsigned)inflated_size, 100.0 - 100.0*(cls.qw_downloadmemorycursize / (float)inflated_size));
- cls.qw_downloadmemory = out;
- cls.qw_downloadmemorycursize = inflated_size;
+ if(out)
+ {
+ Con_Printf("Inflated download: new size: %u (%g%%)\n", (unsigned)inflated_size, 100.0 - 100.0*(cls.qw_downloadmemorycursize / (float)inflated_size));
+ cls.qw_downloadmemory = out;
+ cls.qw_downloadmemorycursize = inflated_size;
+ }
+ else
+ {
+ cls.qw_downloadmemory = NULL;
+ cls.qw_downloadmemorycursize = 0;
+ Con_Printf("Cannot inflate download, possibly corrupt or zlib not present\n");
+ }
}
if(!cls.qw_downloadmemory)
unsigned char *out = NULL;
unsigned char *tmp;
+ *deflated_size = 0;
+ if(!zlib_dll)
+ return NULL;
+
memset(&strm, 0, sizeof(strm));
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
unsigned int have;
sizebuf_t outbuf;
+ *inflated_size = 0;
+ if(!zlib_dll)
+ return NULL;
+
memset(&outbuf, 0, sizeof(outbuf));
outbuf.data = (unsigned char *) Mem_Alloc(tempmempool, sizeof(tmp));
outbuf.maxsize = sizeof(tmp);
Con_DPrintf("Downloading %s to %s\n", host_client->download_name, host_client->name);
- if(host_client->download_deflate)
+ if(host_client->download_deflate && svs.csqc_progdata_deflated)
host_client->download_file = FS_FileFromData(svs.csqc_progdata_deflated, svs.csqc_progsize_deflated, true);
else
host_client->download_file = FS_FileFromData(svs.csqc_progdata, sv.csqc_progsize, true);
//unsigned char *FS_Deflate(const unsigned char *data, size_t size, size_t *deflated_size, int level, mempool_t *mempool);
svs.csqc_progdata_deflated = FS_Deflate(svs.csqc_progdata, progsize, &deflated_size, -1, sv_mempool);
svs.csqc_progsize_deflated = (int)deflated_size;
- Con_Printf("Deflated: %g%%\n", 100.0 - 100.0 * (deflated_size / (float)progsize));
- Con_DPrintf("Uncompressed: %u\nCompressed: %u\n", (unsigned)sv.csqc_progsize, (unsigned)svs.csqc_progsize_deflated);
+ if(svs.csqc_progdata_deflated)
+ {
+ Con_Printf("Deflated: %g%%\n", 100.0 - 100.0 * (deflated_size / (float)progsize));
+ Con_DPrintf("Uncompressed: %u\nCompressed: %u\n", (unsigned)sv.csqc_progsize, (unsigned)svs.csqc_progsize_deflated);
+ }
+ else
+ Con_Printf("Cannot compress - need zlib for this. Using uncompressed progs only.\n");
}
}