small cleanup and bugfix for zlib->abail_zlip

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1576 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2005-11-21 21:09:11 +00:00
parent 277d0b6960
commit cdb82f3316

View file

@ -184,11 +184,11 @@ qboolean FSOS_FLocate(void *handle, flocation_t *loc, char *filename, void *hash
if ( strchr (filename, '/') || strchr (filename,'\\')) if ( strchr (filename, '/') || strchr (filename,'\\'))
continue; continue;
} }
*/ */
// check a file in the directory tree // check a file in the directory tree
_snprintf (netpath, sizeof(netpath)-1, "%s/%s",(char*)handle, filename); _snprintf (netpath, sizeof(netpath)-1, "%s/%s",(char*)handle, filename);
f = fopen(netpath, "rb"); f = fopen(netpath, "rb");
if (!f) if (!f)
return -1; return -1;
@ -232,7 +232,7 @@ searchpathfuncs_t osfilefuncs = {
void FSPAK_PrintPath(void *handle) void FSPAK_PrintPath(void *handle)
{ {
pack_t *pak = handle; pack_t *pak = handle;
Con_Printf("%s\n", pak->filename); Con_Printf("%s\n", pak->filename);
} }
void FSPAK_ClosePath(void *handle) void FSPAK_ClosePath(void *handle)
@ -364,7 +364,7 @@ void *FSPAK_LoadPackFile (char *packfile)
// crc the directory to check for modifications // crc the directory to check for modifications
// crc = QCRC_Block((qbyte *)info, header.dirlen); // crc = QCRC_Block((qbyte *)info, header.dirlen);
// QCRC_Init (&crc); // QCRC_Init (&crc);
@ -390,7 +390,7 @@ void *FSPAK_LoadPackFile (char *packfile)
pack->handle = packhandle; pack->handle = packhandle;
pack->numfiles = numpackfiles; pack->numfiles = numpackfiles;
pack->files = newfiles; pack->files = newfiles;
Con_TPrintf (TL_ADDEDPACKFILE, packfile, numpackfiles); Con_TPrintf (TL_ADDEDPACKFILE, packfile, numpackfiles);
return pack; return pack;
} }
@ -411,7 +411,7 @@ void *com_pathforfile; //fread and stuff is preferable if null
#define ZEXPORT VARGS #define ZEXPORT VARGS
#ifdef ZLIB #ifdef AVAIL_ZLIB
#ifdef _WIN32 #ifdef _WIN32
#pragma comment( lib, "../libs/zlib.lib" ) #pragma comment( lib, "../libs/zlib.lib" )
#endif #endif
@ -438,7 +438,7 @@ typedef struct zipfile_s
static void FSZIP_PrintPath(void *handle) static void FSZIP_PrintPath(void *handle)
{ {
zipfile_t *zip = handle; zipfile_t *zip = handle;
Con_Printf("%s\n", zip->filename); Con_Printf("%s\n", zip->filename);
} }
static void FSZIP_ClosePath(void *handle) static void FSZIP_ClosePath(void *handle)
@ -572,7 +572,7 @@ static void *FSZIP_LoadZipFile (char *filename)
FILE *packhandle; FILE *packhandle;
if (COM_FileOpenRead (filename, &packhandle) == -1) if (COM_FileOpenRead (filename, &packhandle) == -1)
return NULL; return NULL;
fclose(packhandle); fclose(packhandle);
zip = Z_Malloc(sizeof(zipfile_t)); zip = Z_Malloc(sizeof(zipfile_t));
Q_strncpyz(zip->filename, filename, sizeof(zip->filename)); Q_strncpyz(zip->filename, filename, sizeof(zip->filename));
@ -714,14 +714,14 @@ int COM_FileOpenRead (char *path, FILE **hndl)
return -1; return -1;
} }
*hndl = f; *hndl = f;
return COM_filelength(f); return COM_filelength(f);
} }
int COM_FileSize(char *path) int COM_FileSize(char *path)
{ {
int len; int len;
FILE *h; FILE *h;
len = COM_FOpenFile(path, &h); len = COM_FOpenFile(path, &h);
if (len>=0) if (len>=0)
fclose(h); fclose(h);
@ -738,9 +738,9 @@ COM_Path_f
void COM_Path_f (void) void COM_Path_f (void)
{ {
searchpath_t *s; searchpath_t *s;
Con_TPrintf (TL_CURRENTSEARCHPATH); Con_TPrintf (TL_CURRENTSEARCHPATH);
if (com_purepaths) if (com_purepaths)
{ {
for (s=com_purepaths ; s ; s=s->nextpure) for (s=com_purepaths ; s ; s=s->nextpure)
@ -825,11 +825,11 @@ void COM_WriteFile (char *filename, void *data, int len)
{ {
FILE *f; FILE *f;
char name[MAX_OSPATH]; char name[MAX_OSPATH];
sprintf (name, "%s/%s", com_gamedir, filename); sprintf (name, "%s/%s", com_gamedir, filename);
COM_CreatePath(name); COM_CreatePath(name);
f = fopen (name, "wb"); f = fopen (name, "wb");
if (!f) if (!f)
{ {
@ -841,7 +841,7 @@ void COM_WriteFile (char *filename, void *data, int len)
return; return;
} }
} }
Sys_Printf ("COM_WriteFile: %s\n", name); Sys_Printf ("COM_WriteFile: %s\n", name);
fwrite (data, 1, len, f); fwrite (data, 1, len, f);
fclose (f); fclose (f);
@ -853,11 +853,11 @@ FILE *COM_WriteFileOpen (char *filename) //like fopen, but based around quake's
{ {
FILE *f; FILE *f;
char name[MAX_OSPATH]; char name[MAX_OSPATH];
sprintf (name, "%s/%s", com_gamedir, filename); sprintf (name, "%s/%s", com_gamedir, filename);
COM_CreatePath(name); COM_CreatePath(name);
f = fopen (name, "wb"); f = fopen (name, "wb");
return f; return f;
@ -874,7 +874,7 @@ Only used for CopyFile and download
void COM_CreatePath (char *path) void COM_CreatePath (char *path)
{ {
char *ofs; char *ofs;
for (ofs = path+1 ; *ofs ; ofs++) for (ofs = path+1 ; *ofs ; ofs++)
{ {
if (*ofs == '/') if (*ofs == '/')
@ -900,13 +900,13 @@ void COM_CopyFile (char *netpath, char *cachepath)
FILE *in, *out; FILE *in, *out;
int remaining, count; int remaining, count;
char buf[4096]; char buf[4096];
remaining = COM_FileOpenRead (netpath, &in); remaining = COM_FileOpenRead (netpath, &in);
COM_CreatePath (cachepath); // create directories up to the cache file COM_CreatePath (cachepath); // create directories up to the cache file
out = fopen(cachepath, "wb"); out = fopen(cachepath, "wb");
if (!out) if (!out)
Sys_Error ("Error opening %s", cachepath); Sys_Error ("Error opening %s", cachepath);
while (remaining) while (remaining)
{ {
if (remaining < sizeof(buf)) if (remaining < sizeof(buf))
@ -931,7 +931,7 @@ void FS_FlushFSHash(void)
{ {
int i; int i;
bucket_t *bucket, *next; bucket_t *bucket, *next;
for (i = 0; i < filesystemhash.numbuckets; i++) for (i = 0; i < filesystemhash.numbuckets; i++)
{ {
bucket = filesystemhash.bucket[i]; bucket = filesystemhash.bucket[i];
@ -1246,11 +1246,11 @@ void COM_LoadCacheFile (char *path, struct cache_user_s *cu)
qbyte *COM_LoadStackFile (char *path, void *buffer, int bufsize) qbyte *COM_LoadStackFile (char *path, void *buffer, int bufsize)
{ {
qbyte *buf; qbyte *buf;
loadbuf = (qbyte *)buffer; loadbuf = (qbyte *)buffer;
loadsize = bufsize; loadsize = bufsize;
buf = COM_LoadFile (path, 4); buf = COM_LoadFile (path, 4);
return buf; return buf;
} }
@ -1353,7 +1353,7 @@ qboolean COM_LoadMapPackFile (char *filename, int ofs)
pack->handle = packhandle; pack->handle = packhandle;
pack->numfiles = numpackfiles; pack->numfiles = numpackfiles;
pack->files = newfiles; pack->files = newfiles;
Con_TPrintf (TL_ADDEDPACKFILE, filename, numpackfiles); Con_TPrintf (TL_ADDEDPACKFILE, filename, numpackfiles);
COM_AddPathHandle(&packfilefuncs, pack, true, true); COM_AddPathHandle(&packfilefuncs, pack, true, true);
@ -1642,7 +1642,7 @@ void COM_FlushFSCache(void)
COM_AddGameDirectory COM_AddGameDirectory
Sets com_gamedir, adds the directory to the head of the path, Sets com_gamedir, adds the directory to the head of the path,
then loads and adds pak1.pak pak2.pak ... then loads and adds pak1.pak pak2.pak ...
================ ================
*/ */
void COM_AddGameDirectory (char *dir, unsigned int loadstuff) void COM_AddGameDirectory (char *dir, unsigned int loadstuff)
@ -1680,7 +1680,7 @@ void COM_AddGameDirectory (char *dir, unsigned int loadstuff)
if (loadstuff & 2) if (loadstuff & 2)
COM_AddDataFiles("pak", &packfilefuncs);//q1/hl/h2/q2 COM_AddDataFiles("pak", &packfilefuncs);//q1/hl/h2/q2
//pk2s never existed. //pk2s never existed.
#ifdef ZLIB #ifdef AVAIL_ZLIB
if (loadstuff & 4) if (loadstuff & 4)
COM_AddDataFiles("pk3", &zipfilefuncs); //q3 + offspring COM_AddDataFiles("pk3", &zipfilefuncs); //q3 + offspring
if (loadstuff & 8) if (loadstuff & 8)
@ -1790,30 +1790,6 @@ void COM_Gamedir (char *dir)
while (com_searchpaths != com_base_searchpaths) while (com_searchpaths != com_base_searchpaths)
{ {
com_searchpaths->funcs->ClosePath(com_searchpaths->handle); com_searchpaths->funcs->ClosePath(com_searchpaths->handle);
/*
switch(com_searchpaths->type)
{
case SPT_PACK:
fclose (com_searchpaths->u.pack->handle);
Z_Free (com_searchpaths->u.pack->files);
#ifdef HASH_FILESYSTEM
Z_Free (com_searchpaths->u.pack->hash.bucket);
#endif
Z_Free (com_searchpaths->u.pack);
break;
#ifdef ZLIB
case SPT_ZIP:
unzClose(com_searchpaths->u.zip->handle);
Z_Free (com_searchpaths->u.zip->files);
#ifdef HASH_FILESYSTEM
Z_Free (com_searchpaths->u.zip->hash.bucket);
#endif
Z_Free (com_searchpaths->u.zip);
break;
#endif
case SPT_OS:
break;
}*/
next = com_searchpaths->next; next = com_searchpaths->next;
Z_Free (com_searchpaths); Z_Free (com_searchpaths);
com_searchpaths = next; com_searchpaths = next;
@ -1945,7 +1921,7 @@ void FS_ForceToPure(char *str, char *crcs, int seed)
{ {
crcs = COM_Parse(crcs); crcs = COM_Parse(crcs);
crc = atoi(com_token); crc = atoi(com_token);
if (!crc) if (!crc)
continue; continue;