Made fixes to quakefs.c, unzip.c, and unzip.h; compiles for me, and should for you too. Unzip.c was surprisingly broken; quakefs.c was mildy broken but now fixed (GENERATIONS code). Also an "interface" change, no longer searches for .pk3 files but rather .qz (quake pack) as per Knghtbrd's suggestion.

This commit is contained in:
Eric Windisch 2000-03-04 01:55:01 +00:00
parent 3e6df0a25e
commit 45ccae6ba7
3 changed files with 45 additions and 46 deletions

View file

@ -61,21 +61,16 @@ QUAKE FILESYSTEM
=============================================================================
*/
/* Begin Generations */
#if defined(_EXPERIMENTAL_) && defined(GENERATIONS)
#include "unzip.h"
#endif
#ifdef GENERATIONS
#include <unzip.h>
typedef unsigned char byte_t;
char gamedirfile[MAX_OSPATH];
#if 0
#ifndef _AIX
typedef unsigned int uint_t;
typedef unsigned short ushort_t;
#endif
#endif
/* End Generations */
int com_filesize;
@ -540,7 +535,7 @@ pack_t *COM_LoadPackFile (char *packfile)
return pack;
}
#if defined(_EXPERIMENTAL_) && defined(GENERATIONS)
#ifdef GENERATIONS
int
COM_pakzip_checkfile(unzFile *pak, const char *path)
{
@ -564,14 +559,10 @@ COM_pakzip_close(unzFile *pak)
unzCloseCurrentFile(pak);
}
int
COM_pakzip_read(unzFile *pak, void *buf, uint_t size, uint_t nmemb)
{
int len;
len = unzReadCurrentFile(pak, buf, size * nmemb);
int len = unzReadCurrentFile(pak, buf, size * nmemb);
return len / size;
}
@ -613,20 +604,19 @@ COM_pakzip_readfile(unzFile *pak, const char *path, uint_t bufsize, byte_t *buf)
return len;
}
#endif
#if defined _EXPERIMENTAL_ && GENERATIONS
pack_t *COM_LoadPackZipFile (char *packfile)
{
int i;
int i=0;
packfile_t *newfiles;
float numpackfiles;
unzFile *pak;
pack_t *pack_old;
int status;
dpackfile_t info[MAX_FILES_IN_PACK];
char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
// This following variable info is unused ATM.
// dpackfile_t info[MAX_FILES_IN_PACK];
char szCurrentFileName[256];
pak = unzOpen(packfile);
@ -641,7 +631,7 @@ pack_t *COM_LoadPackZipFile (char *packfile)
status=unzGoToFirstFile(pak);
while(status == UNZ_OK) {
unzGetCurrentFileInfo(pak,NULL,&szCurrentFileName,64,NULL,0,NULL,0);
// unzGetCurrentFileInfo(pak,NULL,&szCurrentFileName,64,NULL,0,NULL,0);
if(strcmp(newfiles[i].name, szCurrentFileName)==0)
break;
@ -697,9 +687,9 @@ COM_LoadGameDirectory(char *dir)
}
}
#if defined _EXPERIMENTAL_ && GENERATIONS
#ifdef GENERATIONS
for (done=false, i=0 ; !done ; i++ ) { // Load all Pak3 files.
snprintf(pakfile, sizeof(pakfile), "%s/pak%i.pk3", dir, i);
snprintf(pakfile, sizeof(pakfile), "%s/pak%i.qz", dir, i);
pak = COM_LoadPackZipFile(pakfile);

View file

@ -35,6 +35,15 @@
#define CASESENSITIVITYDEFAULT_NO
#endif
#ifndef UNZ_BUFSIZE
#define UNZ_BUFSIZE (16384)
#endif
#ifndef UNZ_MAXFILENAMEINZIP
#define UNZ_MAXFILENAMEINZIP (256)
#endif
#ifndef ALLOC
# define ALLOC(size) (malloc(size))
#endif
@ -88,7 +97,7 @@ typedef struct
uLong crc32_wait; /* crc32 we must obtain after decompress all */
uLong rest_read_compressed; /* number of byte to be decompressed */
uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
QFile* file; /* io structore of the zipfile */
FILE* file; /* io structore of the zipfile */
uLong compression_method; /* compression method (0==store) */
uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
} file_in_zip_read_info_s;
@ -98,7 +107,7 @@ typedef struct
*/
typedef struct
{
QFile* file; /* io structore of the zipfile */
FILE* file; /* io structore of the zipfile */
unz_global_info gi; /* public global information */
uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
uLong num_file; /* number of the current file in the zipfile*/
@ -125,7 +134,7 @@ typedef struct
local int unzlocal_getByte(fin,pi)
QFile *fin;
FILE *fin;
int *pi;
{
unsigned char c;
@ -149,7 +158,7 @@ local int unzlocal_getByte(fin,pi)
Reads a long in LSB order from the given gz_stream. Sets
*/
local int unzlocal_getShort (fin,pX)
QFile* fin;
FILE* fin;
uLong *pX;
{
uLong x ;
@ -171,7 +180,7 @@ local int unzlocal_getShort (fin,pX)
}
local int unzlocal_getLong (fin,pX)
QFile* fin;
FILE* fin;
uLong *pX;
{
uLong x ;
@ -266,7 +275,7 @@ extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivit
the global comment)
*/
local uLong unzlocal_SearchCentralDir(fin)
QFile *fin;
FILE *fin;
{
unsigned char* buf;
uLong uSizeFile;
@ -336,7 +345,7 @@ extern unzFile ZEXPORT unzOpen (path)
unz_s us;
unz_s *s;
uLong central_pos,uL;
QFile * fin ;
FILE * fin ;
uLong number_disk; /* number of the current dist, used for
spaning ZIP, unsupported, always 0*/
@ -527,10 +536,12 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
/* we check the magic */
if (err==UNZ_OK)
{
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x02014b50)
err=UNZ_BADZIPFILE;
}
if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
err=UNZ_ERRNO;
@ -607,10 +618,12 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
uSizeRead = extraFieldBufferSize;
if (lSeek!=0)
{
if (fseek(s->file,lSeek,SEEK_CUR)==0)
lSeek=0;
else
err=UNZ_ERRNO;
}
if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
err=UNZ_ERRNO;
@ -632,10 +645,12 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
uSizeRead = commentBufferSize;
if (lSeek!=0)
{
if (fseek(s->file,lSeek,SEEK_CUR)==0)
lSeek=0;
else
err=UNZ_ERRNO;
}
if ((file_info.size_file_comment>0) && (commentBufferSize>0))
if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
err=UNZ_ERRNO;
@ -815,14 +830,17 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
return UNZ_ERRNO;
if (err==UNZ_OK)
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
if (err==UNZ_OK) {
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) {
err=UNZ_ERRNO;
else if (uMagic!=0x04034b50)
} else if (uMagic!=0x04034b50) {
err=UNZ_BADZIPFILE;
}
}
if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
if (unzlocal_getShort(s->file,&uData) != UNZ_OK) {
err=UNZ_ERRNO;
}
/*
else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
err=UNZ_BADZIPFILE;
@ -1258,7 +1276,7 @@ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
char *szComment;
uLong uSizeBuf;
{
int err=UNZ_OK;
// int err=UNZ_OK;
unz_s* s;
uLong uReadThis ;
if (file==NULL)

View file

@ -46,18 +46,9 @@ extern "C" {
#endif
#ifndef _ZLIB_H
#include "zlib.h"
#include <zlib.h>
#endif
#ifndef UNZ_BUFSIZE
#define UNZ_BUFSIZE (16384)
#endif
#ifndef UNZ_MAXFILENAMEINZIP
#define UNZ_MAXFILENAMEINZIP (256)
#endif
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */