Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

pakstuff.h File Reference

#include <windows.h>

Include dependency graph for pakstuff.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  DirListStruct
struct  DirStruct
struct  FileListStruct
struct  PACKDirectory

Defines

#define FROMDISK   -1
#define FTYPE_AU   21
#define FTYPE_BMP   36
#define FTYPE_BSP   10
#define FTYPE_ERROR   -1
#define FTYPE_GIF   37
#define FTYPE_IWAD   1
#define FTYPE_MODEL   11
#define FTYPE_PACK   3
#define FTYPE_PBM_ASC   30
#define FTYPE_PBM_RAW   33
#define FTYPE_PCX   38
#define FTYPE_PGM_ASC   31
#define FTYPE_PGM_RAW   34
#define FTYPE_PPM_ASC   32
#define FTYPE_PPM_RAW   35
#define FTYPE_PWAD   2
#define FTYPE_SPRITE   12
#define FTYPE_UNKNOWN   0
#define FTYPE_VOC   22
#define FTYPE_WAD2   4
#define FTYPE_WAV   20
#define MAX(a, b)   (((a) > (b)) ? (a) : (b))
#define MIN(a, b)   (((a) < (b)) ? (a) : (b))
#define RANDOM(x)   (random() % (x))
#define RANDOMIZE()   srand((int) time(NULL))
#define ReadFloat32(f, p)   ReadBytes((f), (p), 4L)
#define ReadInt16(f, p)   ReadBytes((f), (p), 2L)
#define ReadInt32(f, p)   ReadBytes((f), (p), 4L)
#define SwapFloat32(x)   (x)
#define SwapInt16(x)   (x)
#define SwapInt32(x)   (x)
#define WriteFloat32(f, p)   WriteBytes((f), (p), 4L)
#define WriteInt16(f, p)   WriteBytes((f), (p), 2L)
#define WriteInt32(f, p)   WriteBytes((f), (p), 4L)

Typedefs

typedef DirStruct DIRECTORY
typedef DirListStruct DIRLIST
typedef FileListStruct FILELIST
typedef float Float32
typedef double Float64
typedef short Int16
typedef long Int32
typedef char Int8
typedef PACKDirectoryPACKDirPtr
typedef unsigned short UInt16
typedef unsigned long UInt32
typedef unsigned char UInt8

Functions

boolean AddToDirListAlphabetized (DIRLIST **, char *, int)
boolean AddToFileListAlphabetized (FILELIST **t, char *, UInt32, UInt32, boolean)
void ClearDirList (DIRLIST **)
void ClearFileList (FILELIST **)
void ClosePakFile (void)
boolean GetPackFileList (FILELIST **, char *)
boolean GetPackTextureDirs (DIRLIST **)
void WINAPI InitPakFile (const char *pBasePath, const char *pName)
void OpenPakFile (const char *)
int PakLoadAnyFile (const char *filename, void **bufferptr)
boolean PakLoadFile (const char *, void **)

Variables

int m_nPAKIndex
FILEpakfile [16]
boolean pakopen
DIRECTORYpaktextures


Define Documentation

#define FROMDISK   -1
 

Definition at line 88 of file pakstuff.h.

Referenced by FillTextureMenu(), and Texture_ShowDirectory().

#define FTYPE_AU   21
 

Definition at line 53 of file pakstuff.h.

#define FTYPE_BMP   36
 

Definition at line 61 of file pakstuff.h.

#define FTYPE_BSP   10
 

Definition at line 49 of file pakstuff.h.

#define FTYPE_ERROR   -1
 

Definition at line 64 of file pakstuff.h.

#define FTYPE_GIF   37
 

Definition at line 62 of file pakstuff.h.

#define FTYPE_IWAD   1
 

Definition at line 45 of file pakstuff.h.

#define FTYPE_MODEL   11
 

Definition at line 50 of file pakstuff.h.

#define FTYPE_PACK   3
 

Definition at line 47 of file pakstuff.h.

#define FTYPE_PBM_ASC   30
 

Definition at line 55 of file pakstuff.h.

#define FTYPE_PBM_RAW   33
 

Definition at line 58 of file pakstuff.h.

#define FTYPE_PCX   38
 

Definition at line 63 of file pakstuff.h.

#define FTYPE_PGM_ASC   31
 

Definition at line 56 of file pakstuff.h.

#define FTYPE_PGM_RAW   34
 

Definition at line 59 of file pakstuff.h.

#define FTYPE_PPM_ASC   32
 

Definition at line 57 of file pakstuff.h.

#define FTYPE_PPM_RAW   35
 

Definition at line 60 of file pakstuff.h.

#define FTYPE_PWAD   2
 

Definition at line 46 of file pakstuff.h.

#define FTYPE_SPRITE   12
 

Definition at line 51 of file pakstuff.h.

#define FTYPE_UNKNOWN   0
 

Definition at line 44 of file pakstuff.h.

#define FTYPE_VOC   22
 

Definition at line 54 of file pakstuff.h.

#define FTYPE_WAD2   4
 

Definition at line 48 of file pakstuff.h.

#define FTYPE_WAV   20
 

Definition at line 52 of file pakstuff.h.

#define MAX a,
 )     (((a) > (b)) ? (a) : (b))
 

Definition at line 39 of file pakstuff.h.

#define MIN a,
 )     (((a) < (b)) ? (a) : (b))
 

Definition at line 40 of file pakstuff.h.

#define RANDOM  )     (random() % (x))
 

Definition at line 41 of file pakstuff.h.

 
#define RANDOMIZE  )     srand((int) time(NULL))
 

Definition at line 42 of file pakstuff.h.

#define ReadFloat32 f,
p   )     ReadBytes((f), (p), 4L)
 

Definition at line 79 of file pakstuff.h.

#define ReadInt16 f,
p   )     ReadBytes((f), (p), 2L)
 

Definition at line 77 of file pakstuff.h.

#define ReadInt32 f,
p   )     ReadBytes((f), (p), 4L)
 

Definition at line 78 of file pakstuff.h.

Referenced by ReadPACKDirectory().

#define SwapFloat32  )     (x)
 

Definition at line 85 of file pakstuff.h.

#define SwapInt16  )     (x)
 

Definition at line 83 of file pakstuff.h.

#define SwapInt32  )     (x)
 

Definition at line 84 of file pakstuff.h.

Referenced by ReadPACKDirectory().

#define WriteFloat32 f,
p   )     WriteBytes((f), (p), 4L)
 

Definition at line 82 of file pakstuff.h.

#define WriteInt16 f,
p   )     WriteBytes((f), (p), 2L)
 

Definition at line 80 of file pakstuff.h.

#define WriteInt32 f,
p   )     WriteBytes((f), (p), 4L)
 

Definition at line 81 of file pakstuff.h.


Typedef Documentation

typedef struct DirStruct DIRECTORY
 

Referenced by AddPakDir(), ClearPaKDir(), FindPakDir(), GetPackFileList(), OpenPakFile(), and PakLoadFile().

typedef struct DirListStruct DIRLIST
 

Referenced by AddToDirListAlphabetized(), ClearDirList(), FillTextureMenu(), and GetPackTextureDirs().

typedef struct FileListStruct FILELIST
 

Referenced by AddToFileListAlphabetized(), ClearFileList(), GetPackFileList(), LoadPK3FileList(), PakLoadFile(), and Texture_ShowDirectory().

typedef float Float32
 

Definition at line 37 of file pakstuff.h.

typedef double Float64
 

Definition at line 38 of file pakstuff.h.

typedef short Int16
 

Definition at line 32 of file pakstuff.h.

typedef long Int32
 

Definition at line 33 of file pakstuff.h.

typedef char Int8
 

Definition at line 31 of file pakstuff.h.

typedef struct PACKDirectory* PACKDirPtr
 

Definition at line 95 of file pakstuff.h.

Referenced by DumpPACKDirectory(), and ReadPACKDirectory().

typedef unsigned short UInt16
 

Definition at line 35 of file pakstuff.h.

Referenced by DumpPACKDirectory(), GetPackTextureDirs(), and ReadPACKDirectory().

typedef unsigned long UInt32
 

Definition at line 36 of file pakstuff.h.

Referenced by AddToFileListAlphabetized(), DumpPACKDirectory(), ReadBytes(), ReadPACKDirectory(), SNDDMA_Init(), and WriteBytes().

typedef unsigned char UInt8
 

Definition at line 34 of file pakstuff.h.

Referenced by ReadMagic().


Function Documentation

boolean AddToDirListAlphabetized DIRLIST **  ,
char *  ,
int 
 

Definition at line 754 of file pakstuff.cpp.

References __qmalloc(), DIRLIST, DirListStruct::dirname, DirListStruct::from, DirListStruct::next, NULL, strcpy(), and strlwr().

Referenced by FillTextureMenu(), and GetPackTextureDirs().

00755 {
00756     DIRLIST *currentPtr, *previousPtr, *newPtr;
00757 
00758     strlwr(dirname);
00759     for(currentPtr = *list; currentPtr; currentPtr = currentPtr->next)
00760     {
00761         if(!stricmp(dirname, currentPtr->dirname))
00762         {
00763             return false;
00764         }
00765     }
00766     previousPtr = NULL;
00767     currentPtr = *list;
00768 
00769     if((newPtr = (DIRLIST *)__qmalloc(sizeof(DIRLIST))) == NULL)
00770         return false;
00771 
00772     strcpy(newPtr->dirname, dirname);
00773     newPtr->from = from;
00774 
00775     while(currentPtr != NULL && stricmp(dirname, currentPtr->dirname) > 0)
00776     {
00777         previousPtr = currentPtr;
00778         currentPtr = currentPtr->next;
00779     } //End while
00780     if(previousPtr == NULL)
00781     {
00782         newPtr->next = *list;
00783         *list = newPtr;
00784     } //End if
00785     else
00786     {
00787         previousPtr->next = newPtr;
00788         newPtr->next = currentPtr;
00789     } //End else
00790     return true;
00791 }

Here is the call graph for this function:

boolean AddToFileListAlphabetized FILELIST **  t,
char *  ,
UInt32  ,
UInt32  ,
boolean 
 

Definition at line 793 of file pakstuff.cpp.

References __qmalloc(), FILELIST, FileListStruct::filename, FileListStruct::next, NULL, FileListStruct::offset, FileListStruct::size, strcpy(), and UInt32.

Referenced by GetPackFileList(), LoadPK3FileList(), OpenPakFile(), and Texture_ShowDirectory().

00794 {
00795     FILELIST    *currentPtr, *previousPtr, *newPtr;
00796 
00797     for(currentPtr = *list; currentPtr; currentPtr = currentPtr->next)
00798     {
00799         if(!stricmp(filename, currentPtr->filename))
00800         {
00801             return false;
00802         }
00803     }
00804     previousPtr = NULL;
00805     currentPtr = *list;
00806 
00807     if((newPtr = (FILELIST *)__qmalloc(sizeof(FILELIST))) == NULL)
00808         return false;
00809 
00810     strcpy(newPtr->filename, filename);
00811     newPtr->offset = offset;
00812     newPtr->size = size;
00813 
00814     while(currentPtr != NULL && stricmp(filename, currentPtr->filename) > 0)
00815     {
00816         previousPtr = currentPtr;
00817         currentPtr = currentPtr->next;
00818     } //End while
00819     if(previousPtr == NULL)
00820     {
00821         newPtr->next = *list;
00822         *list = newPtr;
00823     } //End if
00824     else
00825     {
00826         previousPtr->next = newPtr;
00827         newPtr->next = currentPtr;
00828     } //End else
00829     return true;
00830 }

Here is the call graph for this function:

void ClearDirList DIRLIST **   ) 
 

Definition at line 611 of file pakstuff.cpp.

References DIRLIST, free(), and DirListStruct::next.

Referenced by FillTextureMenu().

00612 {
00613     DIRLIST *temp;
00614 
00615     while(*list)
00616     {
00617         temp = *list;
00618         *list = (*list)->next;
00619         free(temp);
00620     }
00621 }

Here is the call graph for this function:

void ClearFileList FILELIST **   ) 
 

Definition at line 599 of file pakstuff.cpp.

References FILELIST, free(), and FileListStruct::next.

Referenced by ClearPaKDir(), and Texture_ShowDirectory().

00600 {
00601     FILELIST    *temp;
00602 
00603     while(*list)
00604     {
00605         temp = *list;
00606         *list = (*list)->next;
00607         free(temp);
00608     }
00609 }

Here is the call graph for this function:

void ClosePakFile void   ) 
 

Definition at line 1155 of file pakstuff.cpp.

References CleanUpPakDirs(), closePK3(), fclose(), g_zFiles, m_nPAKIndex, PtrList::Next(), p, pakfile, pakopen, PtrList::Ref(), unzFile, and ZFileList.

Referenced by CMainFrame::OnDestroy().

01156 {
01157     if(pakopen)
01158   {
01159     if (g_bPK3)
01160     {
01161       ZFileList *p = g_zFiles.Next();
01162       while (p != NULL)
01163       {
01164         unzFile uz = p->Ref();
01165         closePK3(uz);
01166         p = p->Next();
01167       }
01168     }
01169     else
01170     {
01171       fclose(pakfile[m_nPAKIndex]);
01172     }
01173   }
01174     pakopen = false;
01175   CleanUpPakDirs();
01176 }

Here is the call graph for this function:

boolean GetPackFileList FILELIST **  ,
char * 
 

Definition at line 675 of file pakstuff.cpp.

References AddToFileListAlphabetized(), DIRECTORY, filelist, FILELIST, FileListStruct::filename, DirStruct::files, FindPakDir(), i, LoadPK3FileList(), FileListStruct::next, FileListStruct::offset, pattern, and strchr().

Referenced by Texture_ShowDirectory().

00676 {
00677     char                    *str1, *str2;
00678     int                     i;
00679     DIRECTORY               *dummy = paktextures;
00680     FILELIST                *temp;
00681 
00682     if (!pakopen)
00683         return false;
00684 
00685   if (g_bPK3)
00686   {
00687     return LoadPK3FileList(filelist, pattern);
00688   }
00689 
00690     str1 = pattern;
00691 
00692     for(i = 0; pattern[i] != '\0'; i++)
00693     {
00694         if(pattern[i] == '\\')
00695             pattern[i] = '/';
00696     }
00697 
00698     while(strchr(str1, '/'))
00699     {
00700         str2 = strchr(str1, '/');
00701         *str2++ = '\0';
00702         dummy = FindPakDir(dummy, str1);
00703         if(!dummy)
00704             return false;
00705         str1 = str2;
00706     }
00707     for(temp = dummy->files; temp; temp=temp->next)
00708     {
00709       AddToFileListAlphabetized(filelist, temp->filename, temp->offset, 0, false);
00710     }
00711     return true;
00712 }

Here is the call graph for this function:

boolean GetPackTextureDirs DIRLIST **   ) 
 

Definition at line 714 of file pakstuff.cpp.

References AddToDirListAlphabetized(), DIRLIST, g_PK3TexturePaths, i, name, PtrList::Next(), pakdirptr, PtrList::Ref(), strchr(), StrList, strncpy(), and UInt16.

Referenced by FillTextureMenu().

00715 {
00716     UInt16                  i;
00717     char                    buf[57];
00718 
00719     if (!pakopen)
00720         return 1;
00721 
00722   if (g_bPK3)
00723   {
00724     StrList *pl = g_PK3TexturePaths.Next();
00725     while (pl != NULL)
00726     {
00727       AddToDirListAlphabetized(dirlist, pl->Ref(), 0);
00728       pl = pl->Next();
00729     }
00730     return true;
00731   }
00732 
00733     for (i = 0; i < dirsize; i++)
00734     {
00735         if(!strnicmp(pakdirptr[i].name, "textures", 8))
00736         {
00737             strncpy(buf, &(pakdirptr[i].name[9]), 46);
00738             if(strchr(buf, '\\'))
00739             *strchr(buf, '\\') = '\0';
00740             else if(strchr(buf, '/'))
00741             *strchr(buf, '/') = '\0';
00742             else
00743             buf[56] = '\0';
00744 
00745             if(strchr(buf, '.'))
00746                 continue;
00747 
00748             AddToDirListAlphabetized(dirlist, buf, 0);
00749         }
00750     }
00751     return true;
00752 }

Here is the call graph for this function:

void WINAPI InitPakFile const char *  pBasePath,
const char *  pName
 

Definition at line 1179 of file pakstuff.cpp.

References AddSlash(), g_strBasePath, m_nPAKIndex, OpenPakFile(), pakopen, paktextures, sprintf(), and strcpy().

Referenced by CMainFrame::CreateQEChildren(), LightMain(), main(), VisMain(), VLightMain(), and VSoundMain().

01180 {
01181   m_nPAKIndex = 0;
01182   pakopen = false;
01183     paktextures = NULL;
01184   strcpy(g_strBasePath, pBasePath);
01185   if (pName == NULL)
01186   {
01187     char cWork[WORK_LEN];
01188       Str strPath(pBasePath);
01189     AddSlash(strPath);
01190     strPath += "*.pk3";
01191     bool bGo = true;
01192       struct _finddata_t fileinfo;
01193     int handle = _findfirst (strPath, &fileinfo);
01194       if (handle != -1)
01195     {
01196         do
01197           {
01198         sprintf(cWork, "%s\\%s", pBasePath, fileinfo.name);
01199         OpenPakFile(cWork);
01200           } while (_findnext( handle, &fileinfo ) != -1);
01201         _findclose (handle);
01202     }
01203     }
01204   else
01205   {
01206       OpenPakFile(pName);
01207   }
01208 }

Here is the call graph for this function:

void OpenPakFile const char *   ) 
 

Definition at line 1061 of file pakstuff.cpp.

References AddPakDir(), AddToFileListAlphabetized(), DIRECTORY, dirsize, f_type, fclose(), DirStruct::files, Str::Find(), g_bPK3, HavePakColormap, i, m_nPAKIndex, Str::MakeLower(), PACKDirectory::name, name, PACKDirectory::offset, OpenFileReadMagic(), OpenPK3(), PakColormapOffset, PakColormapSize, pakdirptr, pakfile, pakopen, paktextures, ReadPACKDirectory(), PACKDirectory::size, and strchr().

Referenced by InitPakFile().

01062 {
01063     int         i;
01064     char        *str1, *str2;
01065     DIRECTORY   *dummy;
01066 
01067     if(!pakopen)
01068         paktextures = NULL;
01069 
01070     HavePakColormap = false;
01071 
01072   Str strTest(filename);
01073   strTest.MakeLower();
01074   if (strTest.Find("pk3") >= 0 || strTest.Find("zip") >= 0)
01075   {
01076     pakopen = g_bPK3 = OpenPK3(filename);
01077     return;
01078   }
01079 
01080 
01081     if((pakfile[m_nPAKIndex] = OpenFileReadMagic(filename, &f_type)) == NULL)
01082     {
01083     //FIXME: error routine
01084         //Sys_Printf("ERROR: Could not open %s", filename);
01085         return;
01086     }
01087     if(f_type != FTYPE_PACK)
01088     {
01089         //Sys_Printf("ERROR: %s is not a valid pack file", filename);
01090         if(f_type != FTYPE_ERROR)
01091             fclose(pakfile[m_nPAKIndex]);
01092         return;
01093     }
01094     pakdirptr = ReadPACKDirectory(pakfile[m_nPAKIndex], 0, &dirsize);
01095     if (pakdirptr == NULL)
01096     {
01097         //Sys_Printf("ERROR: Could not read pack directory", filename);
01098         fclose(pakfile[m_nPAKIndex]);
01099         return;
01100     }
01101     if (dirsize == 0)
01102     {
01103         fclose(pakfile[m_nPAKIndex]);
01104         return;
01105     }
01106     for (i = 0; i < dirsize; i++)
01107     {
01108         if(!strnicmp("textures/", pakdirptr[i].name, 9))
01109         {
01110             dummy = paktextures;
01111             str1 = pakdirptr[i].name+9;
01112             while(strchr(str1, '/'))
01113             {
01114                 str2 = strchr(str1, '/');
01115                 *str2++ = '\0';
01116                     dummy = AddPakDir(dummy==paktextures?&paktextures:&dummy, str1);
01117                 str1 = str2;
01118             }
01119 
01120             AddToFileListAlphabetized(&(dummy->files), str1, pakdirptr[i].offset, pakdirptr[i].size, true);
01121         }
01122         else if(!strnicmp("pics/colormap.pcx", pakdirptr[i].name, 17))
01123         {
01124             HavePakColormap = true;
01125             PakColormapOffset = pakdirptr[i].offset;
01126             PakColormapSize = pakdirptr[i].size;
01127         }
01128     }
01129     pakopen = true;
01130 
01131 }

Here is the call graph for this function:

int PakLoadAnyFile const char *  filename,
void **  bufferptr
 

Definition at line 884 of file pakstuff.cpp.

References __ConvertDOSToUnixName(), __qblockmalloc(), __qmalloc(), __StrDup(), AddSlash(), buffer, PtrList::Find(), FindReplace(), fread(), fseek(), g_LogFile, g_PK3Files, g_strBasePath, Str::GetBuffer(), i, LogFile::Log(), PK3FileInfo::m_lSize, m_nPAKIndex, PK3FileInfo::m_pName, PK3FileInfo::m_zFile, PK3FileInfo::m_zInfo, Str::MakeLower(), memcpy(), n, name, offset, pakdirptr, pakfile, PK3List, PtrList::Ptr(), SEEK_SET, PACKDirectory::size, sprintf(), strlwr(), unzCloseCurrentFile(), unzOpenCurrentFile(), and unzReadCurrentFile().

Referenced by LoadBMP(), LoadImageFile(), LoadJPG(), LoadModel(), LoadPCX(), LoadShader(), LoadShaders(), LoadTGA(), QERApp_LoadFile(), R_LoadMD3(), and ViewShader().

00885 {
00886   char cWork[WORK_LEN];
00887   if (g_bPK3)
00888   {
00889     PK3FileInfo *pInfo;
00890     Str strKey;
00891     // need to lookup the file without the base/texture path on it
00892     Str strBase(g_strBasePath);
00893     AddSlash(strBase);
00894     __ConvertDOSToUnixName(cWork, strBase);
00895     Str strFile(filename);
00896     __ConvertDOSToUnixName(strFile, strFile);
00897     strFile.MakeLower();
00898     strlwr(cWork);
00899     FindReplace(strFile, cWork, "");
00900 
00901     PK3FileInfo infoFind;
00902     infoFind.m_pName = __StrDup(strFile.GetBuffer());
00903     PK3List *pList = g_PK3Files.Find(&infoFind);
00904     if (pList)
00905     {
00906       pInfo = pList->Ptr();
00907       memcpy(pInfo->m_zFile, &pInfo->m_zInfo, sizeof(unz_s));
00908       if (unzOpenCurrentFile(pInfo->m_zFile) == UNZ_OK)
00909       {
00910         void *buffer = __qblockmalloc(pInfo->m_lSize+1);
00911         int n = unzReadCurrentFile(pInfo->m_zFile , buffer, pInfo->m_lSize);
00912         *bufferptr = buffer;
00913         unzCloseCurrentFile(pInfo->m_zFile);
00914         return n;
00915       }
00916     }
00917 #ifdef LOG_PAKFAIL
00918     sprintf(cWork, "PAK failed on %s\n", filename);
00919     g_LogFile.Log(cWork);
00920 #endif
00921     return -1;
00922   }
00923 
00924     for (int i = 0; i < dirsize; i++)
00925     {
00926         if(!stricmp(filename, pakdirptr[i].name))
00927         {
00928             if (fseek(pakfile[m_nPAKIndex], pakdirptr[i].offset, SEEK_SET) >= 0)
00929       {
00930           void *buffer = __qmalloc (pakdirptr[i].size+1);
00931           ((char *)buffer)[pakdirptr[i].size] = 0;
00932               if (fread(buffer, 1, pakdirptr[i].size, pakfile[m_nPAKIndex]) == pakdirptr[i].size)
00933         {
00934           *bufferptr = buffer;
00935           return pakdirptr[i].size;
00936         }
00937       }
00938         }
00939     }
00940 #ifdef LOG_PAKFAIL
00941     sprintf(cWork, "PAK failed on %s\n", filename);
00942     g_LogFile.Log(cWork);
00943 #endif
00944   return -1;
00945 }

Here is the call graph for this function:

boolean PakLoadFile const char *  ,
void ** 
 

Definition at line 832 of file pakstuff.cpp.

References __ConvertDOSToUnixName(), __qmalloc(), buffer, DIRECTORY, FILELIST, FileListStruct::filename, DirStruct::files, FindPakDir(), fread(), free(), fseek(), m_nPAKIndex, FileListStruct::next, FileListStruct::offset, p, pakfile, SEEK_SET, FileListStruct::size, and strchr().

Referenced by Texture_ForName().

00833 {
00834     FILELIST    *p = NULL;
00835     DIRECTORY   *dummy;
00836     void        *buffer;
00837     char        *str1, *str2;
00838 
00839     if(!pakopen)
00840         return false;
00841 
00842   Str str(filename);
00843   __ConvertDOSToUnixName(str, str);
00844 
00845     dummy = paktextures;
00846     str1 = str;
00847 
00848     while(strchr(str1, '/'))
00849     {
00850         str2 = strchr(str1, '/');
00851         *str2++ = '\0';
00852         dummy = FindPakDir(dummy, str1);
00853         if(!dummy)
00854             return false;
00855         str1 = str2;
00856     }
00857 
00858   // FIXME: add error handling routines
00859     for(p = dummy->files; p; p = p->next)
00860     {
00861         if(!stricmp(str1, p->filename))
00862         {
00863             if (fseek(pakfile[m_nPAKIndex], p->offset, SEEK_SET) < 0)
00864             {
00865                 //Sys_Printf("Unexpected EOF in pakfile\n");
00866                 return false;
00867             }
00868             if((buffer = __qmalloc(p->size+5)) == NULL)
00869                 //Error("Could not allocate memory");
00870     
00871             if(fread(buffer, 1, p->size, pakfile[m_nPAKIndex]) != p->size)
00872             {
00873                 //Sys_Printf("Error reading %s from pak\n", str1);
00874                 free(buffer);
00875                 return false;
00876             }
00877             *bufferptr = buffer;
00878             return true;
00879         }
00880     }
00881     return false;
00882 }

Here is the call graph for this function:


Variable Documentation

int m_nPAKIndex
 

Definition at line 34 of file pakstuff.cpp.

Referenced by ClosePakFile(), InitPakFile(), OpenPakFile(), PakLoadAnyFile(), and PakLoadFile().

FILE* pakfile[16]
 

Definition at line 35 of file pakstuff.cpp.

Referenced by ClosePakFile(), FindQuakeFilesInPak(), FindQuakeFilesWithPakFilter(), FS_AddGameDirectory(), OpenPakFile(), PakLoadAnyFile(), and PakLoadFile().

boolean pakopen
 

Definition at line 39 of file pakstuff.cpp.

Referenced by ClosePakFile(), InitPakFile(), and OpenPakFile().

DIRECTORY* paktextures
 

Definition at line 41 of file