mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-02 14:01:26 +00:00
Fix stupid zip decompression error.
This commit is contained in:
parent
c52a165ca5
commit
49822069a3
3 changed files with 8 additions and 8 deletions
|
@ -2095,7 +2095,7 @@ static int COM_FindFile (const char *filename, int *handle, FILE **file,
|
|||
if (f)
|
||||
{
|
||||
fseek (f, pak->files[i].filepos, SEEK_SET);
|
||||
f = FSZIP_Deflate(f, pak->files[i].deflatedsize, pak->files[i].filelen);
|
||||
f = FSZIP_Deflate(f, pak->files[i].deflatedsize, pak->files[i].filelen, pak->files[i].name);
|
||||
if (f)
|
||||
*handle = Sys_FileOpenStdio(f);
|
||||
else
|
||||
|
@ -2124,7 +2124,7 @@ static int COM_FindFile (const char *filename, int *handle, FILE **file,
|
|||
{
|
||||
fseek (*file, pak->files[i].filepos, SEEK_SET);
|
||||
if (pak->files[i].deflatedsize)
|
||||
*file = FSZIP_Deflate(*file, pak->files[i].deflatedsize, pak->files[i].filelen);
|
||||
*file = FSZIP_Deflate(*file, pak->files[i].deflatedsize, pak->files[i].filelen, pak->files[i].name);
|
||||
}
|
||||
return com_filesize;
|
||||
}
|
||||
|
|
|
@ -352,7 +352,7 @@ const char *COM_GetGameNames(qboolean full);
|
|||
qboolean COM_GameDirMatches(const char *tdirs);
|
||||
|
||||
pack_t *FSZIP_LoadArchive (const char *packfile);
|
||||
FILE *FSZIP_Deflate(FILE *src, qofs_t srcsize, qofs_t outsize);
|
||||
FILE *FSZIP_Deflate(FILE *src, qofs_t srcsize, qofs_t outsize, const char *entryname);
|
||||
|
||||
void COM_WriteFile (const char *filename, const void *data, int len);
|
||||
int COM_OpenFile (const char *filename, int *handle, unsigned int *path_id);
|
||||
|
|
|
@ -744,7 +744,7 @@ pack_t *FSZIP_LoadArchive (const char *packfile)
|
|||
return pack;
|
||||
}
|
||||
|
||||
FILE *FSZIP_Deflate(FILE *src, qofs_t srcsize, qofs_t outsize)
|
||||
FILE *FSZIP_Deflate(FILE *src, qofs_t srcsize, qofs_t outsize, const char *entryname)
|
||||
{
|
||||
#ifdef USE_ZLIB
|
||||
byte inbuffer[65536];
|
||||
|
@ -773,6 +773,7 @@ FILE *FSZIP_Deflate(FILE *src, qofs_t srcsize, qofs_t outsize)
|
|||
|
||||
memset(&strm, 0, sizeof(strm));
|
||||
strm.data_type = Z_UNKNOWN;
|
||||
strm.next_out = outbuffer;
|
||||
inflateInit2(&strm, -MAX_WBITS);
|
||||
while ((ret=inflate(&strm, Z_SYNC_FLUSH)) != Z_STREAM_END)
|
||||
{
|
||||
|
@ -787,9 +788,8 @@ FILE *FSZIP_Deflate(FILE *src, qofs_t srcsize, qofs_t outsize)
|
|||
}
|
||||
if (strm.avail_out == 0)
|
||||
{
|
||||
fwrite(outbuffer, 1, strm.next_out - outbuffer, of);
|
||||
strm.next_out = outbuffer;
|
||||
fwrite(outbuffer, 1, strm.total_out, of);
|
||||
strm.total_out = 0;
|
||||
strm.avail_out = sizeof(outbuffer);
|
||||
}
|
||||
continue;
|
||||
|
@ -801,7 +801,7 @@ FILE *FSZIP_Deflate(FILE *src, qofs_t srcsize, qofs_t outsize)
|
|||
inflateEnd(&strm);
|
||||
fclose(src);
|
||||
fclose(of);
|
||||
Con_Printf("Couldn't decompress file, corrupt?\n");
|
||||
Con_Printf("Couldn't decompress file \"%s\", corrupt?\n", entryname);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -811,7 +811,7 @@ FILE *FSZIP_Deflate(FILE *src, qofs_t srcsize, qofs_t outsize)
|
|||
|
||||
if (strm.total_out != outsize)
|
||||
{
|
||||
Con_Printf("Decompressed %u bytes, expected %u\n", (unsigned int)strm.total_out, (unsigned int)outsize);
|
||||
Con_Printf("%s: Decompressed %u bytes, expected %u\n", entryname, (unsigned int)strm.total_out, (unsigned int)outsize);
|
||||
fclose(of);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue